Esempio n. 1
0
        internal static Automaton MakeCharSet(string set)
        {
            if (set.Length == 1)
            {
                return(MakeChar(set[0]));
            }

            var a  = new Automaton();
            var s1 = new State();
            var s2 = new State();

            a.Initial = s1;
            s2.Accept = true;

            foreach (char t in set)
            {
                s1.Transitions.Add(new Transition(t, s2));
            }

            a.IsDeterministic = true;
            a.Reduce();

            return(a);
        }
Esempio n. 2
0
        internal static Automaton MakeCharSet(string set)
        {
            if (set.Length == 1)
            {
                return MakeChar(set[0]);
            }

            var a = new Automaton();
            var s1 = new State();
            var s2 = new State();

            a.Initial = s1;
            s2.Accept = true;

            foreach (char t in set)
            {
                s1.Transitions.Add(new Transition(t, s2));
            }

            a.IsDeterministic = true;
            a.Reduce();

            return a;
        }