예제 #1
0
        private static Nfa Optional(Nfa nfa)
        {
            var start = new NfaState();
            var end   = new NfaState();

            start.AddEpsilon(nfa.Start);
            start.AddEpsilon(end);
            nfa.End.AddEpsilon(end);
            return(new Nfa(start, end));
        }
예제 #2
0
        public Nfa Union(Nfa other)
        {
            var newStart = new NfaState();
            var newEnd   = new NfaState();

            newStart.AddEpsilon(Start);
            newStart.AddEpsilon(other.Start);

            End.AddEpsilon(newEnd);
            other.End.AddEpsilon(newEnd);

            return(new Nfa(newStart, newEnd));
        }
예제 #3
0
        public Nfa Kleene()
        {
            var newStart = new NfaState();
            var newEnd   = new NfaState();

            newStart.AddEpsilon(Start);
            newStart.AddEpsilon(newEnd);

            newEnd.AddEpsilon(Start);
            End.AddEpsilon(newEnd);

            return(new Nfa(newStart, newEnd));
        }
예제 #4
0
        private static Nfa Union(Nfa first, Nfa second)
        {
            var start = new NfaState();
            var end   = new NfaState();

            start.AddEpsilon(first.Start);
            start.AddEpsilon(second.Start);

            first.End.AddEpsilon(end);
            second.End.AddEpsilon(end);

            return(new Nfa(start, end));
        }
예제 #5
0
        private static Nfa Empty()
        {
            var start = new NfaState();
            var end   = new NfaState();

            start.AddEpsilon(end);
            return(new Nfa(start, end));
        }