public static void Main(string[]args) { tiger_grammarLexer lex = new tiger_grammarLexer(new ANTLRFileStream("codigos de prueba/8.txt")); CommonTokenStream tokens = new CommonTokenStream(lex); tiger_grammarParser parser= new tiger_grammarParser(tokens); try { parser.language(); Console.WriteLine("press any key ..."); Console.ReadLine(); } catch(RecognitionException e) { Console.Error.WriteLine("mal sintaxis"); } }
public List<Error> Compile(string inputPath) { this.inputpath = inputPath; root = null; stream = new ANTLRFileStream(inputpath); lexer = new tiger_grammarLexer(stream); tokens = new CommonTokenStream(lexer); parser = new tiger_grammarParser(tokens); try { var result = parser.language(); root = result; if (parser.Errors.Count() == 0) { Errors.Clear(); Scope scope = new Scope(null); scope.InitiScope(); root.CheckSemantic(scope, Errors); if (Errors.Count() == 0) { GenCode(root); } } else { Errors.Clear(); foreach (var item in parser.Errors) { Errors.Add(new Error(0,0,item)); } } } catch (Exception e) { Console.WriteLine(e.Message); Console.ReadLine(); } return Errors; }