public static FA Plus(FA fa) { var clone = fa.ToNfa(true); Debug.Assert(clone.Final != null); clone.Final.Add(clone.Start); return(clone); }
public static FA Concat(FA fa, FA other) { var first = fa.ToNfa(true); Debug.Assert(first.Final != null); other = other.ToNfa(true); Debug.Assert(other.Final != null); first.Final.Add(other.Start); return(FA.From(first.Start, other.Final)); }
public static FA Or(FA fa, FA other) { var first = fa.ToNfa(true); Debug.Assert(first.Final != null); var second = other.ToNfa(true); Debug.Assert(second.Final != null); var newEnd = new State(); first.Start.Add(second.Start); first.Final.Add(newEnd); second.Final.Add(newEnd); return(FA.From(first.Start, newEnd)); }