/** * Adds a set of transitions * @param rs * @param to */ public void addTransition(RangeSet rs, NFAState<T> to) { for (Range c : rs) { addTransition(c, to); } edges.add(to); to.inStates.add(this); } /**
/** * Constructs a nfa containing two states which have transitions from first * to last * <p> * first -rs> last * @param scope * @param rs Range set containing the transition ranges. */ public NFA(Scope<NFAState<T>> scope, RangeSet rs) { this.scope = scope; first = new NFAState<>(scope); last = new NFAState<>(scope); first.addTransition(rs, last); } /**
/** * Construct a new nfa state by cloning other state as well as all connected * states. * @param other * @param map */ NFAState(Scope<NFAState<T>> scope, NFAState<T> other, Map<NFAState<T>,NFAState<T>> map) { super(scope, other); map.put(other, this); for (Range r : other.transitions.keySet()) { Set<Transition<NFAState<T>>> s = other.transitions.get(r); for (Transition<NFAState<T>> t : s) { NFAState<T> to = map.get(t.getTo()); if (to == null) { to = new NFAState<>(scope, t.getTo(), map); } addTransition(r, to); } } } public boolean isAcceptImmediately()
RangeSet rs3 = s.getNonEpsilonConditions(); rs2.remove(rs3); s.addTransition(rs2, current); current.addTransition(rs, prev); end.setFixedEndLength(list.size());