Search in sources :

Example 1 with PersistenceParserGrammar

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

the class PersistenceParserExtension method getPersistenceParserInfo.

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