public NfaClosure(IEnumerable <NfaState> states, NfaState end) { var set = new HashSet <NfaState>(); var isFinal = false; foreach (var state in states) { foreach (var closureState in state.Closure()) { if (closureState.Equals(end)) { isFinal = true; } set.Add(closureState); } } Set = set; State = DfaState.Make(isFinal); this.hashCode = Set.AddedHash(); }
public NfaClosure(NfaState state, NfaState end) : this(Enumerable.Repeat(state, 1), end) { }
public void Add(Atom terminal, NfaState target) { Add(new NfaTransition(terminal, target)); }
public Nfa(NfaState start, NfaState end) { Start = start ?? throw new ArgumentNullException(nameof(start)); End = end ?? throw new ArgumentNullException(nameof(end)); }
public void Add(NfaState target) { Add(new NfaTransition(Atom.From(IntegerSet.Empty), target)); }