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