use of org.finos.legend.pure.m3.serialization.grammar.m3parser.antlr.TemporaryPureSetImplementation in project legend-pure by finos.
the class M3AntlrParser method parseMappingInfo.
public TemporaryPureSetImplementation parseMappingInfo(String content, String classPath, AntlrContextToM3CoreInstance.LambdaContext lambdaContext, String sourceName, int offset, String importId, ModelRepository repository, ProcessorSupport processorSupport, final Context context) {
AntlrSourceInformation sourceInformation = new AntlrSourceInformation(offset, 0, sourceName, true);
org.finos.legend.pure.m3.serialization.grammar.m3parser.antlr.M3Parser parser = initAntlrParser(true, content, sourceInformation);
ImportGroup grp = (ImportGroup) processorSupport.package_getByUserPath("system::imports::" + importId);
M3AntlrTreeWalker visitor = new M3AntlrTreeWalker(classPath, sourceInformation, this.inlineDSLLibrary, repository, null, null, context, grp, 0, null);
return visitor.walkMapping(parser.mapping(), lambdaContext);
}
use of org.finos.legend.pure.m3.serialization.grammar.m3parser.antlr.TemporaryPureSetImplementation in project legend-pure by finos.
the class XStoreParser method parseMapping.
public String parseMapping(String content, String id, String extendsId, String setSourceInfo, boolean root, String classPath, String classSourceInfo, String mappingPath, String sourceName, int offsetLine, String importId, ModelRepository repository, Context context) throws PureParserException {
M3AntlrParser parser = new M3AntlrParser();
M3ProcessorSupport processorSupport = new M3ProcessorSupport(context, repository);
String mappingName = mappingPath.replace("::", "_");
String classMappingName = classPath.replace("::", "_");
AntlrContextToM3CoreInstance.LambdaContext lambdaContext = new AntlrContextToM3CoreInstance.LambdaContext(mappingName + '_' + classMappingName + (id == null ? "" : '_' + id));
TemporaryPureSetImplementation arg = parser.parseMappingInfo(content, classPath, lambdaContext, sourceName, offsetLine, importId, repository, processorSupport, context);
return "^meta::pure::mapping::xStore::XStoreAssociationImplementation" + setSourceInfo + "(" + ((id == null) ? "" : ("id = '" + id + "',")) + "association = ^meta::pure::metamodel::import::ImportStub " + classSourceInfo + " (importGroup=system::imports::" + importId + ", idOrPath='" + classPath + "')," + "parent = ^meta::pure::metamodel::import::ImportStub (importGroup=system::imports::" + importId + ", idOrPath='" + mappingPath + "')," + "propertyMappings = [" + arg.propertyMappings.collect(propertyStubCoreInstancePair -> "^meta::pure::mapping::xStore::XStorePropertyMapping " + propertyStubCoreInstancePair.sourceInformation.toM4String() + " (property='" + propertyStubCoreInstancePair.property + "'," + (propertyStubCoreInstancePair.sourceMappingId == null ? "" : " sourceSetImplementationId='" + propertyStubCoreInstancePair.sourceMappingId + "',") + (propertyStubCoreInstancePair.targetMappingId == null ? "" : " targetSetImplementationId='" + propertyStubCoreInstancePair.targetMappingId + "',") + " crossExpression=^meta::pure::metamodel::function::LambdaFunction " + lambdaContext.getLambdaFunctionUniqueName() + ' ' + propertyStubCoreInstancePair.expression.getSourceInformation().toM4String() + " (" + " classifierGenericType=^meta::pure::metamodel::type::generics::GenericType " + propertyStubCoreInstancePair.expression.getSourceInformation().toM4String() + " (rawType=meta::pure::metamodel::function::LambdaFunction, typeArguments=^meta::pure::metamodel::type::generics::GenericType " + propertyStubCoreInstancePair.expression.getSourceInformation().toM4String() + " (rawType = ^meta::pure::metamodel::type::FunctionType " + propertyStubCoreInstancePair.expression.getSourceInformation().toM4String() + " ()))," + " expressionSequence=" + M3AntlrParser.process(propertyStubCoreInstancePair.expression, processorSupport) + ")" + " )\n").makeString(",") + "])";
}
use of org.finos.legend.pure.m3.serialization.grammar.m3parser.antlr.TemporaryPureSetImplementation in project legend-pure by finos.
the class AntlrContextToM3CoreInstance method mapping.
public TemporaryPureSetImplementation mapping(MappingContext ctx, String cl, LambdaContext lambdaContext, ImportGroup importId) {
ImportStub src = (ctx.qualifiedName() == null) ? null : ImportStubInstance.createPersistent(this.repository, this.sourceInformation.getPureSourceInformation(ctx.qualifiedName().getStart()), getQualifiedNameString(ctx.qualifiedName()), importId);
CoreInstance filter = (ctx.combinedExpression() == null) ? null : combinedExpression(ctx.combinedExpression(), "", Lists.mutable.empty(), lambdaContext, "", true, importId, true);
MutableList<TemporaryPurePropertyMapping> propertyMappings = ListIterate.collect(ctx.mappingLine(), mlc -> mappingLine(mlc, lambdaContext, cl, importId));
return TemporaryPureSetImplementation.build(src, filter, propertyMappings);
}
use of org.finos.legend.pure.m3.serialization.grammar.m3parser.antlr.TemporaryPureSetImplementation in project legend-pure by finos.
the class M3AntlrParser method parseMapping.
@Override
public String parseMapping(String content, String id, String extendsId, String setSourceInfo, boolean root, String classPath, String classSourceInfo, String mappingPath, String sourceName, int offset, String importId, ModelRepository repository, Context context) throws PureParserException {
M3ProcessorSupport processorSupport = new M3ProcessorSupport(context, repository);
String mappingName = mappingPath.replace("::", "_");
String classMappingName = classPath.replace("::", "_");
AntlrContextToM3CoreInstance.LambdaContext lambdaContext = new AntlrContextToM3CoreInstance.LambdaContext(mappingName + '_' + classMappingName + (id == null ? "" : '_' + id));
TemporaryPureSetImplementation arg = parseMappingInfo(content, classPath, lambdaContext, sourceName, offset, importId, repository, processorSupport, context);
return "^meta::pure::mapping::modelToModel::PureInstanceSetImplementation" + setSourceInfo + "(\n" + (id == null ? "" : "id = '" + id + "',\n") + " root = " + root + ",\n" + (arg._class == null ? "" : " srcClass = " + process(arg._class, processorSupport) + ",\n") + (arg.filter == null ? "" : " filter = ^meta::pure::metamodel::function::LambdaFunction " + lambdaContext.getLambdaFunctionUniqueName() + ' ' + arg.filter.getSourceInformation().toM4String() + " (classifierGenericType=^meta::pure::metamodel::type::generics::GenericType " + arg.filter.getSourceInformation().toM4String() + " (rawType=meta::pure::metamodel::function::LambdaFunction, typeArguments=^meta::pure::metamodel::type::generics::GenericType " + arg.filter.getSourceInformation().toM4String() + " (rawType = ^meta::pure::metamodel::type::FunctionType " + arg.filter.getSourceInformation().toM4String() + " ()))," + " expressionSequence=" + process(arg.filter, processorSupport) + "),") + " class = ^meta::pure::metamodel::import::ImportStub " + classSourceInfo + " (idOrPath='" + classPath + "', importGroup=system::imports::" + importId + "),\n" + " parent= ^meta::pure::metamodel::import::ImportStub(idOrPath='" + mappingPath + "', importGroup=system::imports::" + importId + "),\n" + " propertyMappings=[" + arg.propertyMappings.collect(temporaryPurePropertyMapping -> "^meta::pure::mapping::modelToModel::PurePropertyMapping " + temporaryPurePropertyMapping.sourceInformation.toM4String() + " (property='" + temporaryPurePropertyMapping.property + "'," + " explodeProperty = " + temporaryPurePropertyMapping.explodeProperty + "," + " localMappingProperty = " + temporaryPurePropertyMapping.localMappingProperty + "," + (temporaryPurePropertyMapping.localMappingPropertyType == null ? "" : " localMappingPropertyType = " + process(temporaryPurePropertyMapping.localMappingPropertyType._rawTypeCoreInstance(), processorSupport) + ",\n") + (temporaryPurePropertyMapping.localMappingPropertyMultiplicity == null ? "" : " localMappingPropertyMultiplicity = " + process(temporaryPurePropertyMapping.localMappingPropertyMultiplicity, processorSupport) + ",") + (temporaryPurePropertyMapping.targetMappingId == null ? "" : " targetSetImplementationId='" + temporaryPurePropertyMapping.targetMappingId + "',") + (temporaryPurePropertyMapping.enumerationMappingInformation == null ? "" : "transformer=^meta::pure::tools::GrammarInfoStub" + temporaryPurePropertyMapping.enumerationMappingInformation.getTwo().toM4String() + "(value='" + mappingPath + "," + temporaryPurePropertyMapping.enumerationMappingInformation.getOne() + "'),") + " transform=^meta::pure::metamodel::function::LambdaFunction " + lambdaContext.getLambdaFunctionUniqueName() + ' ' + temporaryPurePropertyMapping.expression.getSourceInformation().toM4String() + " (" + " classifierGenericType=^meta::pure::metamodel::type::generics::GenericType " + temporaryPurePropertyMapping.expression.getSourceInformation().toM4String() + " (rawType=meta::pure::metamodel::function::LambdaFunction, typeArguments=^meta::pure::metamodel::type::generics::GenericType " + temporaryPurePropertyMapping.expression.getSourceInformation().toM4String() + " (rawType = ^meta::pure::metamodel::type::FunctionType " + temporaryPurePropertyMapping.expression.getSourceInformation().toM4String() + " ()))," + " expressionSequence=" + process(temporaryPurePropertyMapping.expression, processorSupport) + ")" + " )\n").makeString(",") + "]\n" + ")";
}
Aggregations