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(); }
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(); }
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(); }
public Parser(Lexer lex) { Lex=lex; ConsumeToken(); }