use of org.finos.legend.engine.language.pure.grammar.from.SourceCodeParserInfo 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.SourceCodeParserInfo 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.SourceCodeParserInfo in project legend-engine by finos.
the class PersistenceParserExtension method parseSection.
private static Section parseSection(SectionSourceCode sectionSourceCode, Consumer<PackageableElement> elementConsumer, PureGrammarParserContext context) {
SourceCodeParserInfo parserInfo = getPersistenceParserInfo(sectionSourceCode);
ImportAwareCodeSection section = new ImportAwareCodeSection();
section.parserName = sectionSourceCode.sectionType;
section.sourceInformation = parserInfo.sourceInformation;
PersistenceParseTreeWalker walker = new PersistenceParseTreeWalker(parserInfo.walkerSourceInformation, elementConsumer, section);
walker.visit((PersistenceParserGrammar.DefinitionContext) parserInfo.rootContext);
return section;
}
use of org.finos.legend.engine.language.pure.grammar.from.SourceCodeParserInfo 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.SourceCodeParserInfo in project legend-engine by finos.
the class DiagramParserExtension method parseSection.
private static Section parseSection(SectionSourceCode sectionSourceCode, Consumer<PackageableElement> elementConsumer, PureGrammarParserContext pureGrammarParserContext) {
SourceCodeParserInfo parserInfo = getDiagramParserInfo(sectionSourceCode);
ImportAwareCodeSection section = new ImportAwareCodeSection();
section.parserName = sectionSourceCode.sectionType;
section.sourceInformation = parserInfo.sourceInformation;
DiagramParseTreeWalker walker = new DiagramParseTreeWalker(parserInfo.walkerSourceInformation, elementConsumer, section);
walker.visit((DiagramParserGrammar.DefinitionContext) parserInfo.rootContext);
return section;
}
Aggregations