public override void CheckSemantic(Scope scope, List<Error> errors) { int count = errors.Count(); Id.CheckSemantic(scope, errors); lval = (TigerNode)Id; GetLValues(Access, ref lval); count = errors.Count(); lval.CheckSemantic(scope, errors); if (count == errors.Count()) ReturnType = lval.ReturnType; }
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; }