Search in sources :

Example 1 with DataSpaceParserGrammar

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

the class DataSpaceParserExtension method getDataSpaceParserInfo.

private static SourceCodeParserInfo getDataSpaceParserInfo(SectionSourceCode sectionSourceCode) {
    CharStream input = CharStreams.fromString(sectionSourceCode.code);
    ParserErrorListener errorListener = new ParserErrorListener(sectionSourceCode.walkerSourceInformation);
    DataSpaceLexerGrammar lexer = new DataSpaceLexerGrammar(input);
    lexer.removeErrorListeners();
    lexer.addErrorListener(errorListener);
    DataSpaceParserGrammar parser = new DataSpaceParserGrammar(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) DataSpaceLexerGrammar(org.finos.legend.engine.language.pure.grammar.from.antlr4.DataSpaceLexerGrammar) DataSpaceParserGrammar(org.finos.legend.engine.language.pure.grammar.from.antlr4.DataSpaceParserGrammar) 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 DataSpaceLexerGrammar (org.finos.legend.engine.language.pure.grammar.from.antlr4.DataSpaceLexerGrammar)1 DataSpaceParserGrammar (org.finos.legend.engine.language.pure.grammar.from.antlr4.DataSpaceParserGrammar)1