Exemple #1
0
        public void ParseInvalidUnexpectedCharacterString()
        {
            NonTerminal S, T, F;
            LR0 parser = new LR0(ConstructTestGrammar(out S, out T, out F));

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

            var tree = parser.Parse("((x)*t)*");
        }
Exemple #3
0
        public void ParseMatchedBrackets()
        {
            var lr0 = new LR0(new MatchedBrackets("(", ")"));

            //This is failing because some part of the LR0 parser is not liking having to match an empty string midway through the parse
            //This should parse as "(" + "" + ")"
            lr0.Parse("()");
        }
Exemple #4
0
        public void ParseValidString()
        {
            NonTerminal S, T, F;
            LR0 parser = new LR0(ConstructTestGrammar(out S, out T, out F));

            ParseTree tree = parser.Parse("((x) * y) * 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);
        }
Exemple #5
0
        public void ParseMathExpression()
        {
            var lr0 = new LR0(new MathExpression());

            lr0.Parse("1 * 2");
        }
Exemple #6
0
        public void ParseMatchedBracketsWithContent()
        {
            var lr0 = new LR0(new MatchedBracketsWithContent("(", ")"));

            lr0.Parse("(a)");
        }