예제 #1
0
        public void StartWith_GrammarWithUnresovedRules_ThrowsException()
        {
            var grammar = new AdHocGrammar();

            grammar.Sequence("start", grammar.Ref("item"));

            grammar.Invoking(g => g.StartWith("start")).Should().Throw <GrammarException>().Where(e => e.Id == GrammarExceptionId.GrammarContainsUnresolvedRule);
        }
예제 #2
0
        public void Grammar_WithoutStartRule_ThrowsExceptionOnStart()
        {
            var grammar = new AdHocGrammar();

            grammar.TerminalType("A", "start");

            grammar.Invoking(g => g.Start()).Should().Throw <GrammarException>().Where(e => e.Id == GrammarExceptionId.StartRuleNotDefined);
        }