예제 #1
0
        public void ParseInvalidUnexpectedCharacterString()
        {
            NonTerminal S, T, F;
            LR0 parser = new SLR1(LR0Test.ConstructTestGrammar(out S, out T, out F));

            parser.Parse("((x)*t)**");
        }
예제 #2
0
        public void ParseInvalidEarlyTerminatingString()
        {
            NonTerminal S, T, F;
            LR0 parser = new SLR1(LR0Test.ConstructTestGrammar(out S, out T, out F));

            parser.Parse("((x)*t)*");
        }
예제 #3
0
        public void ParseValidString()
        {
            NonTerminal S, T, F;
            LRParserBase parser = new SLR1(LR0Test.ConstructTestGrammar(out S, out T, out F));

            ParseTree tree = parser.Parse("((x) * t) * foo");

            Assert.IsNotNull(tree);

            Assert.IsNotNull(tree.Root);
            Assert.AreEqual(3, tree.Root.Children.Count);

            Assert.IsNotNull(tree.Root.Children[0].NonTerminal);
            Assert.AreEqual("*", tree.Root.Children[1].Token.Value);
            Assert.IsNotNull(tree.Root.Children[2].NonTerminal);

            Assert.AreEqual("foo", tree.Root.Children[2].Children[0].Token.Value);
        }
예제 #4
0
        public void SLR1InvalidGrammar()
        {
            LRParserBase parser = new SLR1(new CPointerHandling());

            parser.Parse("x = y");
        }