| /******************************************************************************* |
| * Copyright (c) 2011 Willink Transformations 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: |
| * E.D.Willink - initial API and implementation |
| *******************************************************************************/ |
| grammar org.eclipse.qvtd.xtext.qvtcore.QVTcore with org.eclipse.qvtd.xtext.qvtbase.QVTbase |
| |
| 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.xtext.qvtbase/model/QVTbaseCS.ecore" as qvtbasecs |
| import "platform:/resource/org.eclipse.qvtd.pivot.qvtcore/model/QVTcore.ecore" as qvtcore |
| import "platform:/resource/org.eclipse.qvtd.xtext.qvtcore/model/QVTcoreCS.ecore" |
| |
| TopLevelCS: |
| ownedImports+=ImportCS* |
| (ownedPackages+=QualifiedPackageCS | ownedTransformations+=TransformationCS | ownedMappings+=MappingCS | ownedQueries+=QueryCS)* |
| ; |
| |
| BottomPatternCS: // Bug 466385 explains the redundancy below |
| ( |
| '{' (ownedUnrealizedVariables+=UnrealizedVariableCS | ownedRealizedVariables+=RealizedVariableCS) |
| (',' (ownedUnrealizedVariables+=UnrealizedVariableCS | ownedRealizedVariables+=RealizedVariableCS))* |
| '|' ownedConstraints+=PredicateOrAssignmentCS* '}' |
| ) | ( |
| '{' (ownedUnrealizedVariables+=UnrealizedVariableCS | ownedRealizedVariables+=RealizedVariableCS) |
| (',' (ownedUnrealizedVariables+=UnrealizedVariableCS | ownedRealizedVariables+=RealizedVariableCS))* '}' |
| ) | ( |
| '{' ownedConstraints+=PredicateOrAssignmentCS+ '}' |
| ) | ( |
| {BottomPatternCS} '{' '}' |
| ) |
| ; |
| |
| DirectionCS: {DirectionCS} name=Identifier? |
| 'imports' imports+=[pivot::Package|UnrestrictedName] (',' imports+=[pivot::Package|UnrestrictedName])* |
| ('uses' uses+=[qvtbase::TypedModel|UnrestrictedName] (',' uses+=[qvtbase::TypedModel|UnrestrictedName])*)? |
| ; |
| |
| //EnforcementOperationCS: ('creation'|'deletion') ExpCS ';'; |
| |
| GuardPatternCS: // Bug 466385 explains the redundancy below |
| ( |
| '(' ownedUnrealizedVariables+=GuardVariableCS (',' ownedUnrealizedVariables+=GuardVariableCS)* '|' ownedPredicates+=PredicateCS* ')' |
| ) | ( |
| '(' ownedUnrealizedVariables+=GuardVariableCS (',' ownedUnrealizedVariables+=GuardVariableCS)* ')' |
| ) | ( |
| '(' ownedPredicates+=PredicateCS+ ')' |
| ) | ( |
| {GuardPatternCS} '(' ')' |
| ) |
| ; |
| |
| //Variable := VariableName �:� TypeDeclaration |
| GuardVariableCS returns UnrealizedVariableCS: name=UnrestrictedName ':' ownedType=TypeExpCS; |
| |
| ImportCS returns base::ImportCS: |
| 'import' (name=Identifier ':')? ownedPathName=URIPathNameCS (isAll?='::' '*')? ';'; |
| |
| MappingCS: {MappingCS} isAbstract?='abstract'? 'map' name=UnrestrictedName? ('in' ownedInPathName=PathNameCS)? |
| ('refines' refines+=[qvtcore::Mapping|UnrestrictedName] (',' refines+=[qvtcore::Mapping|UnrestrictedName])*)? |
| '{' ownedDomains+=NamedDomainCS* ('where' ownedMiddle=UnnamedDomainCS)? ownedComposedMappings+=MappingCS* '}'; |
| |
| NamedDomainCS returns DomainCS: isCheck?='check'? isEnforce?='enforce'? direction=[qvtbase::TypedModel|UnrestrictedName] |
| ownedGuardPattern=GuardPatternCS ownedBottomPattern=BottomPatternCS; |
| |
| QualifiedPackageCS returns qvtbasecs::QualifiedPackageCS: |
| 'package' ownedPathName=ScopeNameCS? name=UnrestrictedName (':' nsPrefix=UnrestrictedName)? ('=' nsURI=URI)? |
| (('{' |
| (/* ownedAnnotations+=AnnotationElementCS | */ ownedPackages+=QualifiedPackageCS | ownedClasses+=(ClassCS | TransformationCS))* |
| '}') |
| |';' |
| ) |
| ; |
| |
| ParamDeclarationCS: name=UnrestrictedName ':' ownedType=TypeExpCS; |
| |
| PredicateCS: ownedCondition=ExpCS ';'; |
| |
| //Constraint ::= Predicate | Assignment |
| //Predicate ::= BooleanOCLExpr |
| //Assignement ::= [�default�] SlotOwnerOCLExpr�.�PropertyName �:=� ValueOCLExpr |
| PredicateOrAssignmentCS: isDefault?='default'? ownedTarget=ExpCS ((':=' | isPartial?='+=') ownedInitExpression=ExpCS)? ';'; |
| |
| QueryCS: isTransient?='transient'? 'query' ownedPathName=ScopeNameCS name=UnrestrictedName |
| '(' (ownedParameters+=ParamDeclarationCS (',' ownedParameters+=ParamDeclarationCS)*)? ')' |
| ':' ownedType=TypeExpCS |
| (';' | ('{' ownedExpression=ExpCS '}') | ('implementedby' implementation=[qvtbasecs::JavaClassCS|SINGLE_QUOTED_STRING] ';')); |
| //<query> ::= 'query' <PathNameCS> |
| // '(' [<paramDeclaration> (',' <paramDeclaration>)*] ')' |
| // ':' <TypeCS> |
| // (';' | '{' <OCLExpressionCS> '}') |
| |
| ScopeNameCS returns base::PathNameCS: |
| ownedPathElements+=FirstPathElementCS '::' (ownedPathElements+=NextPathElementCS '::')*; |
| |
| TransformationCS: |
| 'transformation' ownedPathName=ScopeNameCS? name=UnreservedName '{' (ownedDirections+=DirectionCS ';')* ownedTargets+=TargetCS* ownedProperties+=StructuralFeatureCS* '}'; |
| |
| //Variable := VariableName �:� TypeDeclaration |
| UnrealizedVariableCS: name=UnrestrictedName (':' ownedType=TypeExpCS)? (':=' ownedInitExpression=ExpCS)?; |
| |
| //RealizedVariable := �realized� VariableName �:� TypeDeclaration |
| RealizedVariableCS: 'realize' name=UnrestrictedName ':' ownedType=TypeExpCS; |
| |
| UnnamedDomainCS returns DomainCS: {DomainCS} ownedGuardPattern=GuardPatternCS ownedBottomPattern=BottomPatternCS; |
| |
| QVTcoreUnrestrictedName: |
| 'abstract' |
| | 'check' |
| | 'enforce' |
| | 'implementedby' |
| | 'import' |
| | 'imports' |
| | 'input' |
| | 'iterates' |
| | 'map' |
| | 'output' |
| | 'package' |
| | 'query' |
| | 'realize' |
| | 'refines' |
| | 'target' |
| | 'transformation' |
| | 'transient' |
| | 'uses' |
| | 'via' |
| //| 'where' |
| ; |
| //| 'creation' |
| //| 'deletion' |
| //| 'include' |
| //| 'library' |
| |
| UnrestrictedName returns ecore::EString: |
| EssentialOCLUnrestrictedName |
| | QVTbaseUnrestrictedName |
| | QVTcoreUnrestrictedName |
| ; |
| |