private static Nfa Optional(Nfa nfa) { var start = new NfaState(); var end = new NfaState(); start.AddEpsilon(nfa.Start); start.AddEpsilon(end); nfa.End.AddEpsilon(end); return(new Nfa(start, end)); }
public Nfa Union(Nfa other) { var newStart = new NfaState(); var newEnd = new NfaState(); newStart.AddEpsilon(Start); newStart.AddEpsilon(other.Start); End.AddEpsilon(newEnd); other.End.AddEpsilon(newEnd); return(new Nfa(newStart, newEnd)); }
public Nfa Kleene() { var newStart = new NfaState(); var newEnd = new NfaState(); newStart.AddEpsilon(Start); newStart.AddEpsilon(newEnd); newEnd.AddEpsilon(Start); End.AddEpsilon(newEnd); return(new Nfa(newStart, newEnd)); }
private static Nfa Union(Nfa first, Nfa second) { var start = new NfaState(); var end = new NfaState(); start.AddEpsilon(first.Start); start.AddEpsilon(second.Start); first.End.AddEpsilon(end); second.End.AddEpsilon(end); return(new Nfa(start, end)); }
private static Nfa Empty() { var start = new NfaState(); var end = new NfaState(); start.AddEpsilon(end); return(new Nfa(start, end)); }