use of org.finos.legend.engine.protocol.pure.v1.model.packageableElement.section.ImportAwareCodeSection 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.protocol.pure.v1.model.packageableElement.section.ImportAwareCodeSection 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;
}
use of org.finos.legend.engine.protocol.pure.v1.model.packageableElement.section.ImportAwareCodeSection in project legend-engine by finos.
the class DomainParser method parseValueSpecification.
public ValueSpecification parseValueSpecification(String input, String s, boolean returnSourceInfo) {
PureGrammarParserContext parserContext = new PureGrammarParserContext(PureGrammarParserExtensions.fromExtensions(Lists.immutable.empty()));
ParseTreeWalkerSourceInformation lambdaWalkerSourceInformation = new ParseTreeWalkerSourceInformation.Builder(s, 0, 0).withReturnSourceInfo(returnSourceInfo).build();
String prefix = "function go():Any[*]{let x = ";
String fullCode = prefix + input + ";}";
ParseTreeWalkerSourceInformation walkerSourceInformation = new ParseTreeWalkerSourceInformation.Builder(lambdaWalkerSourceInformation).withColumnOffset(lambdaWalkerSourceInformation.getColumnOffset() - prefix.length()).build();
SourceCodeParserInfo sectionParserInfo = this.getParserInfo(fullCode, null, walkerSourceInformation, true);
DomainParseTreeWalker walker = new DomainParseTreeWalker(walkerSourceInformation, parserContext, (ImportAwareCodeSection) null);
return (ValueSpecification) walker.combinedExpression(((DomainParserGrammar.DefinitionContext) sectionParserInfo.rootContext).elementDefinition(0).functionDefinition().codeBlock().programLine(0).letExpression().combinedExpression(), "", Lists.mutable.empty(), null, "", false, returnSourceInfo);
}
use of org.finos.legend.engine.protocol.pure.v1.model.packageableElement.section.ImportAwareCodeSection in project legend-engine by finos.
the class DomainParser method parseLambda.
public Lambda parseLambda(String code, String lambdaId, PureGrammarParserContext parserContext, boolean returnSourceInfo) {
ParseTreeWalkerSourceInformation lambdaWalkerSourceInformation = new ParseTreeWalkerSourceInformation.Builder(lambdaId, 0, 0).withReturnSourceInfo(returnSourceInfo).build();
String prefix = "function go():Any[*]{";
String fullCode = prefix + code + "}";
ParseTreeWalkerSourceInformation walkerSourceInformation = new ParseTreeWalkerSourceInformation.Builder(lambdaWalkerSourceInformation).withColumnOffset(lambdaWalkerSourceInformation.getColumnOffset() - prefix.length()).build();
SourceCodeParserInfo sectionParserInfo = this.getParserInfo(fullCode, null, walkerSourceInformation, true);
DomainParseTreeWalker walker = new DomainParseTreeWalker(walkerSourceInformation, parserContext, (ImportAwareCodeSection) null);
return (Lambda) walker.concreteFunctionDefinition(((DomainParserGrammar.DefinitionContext) sectionParserInfo.rootContext).elementDefinition(0).functionDefinition());
}
use of org.finos.legend.engine.protocol.pure.v1.model.packageableElement.section.ImportAwareCodeSection in project legend-engine by finos.
the class RuntimeParser method parse.
@Override
public Section parse(SourceCodeParserInfo sectionParserInfo, Consumer<PackageableElement> pureModelContextData, PureGrammarParserContext parserContext) {
ImportAwareCodeSection section = new ImportAwareCodeSection();
section.parserName = this.getName();
section.sourceInformation = sectionParserInfo.sourceInformation;
RuntimeParseTreeWalker walker = new RuntimeParseTreeWalker(sectionParserInfo.walkerSourceInformation, pureModelContextData, section, this.connectionParser);
walker.visit((RuntimeParserGrammar.DefinitionContext) sectionParserInfo.rootContext);
return section;
}
Aggregations