Пример #1
0
        public void AOneOrMoreRepeated(string input, bool expected)
        {
            string pattern = "^a+$";
            var    target  = NFA.OneOrMany(NFA.Character('a'));

            Test(input, expected, target, pattern);
        }
Пример #2
0
        public void AnyCharSequenceRepeatedTest(string input, bool expected)
        {
            string pattern = "^A.+C$";
            var    target  = NFA.Sequence(NFA.Character('A'), NFA.OneOrMany(NFA.AnyCharacter()), NFA.Character('C'));

            Test(input, expected, target, pattern);
        }
Пример #3
0
        public void JustAB(string input, bool expected)
        {
            string pattern = "^b$";
            var    target  = NFA.Character('b');

            Test(input, expected, target, pattern);
        }
Пример #4
0
        public void JustAnAWithoutEnforcinfItBeTheEntireString(string input, bool expected)
        {
            string pattern = "^a$";
            var    target  = NFA.Character('a');

            Test(input, expected, target, pattern);
        }
Пример #5
0
        public void StartOfStringAssertionMidPatternTest(string input, bool expected)
        {
            string pattern = "^(a|^b*|c)$";
            var    target  = NFA.Alternation(NFA.Character('a'), NFA.Sequence(NFA.StartOfStringAssertion(), NFA.ZeroOrMany(NFA.Character('b'))), NFA.Character('c'));

            Test(input, expected, target, pattern);
        }
Пример #6
0
        public void StartOfStringAssertionTest(string input, bool expected)
        {
            string pattern = "^a$";
            var    target  = NFA.Sequence(NFA.StartOfStringAssertion(), NFA.Character('a'));

            Test(input, expected, target, pattern);
        }
Пример #7
0
        public void AnyCharSequenceTest(string input, bool expected)
        {
            string pattern = "^a.c$";
            var    target  = NFA.Sequence(NFA.Character('a'), NFA.AnyCharacter(), NFA.Character('c'));

            Test(input, expected, target, pattern);
        }
Пример #8
0
        public void OptionalTest(string input, bool expected)
        {
            string pattern = "^ab?$";
            var    target  = NFA.Sequence(NFA.Character('a'), NFA.ZeroOrOne(NFA.Character('b')));

            Test(input, expected, target, pattern);
        }
Пример #9
0
        public void SequenceExplicitTest(string input, bool expected)
        {
            string pattern = "^foo$";
            var    target  = NFA.Sequence(NFA.Character('f'), NFA.Character('o'), NFA.Character('o'));

            Test(input, expected, target, pattern);
        }
Пример #10
0
        public void MultiAlternationNoHelpersTest(string input, bool expected)
        {
            string pattern = "^(a|b|c)$";
            var    target  = NFA.Alternation(NFA.Character('a'), NFA.Character('b'), NFA.Character('c'));

            Test(input, expected, target, pattern);
        }
Пример #11
0
        public void AlternationAndRepetitionTest(string input, bool expected)
        {
            string pattern = "^(a|b*|c)$";

            var target = NFA.Alternation(NFA.Character('a'), NFA.Alternation(NFA.ZeroOrMany(NFA.Character('b')), NFA.Character('c')));

            Test(input, expected, target, pattern);
        }
Пример #12
0
        public void StartAndEndOfStringAssertionMidPatternTest(string input, bool expected)
        {
            string pattern = "^ab+$";
            var    target  = NFA.Sequence(
                NFA.StartOfStringAssertion(),
                NFA.Character('a'),
                NFA.OneOrMany(
                    NFA.Character('b')
                    ),
                NFA.EndOfStringAssertion()
                );

            Test(input, expected, target, pattern);
        }
 public void Visit(Primitive target)
 {
     stack.Push(NFA.Character(target.character));
 }