| /** |
| * <copyright> |
| * |
| * Copyright (c) 2013 Willink Transformation Ltd., University of York and others. |
| * All rights reserved. This program and the accompanying materials |
| * are made available under the terms of the Eclipse Public License v2.0 |
| * which accompanies this distribution, and is available at |
| * http://www.eclipse.org/legal/epl-v20.html |
| * |
| * Contributors: |
| * Adolfo Sanchez-Barbudo Herrera (University of York) - initial API and implementation |
| * |
| * </copyright> |
| */ |
| grammar org.eclipse.qvto.examples.xtext.qvtoperational.QVTOperational with org.eclipse.qvto.examples.xtext.imperativeocl.ImperativeOCL |
| |
| // generate qvtoperationalcs "http://www.eclipse.org/qvt/pivot/1.0/QVTOperationalCS" |
| //import "http://www.eclipse.org/qvt/pivot/1.0/QVTOperationalCS" |
| import "platform:/resource/org.eclipse.qvto.examples.xtext.qvtoperational/model/QVTOperationalCS.ecore" |
| |
| import "http://www.eclipse.org/emf/2002/Ecore" as ecore |
| //import "http://www.eclipse.org/ocl/3.1.0/BaseCST" as base |
| //import "http://www.eclipse.org/ocl/3.1.0/EssentialOCLCST" as essentialocl |
| //import "http://www.eclipse.org/qvt/pivot/1.0/ImperativeOCLCS" as imperativeocl |
| |
| import "platform:/resource/org.eclipse.ocl.xtext.base/model/BaseCS.ecore" as base |
| import "platform:/resource/org.eclipse.ocl.xtext.essentialocl/model/EssentialOCLCS.ecore" as essentialocl |
| import "platform:/resource/org.eclipse.qvto.examples.xtext.imperativeocl/model/ImperativeOCLCS.ecore" as imperativeocl |
| |
| TopLevelCS : (ownedImports += ImportCS)* |
| (ownedPackages+= UnitPackageCS |
| | ownedTypes+= UnitTypeCS |
| | ownedAnnotations+= TagCS )* |
| ; |
| |
| enum MetamodelKindCS : metamodel= 'metamodel' | package='package'; |
| enum DirectionKindCS : in='in'| out='out' | inout='inout'; |
| enum ImportKindCS : access='access' | extension = 'extends'; |
| enum ModuleKindCS : library='library' | transformation = 'transformation'; |
| |
| // FIXME use a CS element and unordered groups |
| TransformationQualifier returns ecore::EString : 'blackbox' | 'abstract' | 'static'; |
| LibraryQualifier returns ecore::EString : 'blackbox'; |
| FeatureQualifier returns ecore::EString : 'composes' | 'references' | 'readonly' | 'derived' | 'static'; |
| OperationQualifier returns ecore::EString : 'blackbox' | 'abstract' | 'static'; |
| |
| |
| |
| // ****** OCL redifinitions ******// |
| |
| // FIXME review this redefiniton. |
| MultiplicityCS returns base::MultiplicityBoundsCS: '[' (lowerBound=LOWER '...')? upperBound=UPPER ']'; |
| |
| PathName2CS returns PathName2CS: |
| ownedPathElements2+=PathElement2CS ('::' ownedPathElements2+=PathElement2CS)* |
| ; |
| |
| PathElement2CS: |
| name=UnrestrictedName |
| ; |
| |
| TypedMultiplicityRef2CS returns base::TypedRefCS: |
| TypedRef2CS (ownedMultiplicity=MultiplicityCS)? |
| ; |
| |
| TypeRefCS returns base::TypeRefCS: |
| TypedRef2CS // | WildcardTypeRefCS |
| // FIXME deviation from OCLInEcore. No templates parameter, yet |
| ; |
| |
| TypedRef2CS returns base::TypedRefCS: |
| TypeLiteralCS | TypedTypeRef2CS |
| ; |
| |
| TypedTypeRef2CS returns TypedTypeRef2CS: |
| ownedPathName=PathName2CS ('(' ownedBinding=TemplateBindingCS ')')? ('@' extentLocation=UnrestrictedName)? |
| ; |
| |
| // ****** QVTo ****** |
| |
| ClassCS returns base::ClassCS: |
| (DataTypeCS | ExceptionCS | QVToClassCS) |
| ';'? |
| ; |
| |
| ClassifierOperationCS returns QVToOperationCS: |
| ownedStereotype = StereotypeQualifierCS? |
| qualifiers+= FeatureQualifier* |
| name=UnrestrictedName |
| '(' (ownedParameters+= ParameterCS (',' ownedParameters+=ParameterCS)*)? ')' |
| (':' ownedType=TypedMultiplicityRef2CS)? |
| ; |
| |
| ClassifierPropertyCS returns ClassifierPropertyCS: |
| ownedStereotype=StereotypeQualifierCS? |
| qualifiers+=FeatureQualifier* |
| name=UnrestrictedName ':' ownedType=TypedMultiplicityRef2CS |
| (default=SINGLE_QUOTED_STRING) ? // FIXME QVTO syntax define a more complex InitPartCS |
| ('opposites' '~'? opposite=Identifier)? // FIXME |
| ; |
| |
| CompoundOperationBodyCS returns OperationBodyCS: |
| {OperationBodyCS} |
| '{' |
| ownedContentExps += ExpressionStatementCS* |
| '}' |
| ; |
| |
| ConfigurationPropertyCS: |
| 'configuration' |
| 'property' ownedScopedName=PathName2CS |
| ':' ownedType=TypeLiteralCS |
| // FIXME OMG issue: allow default values for configuration properties |
| '=' default= StringLiteral |
| ; |
| |
| ContextualPropertyCS: |
| 'intermediate' |
| 'property' ownedScopedName=PathName2CS |
| ':' ownedType=TypedMultiplicityRef2CS |
| ('=' ownedInitExp= ExpCS)? |
| ; |
| |
| ConstructorCS returns ConstructorOperationCS: |
| ConstructorDeclarationCS | ConstructorDefinitionCS |
| ; |
| |
| ConstructorDeclarationCS returns ConstructorOperationCS: |
| ConstructorHeaderCS ';' |
| ; |
| |
| ConstructorDefinitionCS returns ConstructorOperationCS: |
| ConstructorHeaderCS ownedBody=CompoundOperationBodyCS ';'? |
| ; |
| |
| ConstructorHeaderCS returns ConstructorOperationCS: |
| qualifiers+=OperationQualifier* |
| 'constructor' ownedScopedName=PathName2CS |
| '(' (ownedParameters+= ParameterCS (',' ownedParameters+= ParameterCS)* )? ')' |
| ; |
| |
| |
| |
| DataTypeCS returns base::DataTypeCS: |
| ('datatype' | {PrimitiveTypeCS} 'primitive') |
| name=UnrestrictedName |
| ; |
| |
| EntryOperationCS : |
| 'main' '('')' ownedBody=CompoundOperationBodyCS ';'? |
| ; |
| |
| // FIXME Deviation from official grammar |
| EnumerationCS returns base::EnumerationCS: |
| 'enum' |
| name=Identifier |
| ( ('{' (ownedLiterals+=EnumerationLiteralCS (',' ownedLiterals+=EnumerationLiteralCS)*) '}' )) |
| ';'? |
| ; |
| |
| EnumerationLiteralCS returns base::EnumerationLiteralCS: |
| name=UnrestrictedName |
| ; |
| |
| ExceptionCS returns base::StructuredClassCS: // FIXME for the time being, exception is another class |
| 'exception' |
| name = UnrestrictedName |
| ('extends' (ownedSuperTypes+=TypedRefCS (',' ownedSuperTypes+=TypedRefCS)*))? |
| ; |
| |
| HelperCS returns HelperOperationCS: |
| HelperDeclarationCS | HelperDefinitionCS |
| ; |
| |
| HelperDeclarationCS returns HelperOperationCS: |
| HelperHeaderCS ';' |
| ; |
| |
| HelperHeaderCS returns HelperOperationCS: |
| qualifiers+=OperationQualifier* |
| ('helper' | isQuery?='query') ownedScopedName=PathName2CS |
| '{' (ownedParameters+= ParameterDeclarationCS (',' ownedParameters+= ParameterDeclarationCS)* )? ')' |
| (':' ownedResults += ParameterDeclarationCS (',' ownedResults+=ParameterDeclarationCS) )? |
| ; |
| |
| HelperDefinitionCS returns HelperOperationCS: |
| HelperSimpleDefinitionCS | HelperCompoundDefinitionCS |
| ; |
| |
| HelperSimpleDefinitionCS returns HelperOperationCS: |
| HelperHeaderCS ownedBody=SimpleOperationBodyCS ';' |
| ; |
| |
| HelperCompoundDefinitionCS returns HelperOperationCS: |
| HelperHeaderCS ownedBody=CompoundOperationBodyCS ';'? |
| ; |
| |
| ImportCS returns QVToImportCS : |
| ('import' ownedUnitRef=UnitRefCS ';') |
| | ('from' ownedUnitRef=UnitRefCS 'import' ((importedUnitElement+=Identifier (',' importedUnitElement+=Identifier)*) | isAll?='*') ';') |
| ; |
| |
| InitPartCS: |
| initOp=InitOpCS ownedExp=ExpCS |
| ; |
| |
| LibraryCS returns QVToLibraryCS: |
| LibraryDeclCS | LibraryDefCS |
| ; |
| |
| LibraryDeclCS returns QVToLibraryCS: |
| LibraryHeaderCS ';' |
| ; |
| |
| LibraryDefCS returns QVToLibraryCS: |
| LibraryHeaderCS '{' |
| (ownedProperties+= ModulePropertyCS |
| | ownedOperations+= ModuleOperationCS |
| | ownedAnnotations+= TagCS)* |
| '}' ';'? |
| ; |
| |
| LibraryHeaderCS returns QVToLibraryCS: |
| ownedQualifiers+=LibraryQualifier* |
| 'library' name=UnrestrictedName |
| '(' ownedParameters+= ModelTypeRefCS (',' ownedParameters+= ModelTypeRefCS)* ')' |
| (ownedModuleUsages+= ModuleUsageCS)* |
| ; |
| |
| MappingBodyCS: |
| {MappingBodyCS} |
| ('init' '{' ownedInitExps+=ExpCS '}')? |
| |
| ( ((hasPopulationKeyword?='population')? '{' ownedContentExps+=ExpCS* '}') |
| | ownedContentExps+=ExpCS |
| ) |
| |
| ('end' '{' ownedEndExps+=ExpCS '}')? |
| ; |
| |
| // FIXME OMG: the following seems wrong |
| // "Note that the omission of the source is a shorthand in terms of the execution semantics - the source is the transformation |
| // class itself, denoted by ‘this,’ but not in terms of the metamodel representation: the OperationCallExp::source |
| // property may be left empty." |
| // |
| // The invoked operation call should refer (as a source) to the transformation/class in which the call took place |
| // |
| // also ImperativeCallExp::isVirtual doesn't seem to be needed, as this concern should belong to OCL. In OCL, an operation call |
| // can also statically refer to a declared operation, otherwise it needs to be dynamically dispatched. |
| // |
| // ImperativeCallExpCS: NameExpCS; |
| |
| MappingCallExpCS: |
| ('map' | isStrict?='xmap') |
| ownedPathName=PathNameCS ownedRoundBracketedClause=RoundBracketedClauseCS |
| ; |
| |
| MappingOperationCS: |
| MappingDeclarationCS | MappingDefinitionCS |
| ; |
| |
| MappingDeclarationCS returns MappingOperationCS: |
| MappingOperationHeaderCS ';' |
| ; |
| |
| MappingDefinitionCS returns MappingOperationCS: |
| MappingOperationHeaderCS '{' |
| ownedBody=MappingBodyCS |
| '}' |
| ; |
| |
| MappingOperationHeaderCS returns MappingOperationCS: |
| qualifiers+=OperationQualifier* |
| 'mapping' direction=DirectionKindCS? |
| ownedScopedName=PathName2CS |
| '(' (ownedParameters+= ParameterDeclarationCS (',' ownedParameters+= ParameterDeclarationCS)* )? ')' |
| (':' ownedResults += ParameterDeclarationCS (',' ownedResults+=ParameterDeclarationCS) )? |
| ( ('inherits' ownedInheritRefs+=OperationRefCS (',' ownedInheritRefs+=OperationRefCS)* )? |
| & ('merges' ownedMergeRefs+=OperationRefCS (',' ownedMergeRefs+=OperationRefCS)* )? |
| & ('disjuncts' ownedDisjunctRefs+=OperationRefCS (',' ownedDisjunctRefs+=OperationRefCS)* )? |
| & ('refines' ownedRefinedRule=PathName2CS)? |
| ) |
| ('when' '{' ownedWhenExps+=ExpCS* '}')? |
| ('where' '{' ownedWhereExps+=ExpressionBlockCS* '}')? |
| ; |
| |
| MetamodelCS returns MetamodelCS: // MetamodelKind provides extra semantic, we need to retain the kind |
| metamodelKind=MetamodelKindCS |
| name = UnrestrictedName |
| '{' (ownedClasses+=ClassCS | |
| ownedClasses+=EnumerationCS | // FIXME QVTo grammar distincts classifier from enumeration |
| ownedAnnotations+= TagCS)* |
| '}' |
| ';'? |
| ; |
| |
| ModelTypeCS: |
| 'modeltype' name=UnrestrictedName complianceKind=StringLiteral? 'uses' |
| ownedPackageRefs+= PackageRefCS (',' ownedPackageRefs+=PackageRefCS)* |
| ('where' '{' (ownedConditions+=ExpCS (';' ownedConditions+=ExpCS)* ';'?)? '}' )? |
| ';' |
| ; |
| |
| ModelTypeRefCS : |
| ownedType = TypedTypeRef2CS |
| ; |
| |
| ModuleOperationCS returns ImperativeOperationCS: |
| EntryOperationCS | MappingOperationCS | HelperCS | ConstructorCS |
| ; |
| |
| ModulePropertyCS: |
| ConfigurationPropertyCS | ContextualPropertyCS |
| ; |
| |
| ModuleRefCS: |
| ownedScopedName=PathName2CS ('(' ownedParameters+=ParameterDeclarationCS (',' ownedParameters+=ParameterDeclarationCS)* ')')? |
| ; |
| |
| ModuleUsageCS: |
| importKind=ImportKindCS moduleKind=ModuleKindCS? ownedModuleRefs+=ModuleRefCS (',' ownedModuleRefs+=ModuleRefCS)* |
| ; |
| |
| ObjectExpCS: |
| 'object' |
| ('(' ownedIterator=VarDeclarationNoInitCS')')? |
| ownedVariable = ObjectVariableCS |
| ('@' ownedExtentRef = ExtentRefCS)? '{' |
| (ownedExps+=ExpCS)* |
| '}' |
| ; |
| |
| ObjectVariableCS returns essentialocl::VariableCS: |
| name=UnrestrictedName ':' (ownedType=TypedTypeRef2CS)? |
| | ownedType=TypedTypeRef2CS |
| ; |
| |
| OperationRefCS returns OperationRefCS: |
| ownedPathName=PathName2CS |
| ; |
| |
| PackageRefCS: |
| uri=StringLiteral |
| | ownedScopedName=PathName2CS '(' (uri= StringLiteral) ')' |
| ; |
| |
| ParameterCS returns base::ParameterCS: |
| name=UnrestrictedName |
| (':' ownedType=TypedMultiplicityRef2CS)? |
| ; |
| |
| ParameterDeclarationCS : |
| direction= DirectionKindCS? |
| name=UnrestrictedName // FIXME Spec grammar says that you can have just a typeSpec |
| (':' ownedType= TypedMultiplicityRef2CS)? |
| ownedInitPart=InitPartCS? |
| ; |
| |
| QVToClassCS returns QVToClassCS: |
| isIntermediate ?= 'intermediate' ? |
| // FIXME qualifier += Qualifier* |
| 'class' |
| name=UnrestrictedName |
| ('extends' (ownedSuperTypes += TypedRefCS (',' ownedSuperTypes+=TypedRefCS)*))? |
| ('{' ((ownedProperties += ClassifierPropertyCS | ownedOperations+=ClassifierOperationCS | ownedAnnotations+= TagCS) ';' )+ |
| '}' )? |
| ; |
| |
| // FIXME NameExpCS ??? |
| ResolveExpCS : |
| ResolveByTypeExpCS | ResolveByMappingExpCS |
| ; |
| |
| ResolveByTypeExpCS : |
| isDeferred?='late'? |
| name = ('resolve' | 'resolveone' | 'resolveinv' | 'resolveinvone') |
| '(' ownedTarget=TypeSelectorCS ('|' ownedCondition = ExpCS)? ')' |
| ; |
| ResolveByMappingExpCS : |
| isDeferred?='late'? |
| name = ('resolveIn' | 'resolveoneIn' | 'resolveinvIn' | 'resolveinvoneIn') |
| '(' ownedMappingRef=OperationRefCS ( ',' ownedTarget=VarDeclarationNoInitCS '|' ownedCondition=ExpCS) ? ')' |
| ; |
| |
| SimpleOperationBodyCS returns OperationBodyCS: |
| '=' ownedContentExps += ExpCS |
| ; |
| |
| StereotypeQualifierCS returns StereotypeQualifierCS: |
| '<<' (stereotypes+=Identifier (',' stereotypes+=Identifier)*) '>>' |
| ; |
| |
| TagCS returns TagCS: |
| 'tag' name=(UnrestrictedName|SINGLE_QUOTED_STRING)? |
| ownedElementPath=PathName2CS ('=' ownedExpression=ExpCS)? ';' |
| ; |
| |
| TransformationCS: |
| TransformationDeclCS | TransformationDefCS |
| ; |
| |
| TransformationDeclCS returns TransformationCS: |
| TransformationHeaderCS ';' |
| ; |
| |
| TransformationDefCS returns TransformationCS: |
| TransformationHeaderCS '{' |
| // (ownedClasses+= ModuleTypeCS)* FIXME Transformation is not a package anymore. Not allowed |
| (ownedProperties+= ModulePropertyCS |
| | ownedOperations+= ModuleOperationCS |
| | ownedAnnotations+= TagCS)* |
| '}' ';'? |
| ; |
| |
| TransformationHeaderCS returns TransformationCS: |
| ownedQualifiers+=TransformationQualifier* |
| 'transformation' name=UnrestrictedName |
| '(' ownedParameters+= ParameterDeclarationCS (',' ownedParameters+= ParameterDeclarationCS)* ')' |
| (ownedModuleUsages+= ModuleUsageCS)* |
| ('refines' ownedRefinedModule = ModuleRefCS)? |
| ; |
| |
| // typedefs are deprecated |
| // TypedefCS: 'typedef' name=Identifier '=' typespec=TypeExpCS ('[' condition=ExpCS ']')? ';'; |
| |
| TypeSelectorCS returns essentialocl::VariableCS: |
| (name=UnrestrictedName ':')? ownedType=TypedRef2CS |
| ; |
| |
| UnitPackageCS returns base::PackageCS: |
| MetamodelCS |
| ; |
| |
| // FIXME review these units and specially the metamodel UnitRefCS |
| UnitRefCS : |
| segment+=Identifier ('.' segment+=Identifier)* |
| ; |
| |
| UnitTypeCS returns base::TypeCS: |
| ModelTypeCS | TransformationCS | LibraryCS |
| ; |