| /******************************************************************************* |
| * Copyright (c) 2011 E.D.Willink and others. |
| * All rights reserved. This program and the accompanying materials |
| * are made available under the terms of the Eclipse Public License v1.0 |
| * which accompanies this distribution, and is available at |
| * http://www.eclipse.org/legal/epl-v10.html |
| * |
| * Contributors: |
| * E.D.Willink - initial API and implementation |
| *******************************************************************************/ |
| grammar org.eclipse.qvtd.xtext.qvtrelation.QVTrelation with org.eclipse.ocl.xtext.essentialocl.EssentialOCL |
| |
| import "http://www.eclipse.org/emf/2002/Ecore" as ecore |
| import "platform:/resource/org.eclipse.ocl.pivot/model/Pivot.ecore" as pivot |
| 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.qvtd.pivot.qvtbase/model/QVTbase.ecore" as qvtbase |
| import "platform:/resource/org.eclipse.qvtd.pivot.qvtrelation/model/QVTrelation.ecore" as qvtrelation |
| import "platform:/resource/org.eclipse.qvtd.xtext.qvtrelation/model/QVTrelationCS.ecore" |
| |
| TopLevelCS: |
| ownedImports+=UnitCS* |
| ownedTransformations+=TransformationCS* |
| ; |
| |
| //UnitCS: identifier+=[pivot::Element|UnrestrictedName] ('.' identifier+=[pivot::Element|UnrestrictedName])*; |
| |
| CollectionTemplateCS: name=UnrestrictedName? ':' ownedType=CollectionTypeCS |
| '{' (ownedMemberIdentifiers+=(TemplateCS | ElementTemplateCS) |
| (',' ownedMemberIdentifiers+=(TemplateCS | ElementTemplateCS))* |
| '++' ownedRestIdentifier=ElementTemplateCS |
| )? '}'; |
| |
| DefaultValueCS: propertyId=[pivot::Variable|UnrestrictedName] '=' ownedInitExpression=ExpCS ';'; |
| |
| DomainCS: (isCheckonly?='checkonly' | isEnforce?='enforce' | 'replace')? 'domain' modelId=[qvtbase::TypedModel|UnrestrictedName] |
| ownedPattern+=DomainPatternCS (',' ownedPattern+=DomainPatternCS)* |
| ('implementedby' implementedBy=UnrestrictedName)? |
| ('default_values' '{' (ownedDefaultValues+=DefaultValueCS)+ '}')? |
| ';'; |
| |
| DomainPatternCS: ownedTemplate=TemplateCS; |
| |
| ElementTemplateCS: identifier=[pivot::Variable|UnrestrictedName]; |
| |
| KeyDeclCS: 'key' ownedPathName=PathNameCS '{' |
| (propertyIds+=[pivot::Property|UnrestrictedName] |
| | ('opposite' '(' ownedOppositePropertyIds+=PathNameCS ')')) |
| (',' (propertyIds+=[pivot::Property|UnrestrictedName] |
| | ('opposite' '(' ownedOppositePropertyIds+=PathNameCS ')')) |
| )* '}' ';' |
| ; |
| |
| ModelDeclCS: name=UnrestrictedName ':' (metamodelIds+=[pivot::Namespace|UnrestrictedName] |
| | '{' metamodelIds+=[pivot::Namespace|UnrestrictedName] (',' metamodelIds+=[pivot::Namespace|UnrestrictedName])* '}') |
| ; |
| |
| ObjectTemplateCS: name=UnrestrictedName? ':' ownedType=TypedRefCS |
| '{' (ownedPropertyTemplates+=PropertyTemplateCS (',' ownedPropertyTemplates+=PropertyTemplateCS)*)? '}'; |
| |
| ParamDeclarationCS: name=UnrestrictedName ':' ownedType=TypedRefCS; |
| |
| PredicateCS: ownedCondition=ExpCS ';'; |
| |
| PrimitiveTypeDomainCS: 'primitive' 'domain' name=UnrestrictedName ':' ownedType=TypedRefCS ';'; |
| |
| PropertyTemplateCS: (propertyId=[pivot::Property|UnrestrictedName] |
| | ('opposite' '(' ownedOppositePropertyId=PathNameCS ')')) |
| '=' ownedExpression=ExpCSOrTemplateCS; |
| |
| QueryCS: 'query' name=UnrestrictedName |
| '(' (ownedParameters+=ParamDeclarationCS (',' ownedParameters+=ParamDeclarationCS)*)? ')' |
| ':' ownedType=TypedRefCS |
| (';' | '{' ownedExpression=ExpCS '}'); |
| |
| RelationCS: isTop?='top'? isDefault?='default'? 'relation' name=UnrestrictedName |
| ('overrides' overrides=[qvtrelation::Relation|UnrestrictedName])? |
| '{' |
| ownedVarDeclarations+=VarDeclarationCS* |
| (ownedDomains+=DomainCS | ownedDomains+=PrimitiveTypeDomainCS)+ |
| ownedWhen=WhenCS? ownedWhere=WhereCS? |
| '}' |
| ; |
| |
| ScopeNameCS returns base::PathNameCS: |
| ownedPathElements+=FirstPathElementCS '::' (ownedPathElements+=NextPathElementCS '::')*; |
| |
| TemplateCS: (CollectionTemplateCS | ObjectTemplateCS) ('{' ownedGuardExpression=ExpCS '}')?; |
| |
| TransformationCS: 'transformation' ownedPathName=ScopeNameCS? name=UnrestrictedName |
| '(' ownedModelDecls+=ModelDeclCS (',' ownedModelDecls+=ModelDeclCS)* ')' |
| ('extends' extends+=[qvtbase::Transformation|UnrestrictedName] (',' extends+=[qvtbase::Transformation|UnrestrictedName])*)? |
| '{' ownedKeyDecls+=KeyDeclCS* ( ownedRelations+=RelationCS | ownedQueries+=QueryCS )* '}' |
| ; |
| |
| UnitCS returns base::ImportCS: |
| 'import' (name=UnrestrictedName ':')? ownedPathName=URIPathNameCS ('::' isAll?='*')? ';'; |
| |
| VarDeclarationCS: ownedVarDeclarationIds+=VarDeclarationIdCS (',' ownedVarDeclarationIds+=VarDeclarationIdCS)* (':' ownedType=TypedRefCS)? ( '=' ownedInitExpression=ExpCS)? ';'; |
| |
| VarDeclarationIdCS: name=UnrestrictedName; |
| |
| WhenCS returns PatternCS: {PatternCS} 'when' '{' ownedPredicates+=PredicateCS* '}'; |
| |
| WhereCS returns PatternCS: {PatternCS} 'where' '{' ownedPredicates+=PredicateCS* '}'; |
| |
| //<OCLExpressionCS> ::= <PropertyCallExpCS> |
| // | <VariableExpCS> |
| // | <LiteralExpCS> |
| // | <LetExpCS> |
| // | <IfExpCS> |
| // | '(' <OCLExpressionCS> ')' |
| // | <template> |
| // notNameExpressionCS -> templateCS |
| |
| ExpCSOrTemplateCS returns essentialocl::ExpCS: ExpCS | TemplateCS; |
| |
| TypedTypeRefCS returns base::TypedTypeRefCS: ownedPathName=PathNameCS; |
| |
| TypedRefCS returns base::TypedRefCS: |
| (PrimitiveTypeCS ownedMultiplicity=MultiplicityCS?) |
| | (CollectionTypeCS ownedMultiplicity=MultiplicityCS?) |
| | (TypedTypeRefCS ownedMultiplicity=MultiplicityCS?) |
| ; |
| |
| //ExpCS returns essentialocl::ExpCS: |
| // InfixedExpCS |
| //| TemplateCS; |
| |
| UnrestrictedName returns ecore::EString: |
| EssentialOCLUnrestrictedName |
| | 'checkonly' |
| | 'default' |
| | 'default_values' |
| | 'domain' |
| | 'enforce' |
| | 'extends' |
| | 'implementedby' |
| | 'import' |
| | 'library' |
| | 'key' |
| | 'opposite' |
| | 'overrides' |
| | 'primitive' |
| | 'query' |
| | 'relation' |
| | 'replace' |
| | 'top' |
| | 'transformation' |
| | 'when' |
| | 'where' |
| ; |