예제 #1
0
        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();
        }
예제 #2
0
 public NfaClosure(NfaState state, NfaState end)
     : this(Enumerable.Repeat(state, 1), end)
 {
 }
예제 #3
0
 public void Add(Atom terminal, NfaState target)
 {
     Add(new NfaTransition(terminal, target));
 }
예제 #4
0
 public Nfa(NfaState start, NfaState end)
 {
     Start = start ?? throw new ArgumentNullException(nameof(start));
     End   = end ?? throw new ArgumentNullException(nameof(end));
 }
예제 #5
0
 public void Add(NfaState target)
 {
     Add(new NfaTransition(Atom.From(IntegerSet.Empty), target));
 }