Search in sources :

Example 1 with DomainLexerGrammar

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

the class DomainParser method getParserInfo.

private SourceCodeParserInfo getParserInfo(String code, SourceInformation sectionSourceInformation, ParseTreeWalkerSourceInformation walkerSourceInformation, boolean includeRootContext) {
    CharStream input = CharStreams.fromString(code);
    ParserErrorListener errorListener = new ParserErrorListener(walkerSourceInformation);
    DomainLexerGrammar lexer = new DomainLexerGrammar(input);
    lexer.removeErrorListeners();
    lexer.addErrorListener(errorListener);
    DomainParserGrammar parser = new DomainParserGrammar(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) DomainParserGrammar(org.finos.legend.engine.language.pure.grammar.from.antlr4.domain.DomainParserGrammar) CharStream(org.antlr.v4.runtime.CharStream) DomainLexerGrammar(org.finos.legend.engine.language.pure.grammar.from.antlr4.domain.DomainLexerGrammar) 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 DomainLexerGrammar (org.finos.legend.engine.language.pure.grammar.from.antlr4.domain.DomainLexerGrammar)1 DomainParserGrammar (org.finos.legend.engine.language.pure.grammar.from.antlr4.domain.DomainParserGrammar)1