Пример #1
0
 static void Main(string[] args)
 {
     Lexer lex=new Lexer(@"100Holis 100hi=(3+10-5*2)/2;
     print MiNumero+10;");
     Token currentToken = lex.GetToken();
     while (currentToken.Type != TokenType.EOF)
     {
         Console.WriteLine(currentToken);
         currentToken = lex.GetToken();
     }
     Console.WriteLine(currentToken);
     Console.ReadKey();
 }
Пример #2
0
        static void Main(string[] args)
        {
            Lexer lex=new Lexer(@"int a,b,c;
            float d;
            string a2;
            array[10,10] of int arreglo;
            bool e;
            string j;

            for a=3 to 5
            print a;
            end");
            /*Token currentToken = lex.GetToken();
            while (currentToken.Type != TokenType.EOF)
            {
                Console.WriteLine(currentToken);
                currentToken = lex.GetToken();
            }
            Console.WriteLine(currentToken);*/
            Parser parser = new Parser(lex);
            string XML = "";
            var par =parser.Parse();

            var table = SymbolTable.Instance;
            Console.WriteLine("Works!");
            foreach (var statementNode in par)
            {
                statementNode.ValidateSemantic();

            }
            foreach (var statementNode in par)
            {
                statementNode.Interpret();

            }
            Console.WriteLine(XML);
            Console.ReadKey();
        }
Пример #3
0
 static void Main(string[] args)
 {
     Lexer lex=new Lexer(@"int a,b,c;
     float d;
     bool e;
     for  while end to  if then else  array[10]  do");
     Token currentToken = lex.GetToken();
     while (currentToken.Type != TokenType.EOF)
     {
         Console.WriteLine(currentToken);
         currentToken = lex.GetToken();
     }
     Console.WriteLine(currentToken);
     /*Parser parser = new Parser(lex);
     string XML = "";
     var par=parser.Parse();
     foreach (var statementNode in par)
     {
         statementNode.Interpretar();
         XML += statementNode.ToXML()+"\n";
     }
     Console.WriteLine(XML);*/
     Console.ReadKey();
 }
Пример #4
0
 public Parser(Lexer lex)
 {
     Lex=lex;
     ConsumeToken();
 }