public Fsm <TChar> Or(Fsm <TChar> other) { Fsm <TChar> self = Clone(); other = other.Clone(); FsmState initial = FsmState.Create(); FsmState final = FsmState.Create(); initial.EpsTransitions.Add(self.initial); initial.EpsTransitions.Add(other.initial); self.final.EpsTransitions.Add(final); other.final.EpsTransitions.Add(final); return(new Fsm <TChar>(initial, final)); }
public static Fsm <TChar> Sequence(IEnumerable <TChar> sequence) { FsmState initial = FsmState.Create(); FsmState final = FsmState.Create(); FsmState current = initial; foreach (TChar c in sequence) { var next = FsmState.Create(); current.Transitions.Add(new Transition(c, next)); current = next; } current.EpsTransitions.Add(final); return(new Fsm <TChar>(initial, final)); }