Пример #1
0
        private static Nfa Any()
        {
            var start = new NfaState();
            var end   = new NfaState();

            start.AddTransition(AnyTerminal.Instance, end);
            return(new Nfa(start, end));
        }
Пример #2
0
        private static Nfa Character(RegexCharacterClassCharacter character, bool negate)
        {
            var start    = new NfaState();
            var end      = new NfaState();
            var terminal = CreateTerminalForCharacter(character.Value, character.IsEscaped, negate);

            start.AddTransition(terminal, end);

            return(new Nfa(start, end));
        }
Пример #3
0
        private static Nfa Range(RegexCharactersRange range, bool negate)
        {
            // combine characters into a character range terminal
            var          start         = range.StartCharacter.Value;
            var          end           = range.EndCharacter.Value;
            AtomTerminal terminal      = new RangeTerminal(start, end);
            var          nfaStartState = new NfaState();
            var          nfaEndState   = new NfaState();

            if (negate)
            {
                terminal = new NegationTerminal(terminal);
            }

            nfaStartState.AddTransition(terminal, nfaEndState);
            return(new Nfa(nfaStartState, nfaEndState));
        }