Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEd Willink2016-09-10 11:27:17 +0000
committerEd Willink2016-09-19 11:18:37 +0000
commit6f7b176bda2558aaf6bc7c805a501df38569fdf9 (patch)
treeba33085f9e0126609bcaa29677705a77e00cf871
parent777ebb7c5968d6ee2f30009afb9b289c95851d2f (diff)
downloadorg.eclipse.qvtd-6f7b176bda2558aaf6bc7c805a501df38569fdf9.tar.gz
org.eclipse.qvtd-6f7b176bda2558aaf6bc7c805a501df38569fdf9.tar.xz
org.eclipse.qvtd-6f7b176bda2558aaf6bc7c805a501df38569fdf9.zip
[500369] Modify grammar to eliminate ambiguities
-rw-r--r--plugins/org.eclipse.qvtd.xtext.qvtimperative/model/QVTimperativeCS.ecore6
-rw-r--r--plugins/org.eclipse.qvtd.xtext.qvtimperative/model/QVTimperativeCS.genmodel2
-rw-r--r--plugins/org.eclipse.qvtd.xtext.qvtimperative/src/org/eclipse/qvtd/xtext/qvtimperative/QVTimperative.xtext88
3 files changed, 17 insertions, 79 deletions
diff --git a/plugins/org.eclipse.qvtd.xtext.qvtimperative/model/QVTimperativeCS.ecore b/plugins/org.eclipse.qvtd.xtext.qvtimperative/model/QVTimperativeCS.ecore
index 140108476..df7bc1878 100644
--- a/plugins/org.eclipse.qvtd.xtext.qvtimperative/model/QVTimperativeCS.ecore
+++ b/plugins/org.eclipse.qvtd.xtext.qvtimperative/model/QVTimperativeCS.ecore
@@ -118,8 +118,6 @@
<eStructuralFeatures xsi:type="ecore:EAttribute" name="isTransient" eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EBoolean"
defaultValueLiteral="false"/>
</eClassifiers>
- <eClassifiers xsi:type="ecore:EClass" name="RealizeableVariableCS" abstract="true"
- eSuperTypes="../../org.eclipse.ocl.xtext.base/model/BaseCS.ecore#//TypedElementCS"/>
<eClassifiers xsi:type="ecore:EClass" name="NewStatementCS" eSuperTypes="../../org.eclipse.ocl.xtext.base/model/BaseCS.ecore#//TypedElementCS #//StatementCS">
<eStructuralFeatures xsi:type="ecore:EReference" name="ownedInitExpression" eType="ecore:EClass ../../org.eclipse.ocl.xtext.essentialocl/model/EssentialOCLCS.ecore#//ExpCS"
containment="true"/>
@@ -150,8 +148,10 @@
<eStructuralFeatures xsi:type="ecore:EReference" name="ownedDirections" upperBound="-1"
eType="#//DirectionCS" containment="true"/>
</eClassifiers>
- <eClassifiers xsi:type="ecore:EClass" name="UnrealizedVariableCS" eSuperTypes="#//RealizeableVariableCS">
+ <eClassifiers xsi:type="ecore:EClass" name="UnrealizedVariableCS" eSuperTypes="../../org.eclipse.ocl.xtext.base/model/BaseCS.ecore#//TypedElementCS">
<eStructuralFeatures xsi:type="ecore:EReference" name="ownedInitExpression" eType="ecore:EClass ../../org.eclipse.ocl.xtext.essentialocl/model/EssentialOCLCS.ecore#//ExpCS"
containment="true"/>
+ <eStructuralFeatures xsi:type="ecore:EAttribute" name="isConnection" eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EBoolean"
+ defaultValueLiteral="false"/>
</eClassifiers>
</ecore:EPackage>
diff --git a/plugins/org.eclipse.qvtd.xtext.qvtimperative/model/QVTimperativeCS.genmodel b/plugins/org.eclipse.qvtd.xtext.qvtimperative/model/QVTimperativeCS.genmodel
index 480667e67..edfe587f7 100644
--- a/plugins/org.eclipse.qvtd.xtext.qvtimperative/model/QVTimperativeCS.genmodel
+++ b/plugins/org.eclipse.qvtd.xtext.qvtimperative/model/QVTimperativeCS.genmodel
@@ -82,7 +82,6 @@
<genFeatures property="None" children="true" createChild="true" ecoreFeature="ecore:EReference QVTimperativeCS.ecore#//QueryCS/ownedExpression"/>
<genFeatures createChild="false" ecoreFeature="ecore:EAttribute QVTimperativeCS.ecore#//QueryCS/isTransient"/>
</genClasses>
- <genClasses image="false" ecoreClass="QVTimperativeCS.ecore#//RealizeableVariableCS"/>
<genClasses ecoreClass="QVTimperativeCS.ecore#//NewStatementCS">
<genFeatures property="None" children="true" createChild="true" ecoreFeature="ecore:EReference QVTimperativeCS.ecore#//NewStatementCS/ownedInitExpression"/>
<genFeatures property="None" children="true" createChild="true" ecoreFeature="ecore:EReference QVTimperativeCS.ecore#//NewStatementCS/referredTypedModel"/>
@@ -104,6 +103,7 @@
</genClasses>
<genClasses ecoreClass="QVTimperativeCS.ecore#//UnrealizedVariableCS">
<genFeatures property="None" children="true" createChild="true" ecoreFeature="ecore:EReference QVTimperativeCS.ecore#//UnrealizedVariableCS/ownedInitExpression"/>
+ <genFeatures createChild="false" ecoreFeature="ecore:EAttribute QVTimperativeCS.ecore#//UnrealizedVariableCS/isConnection"/>
</genClasses>
</genPackages>
</genmodel:GenModel>
diff --git a/plugins/org.eclipse.qvtd.xtext.qvtimperative/src/org/eclipse/qvtd/xtext/qvtimperative/QVTimperative.xtext b/plugins/org.eclipse.qvtd.xtext.qvtimperative/src/org/eclipse/qvtd/xtext/qvtimperative/QVTimperative.xtext
index 5a67bd262..a821efd2f 100644
--- a/plugins/org.eclipse.qvtd.xtext.qvtimperative/src/org/eclipse/qvtd/xtext/qvtimperative/QVTimperative.xtext
+++ b/plugins/org.eclipse.qvtd.xtext.qvtimperative/src/org/eclipse/qvtd/xtext/qvtimperative/QVTimperative.xtext
@@ -26,20 +26,13 @@ TopLevelCS:
AddStatementCS: 'add' targetVariable=[pivot::Variable|UnrestrictedName] '+=' ownedExpression=ExpCS ';';
-BottomPatternCS: // Bug 466385 explains the redundancy below
- (
- '{' ownedUnrealizedVariables+=UnrealizedVariableCS (',' ownedUnrealizedVariables+=UnrealizedVariableCS)*
- '|' ownedConstraints+=PredicateOrAssignmentCS* '}'
- ) | (
- '{' ownedUnrealizedVariables+=UnrealizedVariableCS (',' ownedUnrealizedVariables+=UnrealizedVariableCS)* '}'
- ) | (
- '{' ownedConstraints+=PredicateOrAssignmentCS+ '}'
- ) | (
- {BottomPatternCS} '{' '}'
- )
+BottomPatternCS:
+ {BottomPatternCS} '{' (ownedUnrealizedVariables+=UnrealizedVariableCS | ownedConstraints+=ConstraintCS)* '}'
;
BottomStatementCS returns StatementCS: NewStatementCS | SetStatementCS;
+
+ConstraintCS returns PredicateOrAssignmentCS: 'check' ownedTarget=ExpCS (':=' ownedInitExpression=ExpCS)? ';';
ControlStatementCS returns MappingStatementCS: AddStatementCS | MappingCallCS | MappingLoopCS;
@@ -49,19 +42,11 @@ DirectionCS: {DirectionCS} name=UnrestrictedName?
;
GuardPatternCS: // Bug 466385 explains the redundancy below
- (
- '(' ownedUnrealizedVariables+=GuardVariableCS (',' ownedUnrealizedVariables+=GuardVariableCS)* '|' ownedPredicates+=PredicateCS* ')'
- ) | (
- '(' ownedUnrealizedVariables+=GuardVariableCS (',' ownedUnrealizedVariables+=GuardVariableCS)* ')'
- ) | (
- '(' ownedPredicates+=PredicateCS+ ')'
- ) | (
- {GuardPatternCS} '(' ')'
- )
+ {GuardPatternCS} '(' (ownedUnrealizedVariables+=GuardVariableCS | ownedUnrealizedVariables+=VariablePredicateCS | ownedPredicates+=PredicateCS)* ')'
;
//Variable := VariableName �:� TypeDeclaration
-GuardVariableCS returns UnrealizedVariableCS: name=UnrestrictedName ':' ownedType=TypeExpCS;
+GuardVariableCS returns UnrealizedVariableCS: ('in'|isConnection?='inout') name=UnrestrictedName ':' ownedType=TypeExpCS ';';
ImportCS returns base::ImportCS:
'import' (name=Identifier ':')? ownedPathName=URIPathNameCS (isAll?='::' '*')? ';';
@@ -82,25 +67,9 @@ MappingIteratorCS returns essentialocl::VariableCS: name=UnrestrictedName (':' o
MiddleDomainCS returns DomainCS:
('{' ('check' checkedProperties+=PathNameCS (',' checkedProperties+=PathNameCS)*)?
('enforce' enforcedProperties+=PathNameCS (',' enforcedProperties+=PathNameCS)*)? '}')?
- ownedGuardPattern=MiddleGuardPatternCS ownedBottomPattern=MiddleBottomPatternCS
+ ownedGuardPattern=GuardPatternCS ownedBottomPattern=BottomPatternCS
;
-MiddleBottomPatternCS returns BottomPatternCS: // Bug 466385 explains the redundancy below
- (
- '{' ownedUnrealizedVariables+=UnrealizedVariableCS (',' ownedUnrealizedVariables+=UnrealizedVariableCS)*
- '|' ownedConstraints+=PredicateOrAssignmentCS* '}'
- ) | (
- '{' ownedUnrealizedVariables+=UnrealizedVariableCS (',' ownedUnrealizedVariables+=UnrealizedVariableCS)* '}'
- ) | (
- '{' ownedConstraints+=PredicateOrAssignmentCS+ '}'
- ) | (
- {BottomPatternCS} '{' '}'
- )
-;
-
-MiddleGuardPatternCS returns GuardPatternCS: GuardPatternCS
-;
-
NamedDomainCS returns DomainCS: isCheck?='check'? isEnforce?='enforce'? direction=[qvtbase::TypedModel|UnrestrictedName]
ownedGuardPattern=GuardPatternCS ownedBottomPattern=BottomPatternCS;
@@ -115,21 +84,11 @@ QualifiedPackageCS returns qvtbasecs::QualifiedPackageCS:
ParamDeclarationCS: name=UnrestrictedName ':' ownedType=TypeExpCS;
-PredicateCS: ownedCondition=ExpCS ';';
-
-//Constraint ::= Predicate | Assignment
-//Predicate ::= BooleanOCLExpr
-//Assignement ::= [�default�] SlotOwnerOCLExpr�.�PropertyName �:=� ValueOCLExpr
-
-PredicateOrAssignmentCS: ownedTarget=ExpCS (':=' ownedInitExpression=ExpCS)? ';';
+PredicateCS: 'check' ownedCondition=ExpCS ';';
QueryCS: isTransient?='transient'? 'query' ownedPathName=ScopeNameCS name=UnrestrictedName
'(' (ownedParameters+=ParamDeclarationCS (',' ownedParameters+=ParamDeclarationCS)*)? ')'
':' ownedType=TypeExpCS (';' | '{' ownedExpression=ExpCS '}');
-//<query> ::= 'query' <PathNameCS>
-// '(' [<paramDeclaration> (',' <paramDeclaration>)*] ')'
-// ':' <TypeCS>
-// (';' | '{' <OCLExpressionCS> '}')
NewStatementCS:
'new' ':' referredTypedModel=[qvtbase::TypedModel|UnrestrictedName] name=UnrestrictedName ':' ownedType=TypeExpCS (':=' ownedInitExpression=ExpCS)?';'
@@ -143,17 +102,7 @@ SetStatementCS: 'set' referredVariable=[pivot::Variable|UnrestrictedName] '.' re
SourceDomainCS returns DomainCS: isCheck?='check' direction=[qvtbase::TypedModel|UnrestrictedName]
('{' ('check' checkedProperties+=PathNameCS (',' checkedProperties+=PathNameCS)*)?
('enforce' enforcedProperties+=PathNameCS (',' enforcedProperties+=PathNameCS)*)? '}')?
- ownedGuardPattern=SourceGuardPatternCS ownedBottomPattern=SourceBottomPatternCS
-;
-
-SourceBottomPatternCS returns BottomPatternCS:
- {BottomPatternCS} '{' (ownedUnrealizedVariables+=UnrealizedVariableCS
- (',' ownedUnrealizedVariables+=UnrealizedVariableCS)*)?
- '}'
-;
-
-SourceGuardPatternCS returns GuardPatternCS:
- {GuardPatternCS} '(' (ownedUnrealizedVariables+=UnrealizedVariableCS (',' ownedUnrealizedVariables+=UnrealizedVariableCS)*)? ')'
+ ownedGuardPattern=GuardPatternCS ownedBottomPattern=BottomPatternCS
;
StatementCS: ControlStatementCS;
@@ -164,29 +113,18 @@ TransformationCS:
TargetDomainCS returns DomainCS: isEnforce?='enforce' direction=[qvtbase::TypedModel|UnrestrictedName]
('{' ('check' checkedProperties+=PathNameCS (',' checkedProperties+=PathNameCS)*)?
('enforce' enforcedProperties+=PathNameCS (',' enforcedProperties+=PathNameCS)*)? '}')?
- ownedGuardPattern=TargetGuardPatternCS ownedBottomPattern=TargetBottomPatternCS
-;
-
-TargetBottomPatternCS returns BottomPatternCS:
- {BottomPatternCS} '{' (ownedUnrealizedVariables+=UnrealizedVariableCS (',' ownedUnrealizedVariables+=UnrealizedVariableCS)*)?
- '}'
-;
-
-TargetGuardPatternCS returns GuardPatternCS:
- {GuardPatternCS} '(' (ownedUnrealizedVariables+=UnrealizedVariableCS (',' ownedUnrealizedVariables+=UnrealizedVariableCS)*)? ')'
+ ownedGuardPattern=GuardPatternCS ownedBottomPattern=BottomPatternCS
;
UnnamedDomainCS returns DomainCS: {DomainCS} ownedGuardPattern=GuardPatternCS ownedBottomPattern=BottomPatternCS;
-//Variable := VariableName �:� TypeDeclaration
-UnrealizedVariableCS: name=UnrestrictedName (':' ownedType=TypeExpCS)? (':=' ownedInitExpression=ExpCS)?;
+UnrealizedVariableCS: ('var'|isConnection?='out') name=UnrestrictedName (':' ownedType=TypeExpCS)? (':=' ownedInitExpression=ExpCS)? ';';
+
+VariablePredicateCS returns UnrealizedVariableCS: 'invar' name=UnrestrictedName (':' ownedType=TypeExpCS)? ':=' ownedInitExpression=ExpCS ';';
UnrestrictedName returns ecore::EString:
EssentialOCLUnrestrictedName
| 'check'
-//| 'creation'
-//| 'default'
-//| 'deletion'
| 'enforce'
| 'import'
| 'imports'

Back to the top