/** * Returns true if this dfa can accept empty string. * @return */ public boolean acceptEmpty() { return root.isAccepting(); } /**
public boolean match(String text) { DFAState<Integer> state = start; for (int ii=0;ii<text.length();ii++) { char cc = text.charAt(ii); state = state.transit(cc); if (state == null) { return false; } } return state.isAccepting(); } }
/** * Returns true if state doesn't contain any outbound transition * and is not accepting state * @return */ boolean isDeadEnd() { if (isAccepting()) { return false; } for (Transition<DFAState<T>> next : transitions.values()) { if (next.getTo() != this) { return false; } } return true; } /**
if (state != null) if (state.isAccepting())
int index = stack.size(); indexOf.put(state, index); if (state.isAccepting())
@Override protected void accepting(DFAState<T> s) throws IOException, NoSuchMethodException { if (s.isAccepting()) { tconst(s.getToken()); tstore("accepted"); tload("reader"); invokevirtual(InputReader.class, "findAccept"); } }
protected void accepting(DFAState<T> s) throws IOException, NoSuchMethodException { if (s.isAccepting()) { tconst(s.getToken()); tstore("accepted"); } else { tconst(errorToken); tstore("accepted"); } }
!to.isAccepting() && to.getTransitions().size() == 1 && to.inStates().size() == 1
/** * Marks all nfa states that can be accepting to end stop. */ public void analyzeEndStop() { DFA<T> dfa = constructDFA(new Scope<DFAState<T>>("analyzeEndStop")); for (DFAState<T> s : dfa) { if (s.isAccepting()) { if (s.isEndStop()) { for (NFAState<T> n : s.getNfaSet()) { if (n.isAccepting()) { n.setEndStop(true); } } } } } } /**
if (dfa.getRoot().isAccepting())
@Override protected void accepting(DFAState<T> s) throws IOException, NoSuchMethodException { if (s.isAccepting()) { tconst(s.getToken()); tstore("accepted"); int fixedEndLength = s.getFixedEndLength(); if (fixedEndLength != 0) { tload("reader"); iconst(fixedEndLength); invokevirtual(InputReader.class, "rewind", int.class); } } else { tconst(errorToken); tstore("accepted"); } }