use of org.finos.legend.engine.language.pure.grammar.from.ParserErrorListener in project legend-engine by finos.
the class GenerationParserExtension method getFileGenerationParserInfo.
private static SourceCodeParserInfo getFileGenerationParserInfo(SectionSourceCode sectionSourceCode) {
CharStream input = CharStreams.fromString(sectionSourceCode.code);
ParserErrorListener errorListener = new ParserErrorListener(sectionSourceCode.walkerSourceInformation);
FileGenerationLexerGrammar lexer = new FileGenerationLexerGrammar(input);
lexer.removeErrorListeners();
lexer.addErrorListener(errorListener);
FileGenerationParserGrammar parser = new FileGenerationParserGrammar(new CommonTokenStream(lexer));
parser.removeErrorListeners();
parser.addErrorListener(errorListener);
return new SourceCodeParserInfo(sectionSourceCode.code, input, sectionSourceCode.sourceInformation, sectionSourceCode.walkerSourceInformation, lexer, parser, parser.definition());
}
use of org.finos.legend.engine.language.pure.grammar.from.ParserErrorListener in project legend-engine by finos.
the class DataSpaceParserExtension method getDataSpaceParserInfo.
private static SourceCodeParserInfo getDataSpaceParserInfo(SectionSourceCode sectionSourceCode) {
CharStream input = CharStreams.fromString(sectionSourceCode.code);
ParserErrorListener errorListener = new ParserErrorListener(sectionSourceCode.walkerSourceInformation);
DataSpaceLexerGrammar lexer = new DataSpaceLexerGrammar(input);
lexer.removeErrorListeners();
lexer.addErrorListener(errorListener);
DataSpaceParserGrammar parser = new DataSpaceParserGrammar(new CommonTokenStream(lexer));
parser.removeErrorListeners();
parser.addErrorListener(errorListener);
return new SourceCodeParserInfo(sectionSourceCode.code, input, sectionSourceCode.sourceInformation, sectionSourceCode.walkerSourceInformation, lexer, parser, parser.definition());
}
use of org.finos.legend.engine.language.pure.grammar.from.ParserErrorListener in project legend-engine by finos.
the class DiagramParserExtension method getDiagramParserInfo.
private static SourceCodeParserInfo getDiagramParserInfo(SectionSourceCode sectionSourceCode) {
CharStream input = CharStreams.fromString(sectionSourceCode.code);
ParserErrorListener errorListener = new ParserErrorListener(sectionSourceCode.walkerSourceInformation);
DiagramLexerGrammar lexer = new DiagramLexerGrammar(input);
lexer.removeErrorListeners();
lexer.addErrorListener(errorListener);
DiagramParserGrammar parser = new DiagramParserGrammar(new CommonTokenStream(lexer));
parser.removeErrorListeners();
parser.addErrorListener(errorListener);
return new SourceCodeParserInfo(sectionSourceCode.code, input, sectionSourceCode.sourceInformation, sectionSourceCode.walkerSourceInformation, lexer, parser, parser.definition());
}
use of org.finos.legend.engine.language.pure.grammar.from.ParserErrorListener in project legend-engine by finos.
the class PostProcessorParseTreeWalker method parsePostProcessor.
public static <T extends PostProcessor> T parsePostProcessor(PostProcessorSpecificationSourceCode code, Function<PostProcessorParserGrammar, T> func) {
CharStream input = CharStreams.fromString(code.getCode());
ParserErrorListener errorListener = new ParserErrorListener(code.getWalkerSourceInformation());
PostProcessorLexerGrammar lexer = new PostProcessorLexerGrammar(input);
PostProcessorParserGrammar parser = new PostProcessorParserGrammar(new CommonTokenStream(lexer));
lexer.removeErrorListeners();
lexer.addErrorListener(errorListener);
parser.removeErrorListeners();
parser.addErrorListener(errorListener);
return func.apply(parser);
}
use of org.finos.legend.engine.language.pure.grammar.from.ParserErrorListener 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());
}
Aggregations