/** * @param args the command line arguments */ public static void main(String[] args) { try { DFA<Integer> dfa = Regex.createDFA("qwertyuio|asdfghjkl|zxcvbnm|[qwe]+"); DFADistributor<Integer> distributor = new DFADistributor<>(dfa, 10); distributor.distribute(); } catch (Exception ex) { ex.printStackTrace(); } } }
@Override protected void branch(DFAState<T> x) { addCandidate(x); }
incomingSet.clear(); closure.clear(); reset(); traverse(s); Collections.sort(candidateList, comp); if (!candidateList.isEmpty()) DFADistributor<T> dfaDistributor = new DFADistributor<>(ddfa, maxStates); dfaDistributor.distribute(); distributedDFAs.addAll(dfaDistributor.distributedDFAs);
@Override public void implement() throws IOException { if (!Typ.isSameType(tokenType, getReturnType())) { throw new IllegalArgumentException(tokenType+" is not expected return type "+getReturnType()+" of method"); } if (dfa.initialSize() > MAXSTATES) { SubClass subClass = getSubClass(); DFADistributor<T> dd = new DFADistributor<>(dfa, MAXSTATES); dd.distribute(); for (DFA<T> ddfa : dd.getDistributedDFAs()) { String subName = jav.makeJavaIdentifier(getMethodDescription()+ddfa.name()); ExecutableElement distributedMethod = getDistributedMethod(subName); DFACompiler<T> sc = copy(ddfa); sc.setSubCompiler(true); subClass.defineMethod(sc, distributedMethod); } } try { compile(); } catch (NoSuchMethodException ex) { throw new IOException(ex); } }
public void distribute() { distribute(dfa.getRoot(), dfa.initialSize()); } private void distribute(DFAState<T> state, int rootCount)
@Override protected void exit(DFAState<T> x, int count) { Candidate c = getCandidate(x); if (c != null) { VisitSet<DFAState<T>> complement = incomingSet.complement(closure); if (complement.size() == 1) { c.setCount(count); } } }