// If nfa1 has form s1s ----> s1e // and nfa2 has form s2s ----> s2e // then nfa0 has form s0s -eps-> s1s ----> s1e -eps-> s0e // s0s -eps-> s2s ----> s2e -eps-> s0e public override Nfa MkNfa(Nfa.NameSource names) { var nfa1 = _r1.MkNfa(names); var nfa2 = _r2.MkNfa(names); var s0s = names.Next(); var s0e = names.Next(); var nfa0 = new Nfa(s0s, s0e); foreach (var entry in nfa1.Trans) { nfa0.AddTrans(entry); } foreach (var entry in nfa2.Trans) { nfa0.AddTrans(entry); } nfa0.AddTrans(s0s, null, nfa1.Start); nfa0.AddTrans(s0s, null, nfa2.Start); nfa0.AddTrans(nfa1.Exit, null, s0e); nfa0.AddTrans(nfa2.Exit, null, s0e); return(nfa0); }
// The resulting nfa0 has form s0s -sym-> s0e public override Nfa MkNfa(Nfa.NameSource names) { var s0s = names.Next(); var s0e = names.Next(); var nfa0 = new Nfa(s0s, s0e); nfa0.AddTrans(s0s, _sym, s0e); return(nfa0); }