use of org.finos.legend.engine.language.pure.grammar.from.antlr4.TextParserGrammar in project legend-engine by finos.
the class TextParserExtension method getTextParserInfo.
private static SourceCodeParserInfo getTextParserInfo(SectionSourceCode sectionSourceCode) {
CharStream input = CharStreams.fromString(sectionSourceCode.code);
ParserErrorListener errorListener = new ParserErrorListener(sectionSourceCode.walkerSourceInformation);
TextLexerGrammar lexer = new TextLexerGrammar(input);
lexer.removeErrorListeners();
lexer.addErrorListener(errorListener);
TextParserGrammar parser = new TextParserGrammar(new CommonTokenStream(lexer));
parser.removeErrorListeners();
parser.addErrorListener(errorListener);
return new SourceCodeParserInfo(sectionSourceCode.code, input, sectionSourceCode.sourceInformation, sectionSourceCode.walkerSourceInformation, lexer, parser, parser.definition());
}
Aggregations