public BaseAST Parse(string code) { var codeStream = new ANTLRStringStream(code); var lexer = new EvaluationGrammarLexer(codeStream); if (lexer.NumberOfSyntaxErrors > 0) { return null; } var tokenStream = new CommonTokenStream(lexer); var parser = new EvaluationGrammarParser(tokenStream); var parseTree = (CommonTree)parser.program().Tree; if (parser.NumberOfSyntaxErrors > 0) { return null; } var nodes = new CommonTreeNodeStream(parseTree); var astGenerator = new ASTGenerator(nodes); return astGenerator.getAST(); }
public BaseAST Parse(string code) { var codeStream = new ANTLRStringStream(code); var lexer = new EvaluationGrammarLexer(codeStream); if (lexer.NumberOfSyntaxErrors > 0) { return(null); } var tokenStream = new CommonTokenStream(lexer); var parser = new EvaluationGrammarParser(tokenStream); var parseTree = (CommonTree)parser.program().Tree; if (parser.NumberOfSyntaxErrors > 0) { return(null); } var nodes = new CommonTreeNodeStream(parseTree); var astGenerator = new ASTGenerator(nodes); return(astGenerator.getAST()); }