Package dk.brics.automaton

Examples of dk.brics.automaton.Transition


        State last = start;

        for (int i = 0; i < length; i++) {
            last = new State();
            for (int k : alphabet) {
                tmp.addTransition(new Transition(FiniteAutomaton.getCharFromInt(k), last));
            }
            tmp = last;

        }
        last.setAccept(true);
View Full Code Here


  private State makeState() {
    State s = new State();
    if(contents != null) s.setAccept(true);
    for(Character c : next.keySet()) {
      State nextState = next.get(c).makeState();
      Transition t = new Transition(c, nextState);
      s.addTransition(t);
    }   
    return s;
  }
View Full Code Here

    public Automaton toAutomaton() {
        Automaton a = new Automaton();
        State s = a.getInitialState();
        s.setAccept(true);
        for (Interval v : intervals) {
            s.addTransition(new Transition(v.getMin(), v.getMax(), s));
        }
        return a;
    }
View Full Code Here

                char max = t.getMax();
                if (min <= '\u0020') {
                    min = '\u0021';
                }
                if (min <= max) {
                    initial.addTransition(new Transition(min, max, t.getDest()));
                }
            }
        }
        State accept = new State();
        accept.setAccept(true);
        for (State s : b.getAcceptStates()) {
            s.setAccept(false);
        }
        if (initial_accept) {
            initial.setAccept(true);
        }
        for (State s : post) {
            Set<State> prevset = normal_prevs.get(s);
            if (prevset != null) {
                for (State p : prevset) {
                    for (Transition t : new ArrayList<Transition>(p.getTransitions())) {
                        if (t.getDest() == s) {
                            char min = t.getMin();
                            char max = t.getMax();
                            if (min <= '\u0020') {
                                min = '\u0021';
                            }
                            if (min <= max) {
                                p.addTransition(new Transition(min, max, accept));
                            }
                        }
                    }
                }
            }
View Full Code Here

                if (min != Character.MIN_VALUE || max != Character.MAX_VALUE) {
                    transitions.remove(t);
                    for (int c = min; c <= max; c++) {
                      String up = String.valueOf((char)c).toUpperCase();
                      if (up.length() == 1) {
                        transitions.add(new Transition(Character.toUpperCase((char) c), dest));
                      } else {
                        // YES some characters translate to more than one character when turned upper case
                        // for example the German character "�" becomes "SS"
                        State lastState = s;
                        for (int i=0; i<up.length()-1; i++) {
                          char ch = up.charAt(i);
                          State state = new State();
                          lastState.addTransition(new Transition(ch, state));
                          lastState = state;
                        }
                        lastState.addTransition(new Transition(up.charAt(up.length()-1), dest));
                      }
                    }
                }
            }
        }
View Full Code Here

            for (Transition t : new ArrayList<Transition>(transitions)) {
                char min = t.getMin();
                char max = t.getMax();
                State dest = t.getDest();
                if (min <= c && c <= max) {
                    transitions.add(new Transition(Character.MIN_VALUE, Character.MAX_VALUE, dest));
                }
            }
        }
        b.setDeterministic(false);
        b.reduce();
View Full Code Here

       
        Set<State> live = a.getLiveStates();
        for (State state : queue) {
            for (Transition t : state.getTransitions()) {
                if (live.contains(t.getDest())) {
                    initial.addTransition(new Transition(t.getMin(), t.getMax(), accept));
                }
            }
        }
       
        // boilerplate stuff
View Full Code Here

    @Override
    public Automaton op(Automaton a) {
        Automaton b = a.clone();
        State pad = new State();
        pad.setAccept(true);
        pad.addTransition(new Transition('\u0000', pad));
        Set<StatePair> epsilons = new HashSet<StatePair>();
        for (State s : b.getStates()) {
            if (s.isAccept()) {
                epsilons.add(new StatePair(s, pad));
            } else {
View Full Code Here

          if (tr.getMin() <= first && tr.getMax() >= first) {
            killedTransitions.add(new StateTransitionPair(origin, tr));
           
            // add back the remaining characters from the interval
            if (tr.getMin() < first) {
              newTransitions.add(new StateTransitionPair(origin, new Transition(tr.getMin(), (char)(first-1), tr.getDest())));
            }
            if (tr.getMax() > first) {
              newTransitions.add(new StateTransitionPair(origin, new Transition((char)(first+1), tr.getMax(), tr.getDest())));
            }
          }
        }
      }
     
View Full Code Here

      State first = new State();
      list.add(first);
      State last = first;
      for (int i=0; i<s.length(); i++) {
        State state = new State();
        last.addTransition(new Transition(s.charAt(i), state));
        list.add(state);
        last = state;
      }
      return list;
    }
View Full Code Here

TOP

Related Classes of dk.brics.automaton.Transition

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.