Search in sources :

Example 1 with TextParserGrammar

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

the class TextParserExtension method getTextParserInfo.

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