Search in sources :

Example 1 with MappingParserGrammar

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

the class MappingParser method getParserInfo.

@Override
public SourceCodeParserInfo getParserInfo(String code, SourceInformation sourceInformation, ParseTreeWalkerSourceInformation walkerSourceInformation) {
    CharStream input = CharStreams.fromString(code);
    ParserErrorListener errorListener = new ParserErrorListener(walkerSourceInformation);
    MappingLexerGrammar lexer = new MappingLexerGrammar(input);
    lexer.removeErrorListeners();
    lexer.addErrorListener(errorListener);
    MappingParserGrammar parser = new MappingParserGrammar(new CommonTokenStream(lexer));
    parser.removeErrorListeners();
    parser.addErrorListener(errorListener);
    return new SourceCodeParserInfo(code, input, sourceInformation, walkerSourceInformation, lexer, parser, parser.definition());
}
Also used : SourceCodeParserInfo(org.finos.legend.engine.language.pure.grammar.from.SourceCodeParserInfo) CommonTokenStream(org.antlr.v4.runtime.CommonTokenStream) MappingParserGrammar(org.finos.legend.engine.language.pure.grammar.from.antlr4.mapping.MappingParserGrammar) MappingLexerGrammar(org.finos.legend.engine.language.pure.grammar.from.antlr4.mapping.MappingLexerGrammar) 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 MappingLexerGrammar (org.finos.legend.engine.language.pure.grammar.from.antlr4.mapping.MappingLexerGrammar)1 MappingParserGrammar (org.finos.legend.engine.language.pure.grammar.from.antlr4.mapping.MappingParserGrammar)1