/* Compilation */ public static IParseTree GetAST(string code) { var inputStream = new AntlrInputStream(code); var lexer = new scheme_langLexer(inputStream); var tokenStream = new CommonTokenStream(lexer); var parser = new scheme_langParser(tokenStream); var context = parser.doc(); return(context); }
public static IParseTree GenerateAST(string code, ref List <ErrorDescriptor> errors) { var inputStream = new AntlrInputStream(code); var lexer = new scheme_langLexer(inputStream); lexer.RemoveErrorListeners(); LexerErrorListener errorListener = new LexerErrorListener(errors); lexer.AddErrorListener(errorListener); var tokenStream = new CommonTokenStream(lexer); var parser = new scheme_langParser(tokenStream); parser.RemoveErrorListeners(); ParserErrorListener errorListener2 = new ParserErrorListener(errors); parser.AddErrorListener(errorListener2); var context = parser.doc(); return(context); }