Package dk.brics.automaton

Examples of dk.brics.automaton.State


        for (State s : b.getStates()) {
            Set<Transition> transitions = s.getTransitions();
            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));
                }
            }
        }
View Full Code Here


            queue = queue2;
            queue2 = tmp;
        }
       
        Automaton result = new Automaton();
        State initial = result.getInitialState();
        State accept = new State();
        accept.setAccept(true);
       
        Set<State> live = a.getLiveStates();
        for (State state : queue) {
            for (Transition t : state.getTransitions()) {
                if (live.contains(t.getDest())) {
View Full Code Here

     * @return resulting automaton
     */
    @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

        Iterator<State> ghostIt = ghost.iterator();
        ghostIt.next(); // skip the initial state in the ghost path
        int index = 1;
        while (ghostIt.hasNext()) {
          assert pathIt.hasNext();
          State pathState = pathIt.next();
          State ghostState = ghostIt.next();
         
          // add an epsilon transition, but disallow reading the next
          // character from the search string if it is followed
          epsilons.add(new ConstrainedEpsilon(ghostState, pathState, searchFor.charAt(index)));
         
          // set accept state
          if (pathState.isAccept()) {
            ghostState.setAccept(true);
          }
         
          // next char in search string
          index++;
        }
View Full Code Here

     * @param string input to the automaton.
     * @return a new list of states, or <tt>null</tt>.
     */
    private LinkedList<State> getPath(State start, CharSequence string) {
      LinkedList<State> path = new LinkedList<State>();
      State state = start;
      for (int i=0; i<string.length(); i++) {
        state = state.step(string.charAt(i));
        if (state == null)
          return null;
        path.add(state);
      }
      return path;
View Full Code Here

     * @param s a string
     * @return a new list with all the states
     */
    private LinkedList<State> makeString(CharSequence s) {
      LinkedList<State> list = new LinkedList<State>();
      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

      while (!workset.isEmpty()) {
        Iterator<StatePair> it = workset.iterator();
        StatePair pair = it.next();
        it.remove();
       
        State s1 = pair.getFirstState();
        State s2 = pair.getSecondState();
       
        for (State s3 : forward.getView(s2)) {
          // do not create degenerate epsilons
          if (s1 == s3)
            continue;
View Full Code Here

    public Automaton op(Automaton a) {
        Automaton a1 = a.clone();
        Map<State, State> map = new HashMap<State, State>();
        Set<State> a1s = a1.getStates();
        for (State s : a1s) {
            State p = new State();
            map.put(s, p);
            if (s.isAccept()) {
                p.setAccept(true);
                s.setAccept(false);
            }
        }
        for (State s : a1s) {
            State p = map.get(s);
            for (Transition t : s.getTransitions()) {
                p.addTransition(new Transition(t.getMin(), t.getMax(), map.get(t.getDest())));
            }
        }
        a1.setDeterministic(false);
        Set<StatePair> epsilons = new HashSet<StatePair>();
        for (State s : a1s) {
View Full Code Here

    public Automaton op(Automaton a) {
        Automaton b = a.clone();
        for (State s : b.getStates()) {
            Set<Transition> transitions = s.getTransitions();
            for (Transition t : new ArrayList<Transition>(transitions)) {
                State dest = t.getDest();
                transitions.add(new Transition(d, dest));
            }
        }
        b.setDeterministic(false);
        b.reduce();
View Full Code Here

    public Automaton op(Automaton a) {
        Automaton a1 = a.clone();
        Map<State, State> map = new HashMap<State, State>();
        Set<State> a1s = a1.getStates();
        for (State s : a1s) {
            State p = new State();
            map.put(s, p);
            if (s.isAccept()) {
                p.setAccept(true);
                s.setAccept(false);
            }
        }
        for (State s : a1s) {
            State p = map.get(s);
            for (Transition t : s.getTransitions()) {
                p.addTransition(new Transition(t.getMin(), t.getMax(), map.get(t.getDest())));
            }
        }
        a1.setDeterministic(false);
        Set<StatePair> epsilons = new HashSet<StatePair>();
        for (State s : a1s) {
View Full Code Here

TOP

Related Classes of dk.brics.automaton.State

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.