/** * Constructs a new automaton whose language is the concatenation of the language of this automaton * and the language of the given automaton. [Martin, Th. 3.25] * The input automata are unmodified. * @exception IllegalArgumentException if the alphabets of f and this automaton are not the same */ public NFA concat(NFA f) throws IllegalArgumentException { if (!alphabet.equals(f.alphabet)) throw new IllegalArgumentException("alphabets are different"); NFA f1 = (NFA) this.clone(); NFA f2 = (NFA) f.clone(); NFA n = new NFA(); n.alphabet = alphabet; n.states.addAll(f1.states); n.states.addAll(f2.states); n.accept.addAll(f2.accept); n.initial = f1.initial; n.transitions.putAll(f1.transitions); n.transitions.putAll(f2.transitions); for (State s : f1.accept) n.addLambda(s, f2.initial); return n; }