Search in sources :

Example 1 with ConnectionParserGrammar

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

the class ConnectionParser method getParserInfo.

private SourceCodeParserInfo getParserInfo(String code, SourceInformation sectionSourceInformation, ParseTreeWalkerSourceInformation walkerSourceInformation, boolean includeRootContext) {
    CharStream input = CharStreams.fromString(code);
    ParserErrorListener errorListener = new ParserErrorListener(walkerSourceInformation);
    ConnectionLexerGrammar lexer = new ConnectionLexerGrammar(input);
    lexer.removeErrorListeners();
    lexer.addErrorListener(errorListener);
    ConnectionParserGrammar parser = new ConnectionParserGrammar(new CommonTokenStream(lexer));
    parser.removeErrorListeners();
    parser.addErrorListener(errorListener);
    return new SourceCodeParserInfo(code, input, sectionSourceInformation, walkerSourceInformation, lexer, parser, includeRootContext ? parser.definition() : null);
}
Also used : SourceCodeParserInfo(org.finos.legend.engine.language.pure.grammar.from.SourceCodeParserInfo) CommonTokenStream(org.antlr.v4.runtime.CommonTokenStream) ConnectionParserGrammar(org.finos.legend.engine.language.pure.grammar.from.antlr4.connection.ConnectionParserGrammar) CharStream(org.antlr.v4.runtime.CharStream) ConnectionLexerGrammar(org.finos.legend.engine.language.pure.grammar.from.antlr4.connection.ConnectionLexerGrammar) 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 ConnectionLexerGrammar (org.finos.legend.engine.language.pure.grammar.from.antlr4.connection.ConnectionLexerGrammar)1 ConnectionParserGrammar (org.finos.legend.engine.language.pure.grammar.from.antlr4.connection.ConnectionParserGrammar)1