Exemplo n.º 1
0
        protected override HashSet <NFA.State> GetNextState(HashSet <NFA.State> state, char input)
        {
            HashSet <NFA.State> nextState = new HashSet <NFA.State>();

            nextState.UnionWith(nfa.Closure(
                                    nfa.Transitions.Where(t => t.ValidInput.ContainsChar(input) && state.Contains(t.From)).Select(f => f.To).
                                    ToArray()));
            return(nextState);
        }
Exemplo n.º 2
0
        public void TestClosure()
        {
            NFA nfa = NFACreate("(a|b)*cd");
            IList <NFA.State> s0Closure = nfa.Closure(new[] { nfa.StartState }).ToList();

            // In this sample 6 stats are reachable
            Assert.AreEqual(6, s0Closure.Count());

            // The same state is never in the closure twice. This checks that
            Assert.AreEqual(6, s0Closure.Select(f => f.StateNumber).Distinct().Count());
        }