| /******************************************************************************* |
| * 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.qvtimperative.QVTimperative 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.xtext.qvtbase/model/QVTbaseCS.ecore" as qvtbasecs |
| import "platform:/resource/org.eclipse.qvtd.pivot.qvtbase/model/QVTbase.ecore" as qvtbase |
| import "platform:/resource/org.eclipse.qvtd.pivot.qvtimperative/model/QVTimperative.ecore" as qvtimperative |
| import "platform:/resource/org.eclipse.qvtd.xtext.qvtimperative/model/QVTimperativeCS.ecore" |
| |
| TopLevelCS: |
| ownedImports+=ImportCS* |
| (ownedPackages+=QualifiedPackageCS | ownedTransformations+=TransformationCS)* |
| ; |
| |
| AddStatementCS: ('observe' observedProperties+=PathNameCS (',' observedProperties+=PathNameCS)*)? |
| 'add' targetVariable=[qvtimperative::ConnectionVariable|UnrestrictedName] '+=' ownedExpression=ExpCS ';'; |
| |
| AppendParameterBindingCS: referredVariable=[qvtimperative::AppendParameter|UnrestrictedName] 'appendsTo' value=[qvtimperative::ConnectionVariable|UnrestrictedName] ';'; |
| |
| AppendParameterCS: 'append' name=UnrestrictedName ':' ownedType=TypeExpCS ';'; |
| |
| BufferStatementCS: isStrict?='strict'? 'buffer' (':' firstPass=LOWER ('..' lastPass=LOWER)?)? |
| name=UnrestrictedName (':' ownedType=TypeExpCS)? (':=' ownedExpression=ExpCS)? ';' |
| ; |
| |
| CommitStatementCS returns StatementCS: NewStatementCS | SetStatementCS; |
| |
| CheckStatementCS: ('observe' observedProperties+=PathNameCS (',' observedProperties+=PathNameCS)*)? |
| 'check' ownedCondition=ExpCS ';'; |
| |
| ControlStatementCS returns MappingStatementCS: AddStatementCS | MappingCallCS | MappingLoopCS; |
| |
| DeclareStatementCS: ('observe' observedProperties+=PathNameCS (',' observedProperties+=PathNameCS)*)? |
| isCheck?='check'? 'var' name=UnrestrictedName (':' ownedType=TypeExpCS)? ':=' ownedExpression=ExpCS ';'; |
| |
| DirectionCS: {DirectionCS} name=Identifier? |
| ('imports' imports+=[pivot::Package|UnrestrictedName] (',' imports+=[pivot::Package|UnrestrictedName])*)? |
| ; |
| |
| EntryPointCS: {EntryPointCS} isStrict?='strict'? 'entry' (':' targetName=UnrestrictedName)? |
| name=UnrestrictedName |
| ('input' inputTypedModels+=[qvtbase::TypedModel|UnrestrictedName] (',' inputTypedModels+=[qvtbase::TypedModel|UnrestrictedName])*)? |
| ('output' outputTypedModels+=[qvtbase::TypedModel|UnrestrictedName] (',' outputTypedModels+=[qvtbase::TypedModel|UnrestrictedName])*)? |
| '{' |
| ownedParameters+=MappingParameterCS* |
| ownedStatements+=GuardStatementCS* |
| ownedStatements+=CommitStatementCS* |
| ownedStatements+=ControlStatementCS* |
| '}'; |
| |
| GuardParameterBindingCS: isCheck?='check'? referredVariable=[qvtimperative::GuardParameter|UnrestrictedName] 'consumes' value=[qvtimperative::ConnectionVariable|UnrestrictedName] ';'; |
| |
| GuardParameterCS: 'guard' ':' referredTypedModel=[qvtbase::TypedModel|UnrestrictedName] name=UnrestrictedName ':' ownedType=TypeExpCS |
| ('success' successProperty=[pivot::Property|UnrestrictedName])? ';' |
| ; |
| |
| GuardStatementCS returns StatementCS: BufferStatementCS | DeclareStatementCS | DeclareStatementCS | CheckStatementCS | SpeculateStatementCS; |
| |
| ImportCS returns base::ImportCS: |
| 'import' (name=Identifier ':')? ownedPathName=URIPathNameCS (isAll?='::' '*')? ';'; |
| |
| LoopParameterBindingCS: isCheck?='check'? referredVariable=[qvtimperative::GuardParameter|UnrestrictedName] 'iterates' value=[qvtimperative::LoopVariable|UnrestrictedName] ';'; |
| |
| MappingCS: {MappingCS} isStrict?='strict'? 'map' (':' firstPass=LOWER ('..' lastPass=LOWER)?)? |
| name=UnrestrictedName |
| '{' |
| ownedParameters+=MappingParameterCS* |
| ownedStatements+=GuardStatementCS* |
| ownedStatements+=CommitStatementCS* |
| ownedStatements+=ControlStatementCS* |
| '}'; |
| |
| MappingCallCS: {MappingCallCS} ('call'|isInstall?='install'|isInvoke?='invoke') |
| ownedPathName=PathNameCS '{' ownedBindings+=MappingParameterBindingCS* '}'; |
| |
| MappingLoopCS: ('observe' observedProperties+=PathNameCS (',' observedProperties+=PathNameCS)*)? |
| 'for' ownedIterator=MappingIteratorCS 'in' ownedInExpression=ExpCS '{' ownedMappingStatements+=ControlStatementCS+ '}'; |
| |
| MappingIteratorCS returns essentialocl::VariableCS: name=UnrestrictedName (':' ownedType=TypeExpCS)?; |
| |
| MappingParameterBindingCS: AppendParameterBindingCS | GuardParameterBindingCS | LoopParameterBindingCS | SimpleParameterBindingCS; |
| |
| MappingParameterCS: AppendParameterCS | GuardParameterCS | SimpleParameterCS; |
| |
| NewStatementCS: ('observe' observedProperties+=PathNameCS (',' observedProperties+=PathNameCS)*)? |
| isContained?='contained'? 'new' ':' referredTypedModel=[qvtbase::TypedModel|UnrestrictedName] name=UnrestrictedName ':' ownedType=TypeExpCS |
| (':=' ownedExpression=ExpCS)? ';' |
| ; |
| |
| ParamDeclarationCS: name=UnrestrictedName ':' ownedType=TypeExpCS; |
| |
| QualifiedPackageCS returns qvtbasecs::QualifiedPackageCS: |
| 'package' ownedPathName=ScopeNameCS? name=UnrestrictedName (':' nsPrefix=UnrestrictedName)? ('=' nsURI=URI)? |
| (('{' |
| (/* ownedAnnotations+=AnnotationElementCS | */ ownedPackages+=QualifiedPackageCS | ownedClasses+=(ClassCS | TransformationCS))* |
| '}') |
| |';' |
| ) |
| ; |
| |
| QueryCS: isTransient?='transient'? 'query' name=UnrestrictedName |
| '(' (ownedParameters+=ParamDeclarationCS (',' ownedParameters+=ParamDeclarationCS)*)? ')' |
| ':' ownedType=TypeExpCS |
| (';' | ('{' ownedExpression=ExpCS '}') | ('implementedby' implementation=[qvtbasecs::JavaClassCS|SINGLE_QUOTED_STRING] ';')); |
| |
| ScopeNameCS returns base::PathNameCS: |
| ownedPathElements+=FirstPathElementCS '::' (ownedPathElements+=NextPathElementCS '::')*; |
| |
| SetStatementCS: ('observe' observedProperties+=PathNameCS (',' observedProperties+=PathNameCS)*)? |
| (isNotify?='notify')? 'set' referredVariable=[pivot::VariableDeclaration|UnrestrictedName] '.' referredProperty=[pivot::Property|UnrestrictedName] |
| (':=' | isPartial?='+=') ownedExpression=ExpCS ';'; |
| |
| SimpleParameterBindingCS: isCheck?='check'? referredVariable=[qvtimperative::SimpleParameter|UnrestrictedName] 'uses' ownedValue=ExpCS ';'; |
| |
| SimpleParameterCS: 'in' ':' referredTypedModel=[qvtbase::TypedModel|UnrestrictedName] name=UnrestrictedName ':' ownedType=TypeExpCS ';'; |
| |
| SpeculateStatementCS: 'speculate' ownedConditions+=ExpCS (',' ownedConditions+=ExpCS)* ';'; |
| |
| TransformationCS: |
| 'transformation' ownedPathName=ScopeNameCS? name=UnreservedName (':' ownedContextType=TypeExpCS)? |
| '{' (ownedDirections+=DirectionCS ';')* (ownedMappings+=(EntryPointCS | MappingCS) | ownedQueries+=QueryCS)* '}'; |
| |
| QVTimperativeUnrestrictedName: |
| 'add' |
| | 'append' |
| | 'appendsTo' |
| | 'buffer' |
| | 'call' |
| | 'check' |
| | 'contained' |
| | 'entry' |
| | 'for' |
| | 'implementedby' |
| | 'imports' |
| //| 'in' |
| | 'input' |
| | 'install' |
| | 'invoke' |
| | 'iterates' |
| | 'map' |
| | 'new' |
| | 'notify' |
| | 'observe' |
| | 'output' |
| | 'package' |
| | 'query' |
| | 'set' |
| | 'speculate' |
| | 'strict' |
| | 'success' |
| | 'target' |
| | 'transformation' |
| | 'transient' |
| | 'uses' |
| | 'var' |
| | 'via' |
| ; |
| |
| UnrestrictedName returns ecore::EString: |
| EssentialOCLUnrestrictedName |
| | QVTbaseUnrestrictedName |
| | QVTimperativeUnrestrictedName |
| ; |