Search in sources :

Example 1 with ServiceLexerGrammar

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

the class ServiceParserExtension method getServiceParserInfo.

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

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 ServiceLexerGrammar (org.finos.legend.engine.language.pure.grammar.from.antlr4.ServiceLexerGrammar)1 ServiceParserGrammar (org.finos.legend.engine.language.pure.grammar.from.antlr4.ServiceParserGrammar)1