示例#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));
        }