Search in sources :

Example 1 with FileGenerationParserGrammar

use of org.finos.legend.engine.language.pure.grammar.from.antlr4.FileGenerationParserGrammar in project legend-engine by finos.

the class GenerationParserExtension method getFileGenerationParserInfo.

private static SourceCodeParserInfo getFileGenerationParserInfo(SectionSourceCode sectionSourceCode) {
    CharStream input = CharStreams.fromString(sectionSourceCode.code);
    ParserErrorListener errorListener = new ParserErrorListener(sectionSourceCode.walkerSourceInformation);
    FileGenerationLexerGrammar lexer = new FileGenerationLexerGrammar(input);
    lexer.removeErrorListeners();
    lexer.addErrorListener(errorListener);
    FileGenerationParserGrammar parser = new FileGenerationParserGrammar(new CommonTokenStream(lexer));
    parser.removeErrorListeners();
    parser.addErrorListener(errorListener);
    return new SourceCodeParserInfo(sectionSourceCode.code, input, sectionSourceCode.sourceInformation, sectionSourceCode.walkerSourceInformation, lexer, parser, parser.definition());
}
Also used : SourceCodeParserInfo(org.finos.legend.engine.language.pure.grammar.from.SourceCodeParserInfo) CommonTokenStream(org.antlr.v4.runtime.CommonTokenStream) FileGenerationParserGrammar(org.finos.legend.engine.language.pure.grammar.from.antlr4.FileGenerationParserGrammar) CharStream(org.antlr.v4.runtime.CharStream) FileGenerationLexerGrammar(org.finos.legend.engine.language.pure.grammar.from.antlr4.FileGenerationLexerGrammar) ParserErrorListener(org.finos.legend.engine.language.pure.grammar.from.ParserErrorListener)

Aggregations

CharStream (org.antlr.v4.runtime.CharStream)1 CommonTokenStream (org.antlr.v4.runtime.CommonTokenStream)1 ParserErrorListener (org.finos.legend.engine.language.pure.grammar.from.ParserErrorListener)1 SourceCodeParserInfo (org.finos.legend.engine.language.pure.grammar.from.SourceCodeParserInfo)1 FileGenerationLexerGrammar (org.finos.legend.engine.language.pure.grammar.from.antlr4.FileGenerationLexerGrammar)1 FileGenerationParserGrammar (org.finos.legend.engine.language.pure.grammar.from.antlr4.FileGenerationParserGrammar)1