a1.addTransition(0, 0, '0'); for (int p : initials) { a1.addEpsilon(0, p);
/** * Returns an automaton that accepts the union of the empty string and the * language of the given automaton. This may create a dead state. * <p> * Complexity: linear in number of states. */ static public Automaton optional(Automaton a) { Automaton result = new Automaton(); result.createState(); result.setAccept(0, true); if (a.getNumStates() > 0) { result.copy(a); result.addEpsilon(0, 1); } result.finishState(); return result; }
/** * Returns an automaton that accepts the union of the languages of the given * automata. * <p> * Complexity: linear in number of states. */ public static Automaton union(Collection<Automaton> l) { Automaton result = new Automaton(); // Create initial state: result.createState(); // Copy over all automata for(Automaton a : l) { result.copy(a); } // Add epsilon transition from new initial state int stateOffset = 1; for(Automaton a : l) { if (a.getNumStates() == 0) { continue; } result.addEpsilon(0, stateOffset); stateOffset += a.getNumStates(); } result.finishState(); return removeDeadStates(result); }
BitSet acceptStates = a.getAcceptStates(); while (s < numStates && (s = acceptStates.nextSetBit(s)) != -1) { result.addEpsilon(0, s+1); if (initialStates != null) { initialStates.add(s+1);
result.addEpsilon(state, t.dest); result.addEpsilon(state, t.dest); } else { result.addTransition(state, t.dest, t.min, t.max);
result.addEpsilon(state, t.dest); result.addEpsilon(state, t.dest); } else { result.addTransition(state, t.dest, t.min, t.max);
a1.addTransition(0, 0, '0'); for (int p : initials) { a1.addEpsilon(0, p);
/** * Returns an automaton that accepts the union of the empty string and the * language of the given automaton. This may create a dead state. * <p> * Complexity: linear in number of states. */ static public Automaton optional(Automaton a) { Automaton result = new Automaton(); result.createState(); result.setAccept(0, true); if (a.getNumStates() > 0) { result.copy(a); result.addEpsilon(0, 1); } result.finishState(); return result; }
/** * Returns an automaton that accepts the union of the empty string and the * language of the given automaton. This may create a dead state. * <p> * Complexity: linear in number of states. */ static public Automaton optional(Automaton a) { Automaton result = new Automaton(); result.createState(); result.setAccept(0, true); if (a.getNumStates() > 0) { result.copy(a); result.addEpsilon(0, 1); } result.finishState(); return result; }
/** * Returns an automaton that accepts the union of the empty string and the * language of the given automaton. This may create a dead state. * <p> * Complexity: linear in number of states. */ static public Automaton optional(Automaton a) { Automaton result = new Automaton(); result.createState(); result.setAccept(0, true); if (a.getNumStates() > 0) { result.copy(a); result.addEpsilon(0, 1); } result.finishState(); return result; }
/** * Returns an automaton that accepts the union of the languages of the given * automata. * <p> * Complexity: linear in number of states. */ public static Automaton union(Collection<Automaton> l) { Automaton result = new Automaton(); // Create initial state: result.createState(); // Copy over all automata for(Automaton a : l) { result.copy(a); } // Add epsilon transition from new initial state int stateOffset = 1; for(Automaton a : l) { if (a.getNumStates() == 0) { continue; } result.addEpsilon(0, stateOffset); stateOffset += a.getNumStates(); } result.finishState(); return removeDeadStates(result); }
result.addEpsilon(state, t.dest); result.addEpsilon(state, t.dest); } else { result.addTransition(state, t.dest, t.min, t.max);
/** * Returns an automaton that accepts the union of the languages of the given * automata. * <p> * Complexity: linear in number of states. */ public static Automaton union(Collection<Automaton> l) { Automaton result = new Automaton(); // Create initial state: result.createState(); // Copy over all automata for(Automaton a : l) { result.copy(a); } // Add epsilon transition from new initial state int stateOffset = 1; for(Automaton a : l) { if (a.getNumStates() == 0) { continue; } result.addEpsilon(0, stateOffset); stateOffset += a.getNumStates(); } result.finishState(); return removeDeadStates(result); }
/** * Returns an automaton that accepts the union of the languages of the given * automata. * <p> * Complexity: linear in number of states. */ public static Automaton union(Collection<Automaton> l) { Automaton result = new Automaton(); // Create initial state: result.createState(); // Copy over all automata for(Automaton a : l) { result.copy(a); } // Add epsilon transition from new initial state int stateOffset = 1; for(Automaton a : l) { if (a.getNumStates() == 0) { continue; } result.addEpsilon(0, stateOffset); stateOffset += a.getNumStates(); } result.finishState(); return removeDeadStates(result); }
result.addEpsilon(state, t.dest); result.addEpsilon(state, t.dest); } else { result.addTransition(state, t.dest, t.min, t.max);
result.addEpsilon(state, t.dest); result.addEpsilon(state, t.dest); } else { result.addTransition(state, t.dest, t.min, t.max);
result.addEpsilon(state, t.dest); result.addEpsilon(state, t.dest); } else { result.addTransition(state, t.dest, t.min, t.max);
BitSet acceptStates = a.getAcceptStates(); while (s < numStates && (s = acceptStates.nextSetBit(s)) != -1) { result.addEpsilon(0, s+1); if (initialStates != null) { initialStates.add(s+1);
BitSet acceptStates = a.getAcceptStates(); while (s < numStates && (s = acceptStates.nextSetBit(s)) != -1) { result.addEpsilon(0, s+1); if (initialStates != null) { initialStates.add(s+1);
BitSet acceptStates = a.getAcceptStates(); while (s < numStates && (s = acceptStates.nextSetBit(s)) != -1) { result.addEpsilon(0, s+1); if (initialStates != null) { initialStates.add(s+1);