Пример #1
0
        static void Main(string[] args)
        {
            //String text = "2*(2+4)";
            String text = "/*my program*/" + "\n" +
                          "var mystring = \"some text\";" +
                          "var i = 1234;" +
                          "i  = 0;" +
                          "while(i < 5) { print(i); i = i + 1; }";
            //String text = "(2*(4+5)-(2*(2+1)))*2";
            LexycalAnalyzer la = new LexycalAnalyzer();
            SyntaxAnalyzer sa = new SyntaxAnalyzer();

            List<Token> result = la.Parse(text);
            //Console.WriteLine(sa.ParseExpressionDev(result).GetValue());
            Console.WriteLine();
            //Console.WriteLine(new SyntaxAnalyzer().FindClosingBracket(result, 24));
            la.WriteTokens(result);
            foreach (Token t in result)
            {
                Console.Write(t.data);
            }

            Command commands = new SyntaxAnalyzer().Analyze(result);
            while (commands.nextCommand != null)
            {
                commands.execute();
                commands = commands.nextCommand;
            }

            Console.Read();
        }