コード例 #1
0
        public void CompileTestReturnStateTest()
        {
            parser = new LrParser(grammarLoader.Words, grammarLoader.Rules, ruleTable, grammarLoader.CountOfRules);

            string textToParse = "= k 12 if := num 10 = 3 3 if := id 6";

            Queue <Word> actualWords = textParser.Parse(textToParse);

            Assert.True(parser.TryCompile(actualWords));
        }
コード例 #2
0
        public void CompileTest1()
        {
            parser = new LrParser(grammarLoader.Words, grammarLoader.Rules, ruleTable, grammarLoader.CountOfRules);

            string textToParse = "= 13 12 if := num 10 = 3 3 if := id 6";

            Queue <Word> actualWords = textParser.Parse(textToParse);

            if (parser.TryCompile(actualWords))
            {
                string expectedString = String.Format(
                    "{0}{1}{2}", "if ( 13 == 12 ) { num = 10; }",
                    Environment.NewLine, "if ( 3 == 3 ) { id = 6; }");

                Assert.AreEqual(expectedString, parser.CompiledText);
            }
            else
            {
                Assert.Fail();
            }
        }