| /******************************************************************************* |
| * 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.qvtbase.QVTbase 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.xtext.qvtbase/model/QVTbaseCS.ecore" |
| |
| AttributeCS returns base::AttributeCS: |
| ((qualifiers+='static' (qualifiers+='definition')?) | (qualifiers+='definition' (qualifiers+='static')?))? |
| 'attribute' name=UnrestrictedName |
| (':' ownedType=TypedMultiplicityRefCS)? |
| ('=' default=SINGLE_QUOTED_STRING)? |
| ('{'((qualifiers+='derived' | qualifiers+='!derived' | |
| qualifiers+='id' | qualifiers+='!id' | |
| qualifiers+='ordered' | qualifiers+='!ordered' | |
| qualifiers+='readonly' | qualifiers+='!readonly' | |
| qualifiers+='transient' | qualifiers+='!transient' | |
| qualifiers+='unique' | qualifiers+='!unique' | |
| qualifiers+='unsettable' | qualifiers+='!unsettable' | |
| qualifiers+='volatile' | qualifiers+='!volatile' |
| ) ','? )+ |
| '}')? |
| ( ('{' (/*ownedAnnotations+=AnnotationElementCS |
| |*/ ('initial' UnrestrictedName? ':' ownedDefaultExpressions+=SpecificationCS? ';') |
| | ('derivation' UnrestrictedName? ':' ownedDefaultExpressions+=SpecificationCS? ';') )* '}') |
| | ';' |
| ) |
| ; |
| |
| ClassCS returns base::ClassCS: |
| StructuredClassCS | DataTypeCS | EnumerationCS |
| ; |
| |
| CompoundTargetElementCS: '{' ownedTargetElements+=SimpleTargetElementCS* '}' ';'? ; |
| |
| DataTypeCS returns base::DataTypeCS: |
| isPrimitive ?= 'primitive'? 'datatype' name=UnrestrictedName |
| (ownedSignature=TemplateSignatureCS)? |
| (':' instanceClassName=SINGLE_QUOTED_STRING)? |
| ('{' (isSerializable?='serializable' | '!serializable')? '}')? |
| ( ('{' /*(ownedAnnotations+=AnnotationElementCS |
| | ownedConstraints+=InvariantConstraintCS)* */ '}') |
| | ';' |
| ) |
| ; |
| |
| EnumerationCS returns base::EnumerationCS: |
| 'enum' name=UnrestrictedName |
| (ownedSignature=TemplateSignatureCS)? |
| (':' instanceClassName=SINGLE_QUOTED_STRING)? |
| ('{' (isSerializable?='serializable' | '!serializable')? '}')? |
| ( ('{' (/*ownedAnnotations+=AnnotationElementCS |
| |*/ ownedLiterals+=EnumerationLiteralCS |
| /*| ownedConstraints+=InvariantConstraintCS*/)* '}') |
| | ';' |
| ) |
| ; |
| |
| EnumerationLiteralCS returns base::EnumerationLiteralCS: |
| (('literal' name=UnrestrictedName) | name=EnumerationLiteralName) ('=' value=SIGNED)? |
| (('{' /*ownedAnnotations+=AnnotationElementCS* */ '}') |
| |';' |
| ) |
| ; |
| |
| OperationCS returns base::OperationCS: |
| ((qualifiers+='static' (qualifiers+='definition')?) | (qualifiers+='definition' (qualifiers+='static')?))? |
| 'operation' (ownedSignature=TemplateSignatureCS)? name=UnrestrictedName |
| '(' (ownedParameters+=ParameterCS (',' ownedParameters+=ParameterCS)*)? ')' |
| (':' ownedType=TypedMultiplicityRefCS)? |
| ('throws' ownedExceptions+=TypedRefCS (',' ownedExceptions+=TypedRefCS)*)? |
| ('{'((qualifiers+='derived' | qualifiers+='!derived' | |
| qualifiers+='ordered' | qualifiers+='!ordered' | |
| qualifiers+='unique' | qualifiers+='!unique' |
| ) ','? )+ |
| '}')? |
| ( ('{' (/*ownedAnnotations+=AnnotationElementCS |
| | ownedPreconditions+=PreconditionConstraintCS |
| |*/ ('body' UnrestrictedName? ':' ownedBodyExpressions+=SpecificationCS? ';') |
| /*| ownedPostconditions+=PostconditionConstraintCS */ )* '}') |
| | ';' |
| ) |
| ; |
| |
| ParameterCS returns base::ParameterCS: |
| name=UnrestrictedName |
| (':' ownedType=TypedMultiplicityRefCS)? |
| ('{'(( qualifiers+='ordered' | qualifiers+='!ordered' | |
| qualifiers+='unique' | qualifiers+='!unique' |
| ) ','?)+ |
| '}')? |
| ('{' /*ownedAnnotations+=AnnotationElementCS* */ '}')? |
| ; |
| |
| ReferenceCS returns base::ReferenceCS: |
| ((qualifiers+='static' (qualifiers+='definition')?) | (qualifiers+='definition' (qualifiers+='static')?))? |
| 'property' name=UnrestrictedName |
| ('#' referredOpposite=[pivot::Property|UnrestrictedName])? |
| (':' ownedType=TypedMultiplicityRefCS)? |
| ('=' default=SINGLE_QUOTED_STRING)? |
| ('{'((qualifiers+='composes' | qualifiers+='!composes' | |
| qualifiers+='derived' | qualifiers+='!derived' | |
| qualifiers+='ordered' | qualifiers+='!ordered' | |
| qualifiers+='readonly' | qualifiers+='!readonly' | |
| qualifiers+='resolve' | qualifiers+='!resolve' | |
| qualifiers+='transient' | qualifiers+='!transient' | |
| qualifiers+='unique' | qualifiers+='!unique' | |
| qualifiers+='unsettable' | qualifiers+='!unsettable' | |
| qualifiers+='volatile' | qualifiers+='!volatile' |
| ) ','? )+ |
| '}')? |
| ( ('{' (/*ownedAnnotations+=AnnotationElementCS |
| | ('key' referredKeys+=[pivot::Property|UnrestrictedName] (',' referredKeys+=[pivot::Property|UnrestrictedName])* ';') |
| |*/ ('initial' UnrestrictedName? ':' ownedDefaultExpressions+=SpecificationCS? ';') |
| | ('derivation' UnrestrictedName? ':' ownedDefaultExpressions+=SpecificationCS? ';') )* '}') |
| | ';' |
| ) |
| ; |
| |
| SimpleTargetElementCS: (input?='input'|output?='output'|via?='via') typedModel=[qvtbase::TypedModel|UnrestrictedName] |
| ('iterates' (iterates+=[qvtbase::TypedModel|UnrestrictedName] |
| | ('{' (iterates+=[qvtbase::TypedModel|UnrestrictedName] (',' iterates+=[qvtbase::TypedModel|UnrestrictedName])*)? '}')))? |
| ';'; |
| |
| SpecificationCS returns essentialocl::ExpSpecificationCS: |
| ownedExpression=ExpCS | exprString=UNQUOTED_STRING |
| ; |
| |
| StructuredClassCS returns base::StructuredClassCS: |
| isAbstract?='abstract'? |
| 'class' name=UnrestrictedName |
| (ownedSignature=TemplateSignatureCS)? |
| ('extends' ownedSuperTypes+=TypedRefCS (',' ownedSuperTypes+=TypedRefCS)*)? |
| (':' instanceClassName=SINGLE_QUOTED_STRING)? |
| ('{' isInterface?='interface'? |
| '}')? |
| ( ('{' (/*ownedAnnotations+=AnnotationElementCS |
| |*/ ownedOperations+=OperationCS |
| | ownedProperties+=StructuralFeatureCS |
| /*| ownedConstraints+=InvariantConstraintCS*/)* '}') |
| | ';' |
| ) |
| ; |
| |
| TargetCS: 'target' name=UnrestrictedName '{' ownedTargetElements+=(SimpleTargetElementCS|CompoundTargetElementCS)* '}' ';'?; |
| |
| TypedMultiplicityRefCS returns base::TypedRefCS: |
| TypedRefCS (ownedMultiplicity=MultiplicityCS)? |
| ; |
| |
| |
| TypedRefCS returns base::TypedRefCS: |
| TypeLiteralCS | TypedTypeRefCS |
| ; |
| |
| StructuralFeatureCS returns base::StructuralFeatureCS: |
| AttributeCS | ReferenceCS |
| ; |
| |
| EnumerationLiteralName returns ecore::EString: |
| EssentialOCLUnrestrictedName |
| ; |
| |
| QVTbaseUnrestrictedName: |
| 'abstract' |
| | 'attribute' |
| | 'body' |
| | 'class' |
| | 'composes' |
| | 'datatype' |
| | 'definition' |
| | 'derived' |
| | 'derivation' |
| | 'enum' |
| | 'extends' |
| | 'id' |
| | 'initial' |
| | 'interface' |
| | 'literal' |
| | 'operation' |
| | 'ordered' |
| | 'primitive' |
| | 'property' |
| | 'readonly' |
| | 'resolve' |
| | 'serializable' |
| | 'static' |
| | 'throws' |
| | 'transient' |
| | 'unique' |
| | 'unsettable' |
| | 'volatile' |
| ; |
| /* |
| | 'callable' |
| | 'import' |
| | 'key' |
| | 'library' |
| | 'module' |
| | 'package' |
| | 'postcondition' |
| | 'precondition' |
| | 'reference' |
| */ |
| |
| |
| SIGNED returns ecore::EInt: |
| '-'? INT |
| ; |
| |
| terminal UNQUOTED_STRING: // Never forward parsed; just provides a placeholder |
| '£$%^£$%^' // for reverse serialisation of embedded OCL |
| ; |