Exemple #1
0
        public void SimpleExpression1_VB_Test()
        {
            GrammarTree GT = LoadGrammar(TESTFILESPATH + @"simple expression1_vb.tpg");
            Grammar G = (Grammar)GT.Eval();
            G.Directives["TinyPG"]["TemplatePath"] = TEMPLATEPATH_VB;

            Compiler.Compiler compiler = new Compiler.Compiler();

            compiler.Compile(G);
            Assert.IsTrue(compiler.Errors.Count == 0, "compilation contains errors");

            CompilerResult result = compiler.Run("5+7/3*2+(4*2)");

            Assert.IsTrue(result.Output.StartsWith("Parse was successful."));
        }
Exemple #2
0
        public void SimpleExpression4_VB_Test()
        {
            GrammarTree GT = LoadGrammar(TESTFILESPATH + @"GrammarHighlighter_vb.tpg");
            Grammar G = (Grammar)GT.Eval();
            G.Directives.Add(new Directive("TinyPG"));
            G.Directives["TinyPG"]["TemplatePath"] = TEMPLATEPATH_VB;

            Compiler.Compiler compiler = new Compiler.Compiler();

            compiler.Compile(G);
            Assert.IsTrue(compiler.Errors.Count == 0, "compilation contains errors");

            CompilerResult result = compiler.Run("using System.IO;\r\n");

            Assert.IsTrue(result.Output.StartsWith("Parse was successful."));
        }
Exemple #3
0
        public void SimpleExpression1_Test()
        {
            GrammarTree GT = LoadGrammar(TESTFILESPATH + @"simple expression1.tpg");
            Grammar G = (Grammar) GT.Eval();

            G.Directives["TinyPG"]["TemplatePath"] = TEMPLATEPATH;
            G.Directives["TinyPG"]["OutputPath"] = OUTPUTPATH;

            // basic checks
            string temp = G.PrintFirsts();
            Assert.IsTrue(!String.IsNullOrEmpty(temp));
            temp = G.GetOutputPath();
            Assert.IsTrue(!String.IsNullOrEmpty(temp));
            temp = G.PrintGrammar();
            Assert.IsTrue(!String.IsNullOrEmpty(temp));

            Compiler.Compiler compiler = new Compiler.Compiler();

            compiler.Compile(G);

            Assert.IsTrue(compiler.Errors.Count == 0, "compilation contains errors");

            CompilerResult result = compiler.Run("5+7/3*2+(4*2)");

            Assert.IsTrue(result.Output.StartsWith("Parse was successful."));
        }
Exemple #4
0
        public void SimpleExpression2_VB_Test()
        {
            GrammarTree GT = LoadGrammar(TESTFILESPATH + @"simple expression2_vb.tpg");
            Grammar G = (Grammar)GT.Eval();
            G.Directives.Add(new Directive("TinyPG"));
            G.Directives["TinyPG"]["TemplatePath"] = TEMPLATEPATH_VB;

            Compiler.Compiler compiler = new Compiler.Compiler();

            compiler.Compile(G);
            Assert.IsTrue(compiler.Errors.Count == 0, "compilation contains errors");

            CompilerResult result = compiler.Run("5+8/4*2+(4*2)");

            Assert.IsTrue(Convert.ToInt32(result.Value) == 17);
        }