Esempio n. 1
0
        public void TestAlternateChoiceErrorMixedTerminalAndNonTerminal()
        {
            var startingRule   = $"choice";
            var parserInstance = new AlternateChoiceTestError();
            var builder        = new ParserBuilder <OptionTestToken, string>();
            var builtParser    = builder.BuildParser(parserInstance, ParserType.EBNF_LL_RECURSIVE_DESCENT, startingRule);

            Assert.True(builtParser.IsError);
            Assert.Equal(2, builtParser.Errors.Count);
            Assert.Contains("mixed", builtParser.Errors[0].Message);
            Assert.Contains("discarded", builtParser.Errors[1].Message);
        }
Esempio n. 2
0
        public void TestAlternateChoiceErrorMixedTerminalAndNonTerminal()
        {
            var startingRule   = $"choice";
            var parserInstance = new AlternateChoiceTestError();
            var builder        = new ParserBuilder <OptionTestToken, string>();
            var builtParser    = builder.BuildParser(parserInstance, ParserType.EBNF_LL_RECURSIVE_DESCENT, startingRule);

            Assert.True(builtParser.IsError);
            Assert.Equal(2, builtParser.Errors.Count);
            Assert.Equal(ErrorCodes.PARSER_MIXED_CHOICES, builtParser.Errors[0].Code);
            Assert.Equal(ErrorCodes.PARSER_NON_TERMINAL_CHOICE_CANNOT_BE_DISCARDED, builtParser.Errors[1].Code);
        }