private static INfa Union(INfa first, INfa second) { var start = new NfaState(); start.AddTransistion(new NullNfaTransition(first.Start)); start.AddTransistion(new NullNfaTransition(second.Start)); var end = new NfaState(); var endTransition = new NullNfaTransition(end); first.End.AddTransistion(endTransition); second.End.AddTransistion(endTransition); return new Nfa(start, end); }
private static INfa KleeneStar(INfa nfa) { var start = new NfaState(); var nullToNfaStart = new NullNfaTransition(nfa.Start); start.AddTransistion(nullToNfaStart); nfa.End.AddTransistion(nullToNfaStart); var end = new NfaState(); var nullToNewEnd = new NullNfaTransition(end); start.AddTransistion(nullToNewEnd); nfa.End.AddTransistion(nullToNewEnd); return new Nfa(start, end); }