예제 #1
0
 public void a_scanner_and_some_terminals()
 {
     scanner = new ScanStrings(Input) { SkipWhitespace = true };
     __this__ = new LiteralString("this");
     __is__ = new LiteralString("is");
     __wally__ = new LiteralString("wally");
     __dr_jones__ = new LiteralString("Dr. Jones!");
 }
예제 #2
0
        public void input_that_repeats_less_than_parsers_lower_bound_fails()
        {
            var term = new LiteralString("op!");
            var scanner = new ScanStrings("op!op!");
            IParser subject = new Repetition(term, 4, 5);

            var result = subject.Parse(scanner);

            Assert.That(result.Success, Is.False);
        }
예제 #3
0
        public void input_that_repeats_more_than_parsers_upper_bound_passes_and_captures_only_expected_max_range()
        {
            var term = new LiteralString("op!");
            var scanner = new ScanStrings("op!op!op!op!op!op!op!op!");
            IParser subject = new Repetition(term, 3, 3);

            var result = subject.Parse(scanner);

            Assert.That(result.Success, Is.True);
            Assert.That(result.Value, Is.EqualTo("op!op!op!"));
        }
예제 #4
0
        public void input_that_repeats_exactly_as_many_as_the_upper_bound_passes_and_captures_all_input()
        {
            var term = new LiteralString("op!");
            var scanner = new ScanStrings("op!op!op!");
            IParser subject = new Repetition(term, 1, 3);

            var result = subject.Parse(scanner);

            Assert.That(result.Success, Is.True);
            Assert.That(result.Value, Is.EqualTo("op!op!op!"));
        }