Search in sources :

Example 1 with GenerationSpecificationParserGrammar

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());
}
Also used : GenerationSpecificationLexerGrammar(org.finos.legend.engine.language.pure.grammar.from.antlr4.GenerationSpecificationLexerGrammar) SourceCodeParserInfo(org.finos.legend.engine.language.pure.grammar.from.SourceCodeParserInfo) CommonTokenStream(org.antlr.v4.runtime.CommonTokenStream) GenerationSpecificationParserGrammar(org.finos.legend.engine.language.pure.grammar.from.antlr4.GenerationSpecificationParserGrammar) CharStream(org.antlr.v4.runtime.CharStream) 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 GenerationSpecificationLexerGrammar (org.finos.legend.engine.language.pure.grammar.from.antlr4.GenerationSpecificationLexerGrammar)1 GenerationSpecificationParserGrammar (org.finos.legend.engine.language.pure.grammar.from.antlr4.GenerationSpecificationParserGrammar)1