use of org.finos.legend.pure.m3.serialization.grammar.top.antlr.TopAntlrParser in project legend-pure by finos.
the class TopParser method initAntlrParser.
private TopAntlrParser initAntlrParser(boolean fastParser, String code, String sourceName) {
AntlrSourceInformation sourceInformation = new AntlrSourceInformation(0, 0, sourceName);
AntlrDescriptiveErrorListener pureErrorListener = new AntlrDescriptiveErrorListener(sourceInformation);
TopAntlrLexer lexer = new TopAntlrLexer(new ANTLRInputStream(code));
lexer.removeErrorListeners();
lexer.addErrorListener(pureErrorListener);
TopAntlrParser parser = new TopAntlrParser(new CommonTokenStream(lexer));
parser.removeErrorListeners();
parser.addErrorListener(pureErrorListener);
parser.setErrorHandler(new PureAntlrErrorStrategy(sourceInformation));
parser.getInterpreter().setPredictionMode(fastParser ? PredictionMode.SLL : PredictionMode.LL);
return parser;
}
use of org.finos.legend.pure.m3.serialization.grammar.top.antlr.TopAntlrParser in project legend-pure by finos.
the class TopParser method parseDefinition.
private MutableListMultimap<Parser, CoreInstance> parseDefinition(boolean useFastParser, String code, String sourceName, ModelRepository repository, ParserLibrary parserLibrary, M3M4StateListener listener, Context context, SourceState oldState) {
TopAntlrParser parser = this.initAntlrParser(useFastParser, "\u005cn###Pure\u005cn" + code, sourceName);
TopGraphBuilder visitor = new TopGraphBuilder(sourceName, repository, listener, context, parserLibrary, oldState);
TopAntlrParser.DefinitionContext c = parser.definition();
return visitor.visitDefinition(c);
}
Aggregations