Example #1
0
        public void TestLeftRecursionNonLR()
        {
            var parser = new LRParser(false);
            var match  = parser.GetMatch("ab", parser.NonLR);

            Assert.IsTrue(match.Success);

            match = parser.GetMatch("ac", parser.NonLR);
            Assert.IsTrue(match.Success);

            match = parser.GetMatch("ad", parser.NonLR);
            Assert.IsFalse(match.Success);
        }
Example #2
0
        public void TestLeftRecursionHexEscape()
        {
            var parser = new LRParser();
            var match  = parser.GetMatch("#\\x000", parser.HexEscapeCharacter);

            Assert.IsTrue(match.Success);
        }
Example #3
0
        public void TestLeftRecursionLR2()
        {
            var parser = new LRParser();
            var match  = parser.GetMatch("ababbba", parser.AAA);

            Assert.IsTrue(match.Success);
            var res = match.Result;
        }
Example #4
0
        public void TestLeftRecursionAssociation()
        {
            var parser = new LRParser();
            var match  = parser.GetMatch("1+1+1+1", parser.Exp);

            Assert.IsTrue(match.Success);
            Assert.AreEqual("(((1 + 1) + 1) + 1)", match.Result);
        }