Search in sources :

Example 1 with ParserErrorListener

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());
}
Also used : SourceCodeParserInfo(org.finos.legend.engine.language.pure.grammar.from.SourceCodeParserInfo) CommonTokenStream(org.antlr.v4.runtime.CommonTokenStream) FileGenerationParserGrammar(org.finos.legend.engine.language.pure.grammar.from.antlr4.FileGenerationParserGrammar) CharStream(org.antlr.v4.runtime.CharStream) FileGenerationLexerGrammar(org.finos.legend.engine.language.pure.grammar.from.antlr4.FileGenerationLexerGrammar) ParserErrorListener(org.finos.legend.engine.language.pure.grammar.from.ParserErrorListener)

Example 2 with ParserErrorListener

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());
}
Also used : SourceCodeParserInfo(org.finos.legend.engine.language.pure.grammar.from.SourceCodeParserInfo) CommonTokenStream(org.antlr.v4.runtime.CommonTokenStream) DataSpaceLexerGrammar(org.finos.legend.engine.language.pure.grammar.from.antlr4.DataSpaceLexerGrammar) DataSpaceParserGrammar(org.finos.legend.engine.language.pure.grammar.from.antlr4.DataSpaceParserGrammar) CharStream(org.antlr.v4.runtime.CharStream) ParserErrorListener(org.finos.legend.engine.language.pure.grammar.from.ParserErrorListener)

Example 3 with ParserErrorListener

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());
}
Also used : SourceCodeParserInfo(org.finos.legend.engine.language.pure.grammar.from.SourceCodeParserInfo) CommonTokenStream(org.antlr.v4.runtime.CommonTokenStream) DiagramLexerGrammar(org.finos.legend.engine.language.pure.grammar.from.antlr4.DiagramLexerGrammar) DiagramParserGrammar(org.finos.legend.engine.language.pure.grammar.from.antlr4.DiagramParserGrammar) CharStream(org.antlr.v4.runtime.CharStream) ParserErrorListener(org.finos.legend.engine.language.pure.grammar.from.ParserErrorListener)

Example 4 with ParserErrorListener

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);
}
Also used : CommonTokenStream(org.antlr.v4.runtime.CommonTokenStream) PostProcessorParserGrammar(org.finos.legend.engine.language.pure.grammar.from.antlr4.connection.postProcessor.PostProcessorParserGrammar) PostProcessorLexerGrammar(org.finos.legend.engine.language.pure.grammar.from.antlr4.connection.postProcessor.PostProcessorLexerGrammar) CharStream(org.antlr.v4.runtime.CharStream) ParserErrorListener(org.finos.legend.engine.language.pure.grammar.from.ParserErrorListener)

Example 5 with ParserErrorListener

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());
}
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

CommonTokenStream (org.antlr.v4.runtime.CommonTokenStream)17 ParserErrorListener (org.finos.legend.engine.language.pure.grammar.from.ParserErrorListener)17 CharStream (org.antlr.v4.runtime.CharStream)15 SourceCodeParserInfo (org.finos.legend.engine.language.pure.grammar.from.SourceCodeParserInfo)14 ParseTreeWalkerSourceInformation (org.finos.legend.engine.language.pure.grammar.from.ParseTreeWalkerSourceInformation)2 DomainParserGrammar (org.finos.legend.engine.language.pure.grammar.from.antlr4.domain.DomainParserGrammar)2 Constraint (org.finos.legend.engine.protocol.pure.v1.model.packageableElement.domain.Constraint)2 CString (org.finos.legend.engine.protocol.pure.v1.model.valueSpecification.raw.CString)2 TerminalNode (org.antlr.v4.runtime.tree.TerminalNode)1 DataSpaceLexerGrammar (org.finos.legend.engine.language.pure.grammar.from.antlr4.DataSpaceLexerGrammar)1 DataSpaceParserGrammar (org.finos.legend.engine.language.pure.grammar.from.antlr4.DataSpaceParserGrammar)1 DiagramLexerGrammar (org.finos.legend.engine.language.pure.grammar.from.antlr4.DiagramLexerGrammar)1 DiagramParserGrammar (org.finos.legend.engine.language.pure.grammar.from.antlr4.DiagramParserGrammar)1 FileGenerationLexerGrammar (org.finos.legend.engine.language.pure.grammar.from.antlr4.FileGenerationLexerGrammar)1 FileGenerationParserGrammar (org.finos.legend.engine.language.pure.grammar.from.antlr4.FileGenerationParserGrammar)1 GenerationSpecificationLexerGrammar (org.finos.legend.engine.language.pure.grammar.from.antlr4.GenerationSpecificationLexerGrammar)1 GenerationSpecificationParserGrammar (org.finos.legend.engine.language.pure.grammar.from.antlr4.GenerationSpecificationParserGrammar)1 PersistenceLexerGrammar (org.finos.legend.engine.language.pure.grammar.from.antlr4.PersistenceLexerGrammar)1 PersistenceParserGrammar (org.finos.legend.engine.language.pure.grammar.from.antlr4.PersistenceParserGrammar)1 ServiceLexerGrammar (org.finos.legend.engine.language.pure.grammar.from.antlr4.ServiceLexerGrammar)1