Example #1
0
        static void TestLatex()
        {
            string j = "";
            j += @"\documentclass{article}\begin{document}";

            foreach (string k in test)
            {
                string i = k.Split('|')[0];
                Lexer l = new Lexer(i);
                Parser p = new Parser(l);
                if(p.Result != null)
                {
                    j += i + " == $";
                    j += p.Result.ToLatex();
                    j+= "$";
                    try
                    {
                        j += " = " + p.Result.Evaluate().ToString();
                    }
                    catch { }
                    j += "\r\n\r\n";
                }
            }

            j += @"\end{document}";
            Console.WriteLine(j);
        }
Example #2
0
 static void Normal()
 {
     string s = ".abu pi'ibo vei xy. te'a re ve'o su'i by. pi'ibo xy. su'i cy.";
     Lexer l = new Lexer(s);
     try
     {
         Parser p = new Parser(l);
         if (p.Result != null)
         {
             Console.WriteLine(l.ToString() + " =>");
             Console.WriteLine(p.Result.Verbose());
             try
             {
                 Console.WriteLine("Answer: " + p.Result.Evaluate());
             }
             catch { }
         }
     }
     catch (ParseError pe)
     {
         Console.WriteLine(pe.Message + " : " + pe.token.Value);
     }
 }
Example #3
0
        static void TimeTest()
        {
            string[] t = new string[3];
            t[0] = "vei va'a by. ku'e su'i fe'a vei by. te'abo re vu'u vo pi'ibo .abu pi'ibo cy. ve'o ve'o fe'i re pi'ibo .abu";
            t[1] = "+ + + + + + + + 1";
            t[2] = "1 2 3 + 4 5 6 - 7 8 9 *";

            for(int i = 0; i < 1000; i++)
                foreach (string s in t)
                {
                    Lexer l = new Lexer(s);
                    Parser p = new Parser(l);
                    if (p.Result != null)
                    {
                        Console.WriteLine("Current Token: " + l.Current.Value);
                        Console.WriteLine("Length of production: " + p.Result.Length.ToString());
                        Console.WriteLine(p.Result.Verbose());
                        try
                        {
                            Console.WriteLine("Answer: " + p.Result.Evaluate());
                        }
                        catch { }
                    }
                }
        }