Search in sources :

Example 1 with ExternalFormatParserGrammar

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

the class ExternalFormatGrammarParserExtension method getFormatSchemaParserInfo.

private static SourceCodeParserInfo getFormatSchemaParserInfo(SectionSourceCode sourceCode) {
    CharStream input = CharStreams.fromString(sourceCode.code);
    ParserErrorListener errorListener = new ParserErrorListener(sourceCode.walkerSourceInformation);
    ExternalFormatLexerGrammar lexer = new ExternalFormatLexerGrammar(input);
    lexer.removeErrorListeners();
    lexer.addErrorListener(errorListener);
    ExternalFormatParserGrammar parser = new ExternalFormatParserGrammar(new CommonTokenStream(lexer));
    parser.removeErrorListeners();
    parser.addErrorListener(errorListener);
    return new SourceCodeParserInfo(sourceCode.code, input, sourceCode.sourceInformation, sourceCode.walkerSourceInformation, lexer, parser, parser.definition());
}
Also used : CommonTokenStream(org.antlr.v4.runtime.CommonTokenStream) ExternalFormatParserGrammar(org.finos.legend.engine.language.pure.grammar.from.antlr4.ExternalFormatParserGrammar) CharStream(org.antlr.v4.runtime.CharStream) ExternalFormatLexerGrammar(org.finos.legend.engine.language.pure.grammar.from.antlr4.ExternalFormatLexerGrammar)

Aggregations

CharStream (org.antlr.v4.runtime.CharStream)1 CommonTokenStream (org.antlr.v4.runtime.CommonTokenStream)1 ExternalFormatLexerGrammar (org.finos.legend.engine.language.pure.grammar.from.antlr4.ExternalFormatLexerGrammar)1 ExternalFormatParserGrammar (org.finos.legend.engine.language.pure.grammar.from.antlr4.ExternalFormatParserGrammar)1