Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAdolfo SBH2016-08-26 15:15:06 +0000
committerEd Willink2016-10-22 14:15:43 +0000
commitac2be4a87cb61b60e598a1e486bc2e30987273b4 (patch)
tree4ce78215776a4acb4b5cc89260aeba9390837857
parent80cd60130e67ae7a5da3c571d0e7ea7bd0869d18 (diff)
downloadorg.eclipse.qvtd-ac2be4a87cb61b60e598a1e486bc2e30987273b4.tar.gz
org.eclipse.qvtd-ac2be4a87cb61b60e598a1e486bc2e30987273b4.tar.xz
org.eclipse.qvtd-ac2be4a87cb61b60e598a1e486bc2e30987273b4.zip
[cs2as] - Changes to align with last DSTL generator
-rw-r--r--doc/org.eclipse.qvtd.doc.minioclcs.xtext/model/MiniOCLCS2AS.ocl15
-rw-r--r--doc/org.eclipse.qvtd.doc.minioclcs.xtext/model/MiniOCLCS2ASDisambiguation.ocl4
-rw-r--r--doc/org.eclipse.qvtd.doc.minioclcs.xtext/model/MiniOCLCS2ASHelpers.ocl2
-rw-r--r--doc/org.eclipse.qvtd.doc.minioclcs.xtext/model/MiniOCLCS2ASLookup.ocl15
-rw-r--r--doc/org.eclipse.qvtd.doc.minioclcs.xtext/src/org/eclipse/qvtd/doc/MiniOCLCS.xtext100
5 files changed, 107 insertions, 29 deletions
diff --git a/doc/org.eclipse.qvtd.doc.minioclcs.xtext/model/MiniOCLCS2AS.ocl b/doc/org.eclipse.qvtd.doc.minioclcs.xtext/model/MiniOCLCS2AS.ocl
index bbbf8b755..e36f5fa49 100644
--- a/doc/org.eclipse.qvtd.doc.minioclcs.xtext/model/MiniOCLCS2AS.ocl
+++ b/doc/org.eclipse.qvtd.doc.minioclcs.xtext/model/MiniOCLCS2AS.ocl
@@ -16,7 +16,7 @@ context PackageCS
def : ast() : as::Package[1] =
as::Package {
name = name.toString(), -- FIXME bug 494252
- ownedClasses = classes.ast()->asOrderedSet(), -- FIXME remove asOrderedSet()
+ ownedClasses = classifiers.ast()->asOrderedSet(), -- FIXME remove asOrderedSet()
ownedPackages = packages.ast()->asOrderedSet() -- FIXME remove asOrderedSet()
}
@@ -32,6 +32,9 @@ def : ast() : as::Class[1] =
-- .ast()->asOrderedSet(), -- FIXME remove asOrderedSet()
superClass = if _extends = null then null else ast().lookupClass(_extends) endif
}
+context ClassifierCS
+def : ast () : as::Class[1] =
+ null -- to be overriden
--context InvariantCS
--def : ast() : as::Constraint[1] =
@@ -74,8 +77,12 @@ def : ast() : as::OCLExpression[1] =
invalid -- to be overridden
context CallExpCS
-def : ast() : as::OCLExpression[1] =
- nameExp.ast()
+def : ast() : as::CallExp[1] =
+ navExp.ast()
+
+context NavigationExpCS
+def : ast() : as::CallExp =
+ null -- to be overriden
context NameExpCS
def : ast() : as::OCLExpression[1] =
@@ -106,7 +113,7 @@ def : ast() : as::OCLExpression[1] =
}
else if isVariableExp()
then as::VariableExp {
- referredVariable = ast().lookupVariable(expName.path->first()),
+ referredVariable = ast().lookupVariable(expName.pathElements->first()),
type = ast().oclAsType(as::VariableExp).referredVariable.type
}
else if isPropCallExpWithImplicitSource()
diff --git a/doc/org.eclipse.qvtd.doc.minioclcs.xtext/model/MiniOCLCS2ASDisambiguation.ocl b/doc/org.eclipse.qvtd.doc.minioclcs.xtext/model/MiniOCLCS2ASDisambiguation.ocl
index 81714fa2c..0275fdd0a 100644
--- a/doc/org.eclipse.qvtd.doc.minioclcs.xtext/model/MiniOCLCS2ASDisambiguation.ocl
+++ b/doc/org.eclipse.qvtd.doc.minioclcs.xtext/model/MiniOCLCS2ASDisambiguation.ocl
@@ -8,7 +8,7 @@ package cs
-- FIXME Manually added
context NameExpCS
def : lookupVariableToDisambiguate() : as::Variable =
- oclContainer().oclAsType(CSTrace).ast.lookupVariable(expName.path->first())
+ oclContainer().oclAsType(CSTrace).ast.lookupVariable(expName.pathElements->first())
-- ENDOF manual addition
@@ -28,7 +28,7 @@ def : isPropCallExpWithExplicitSource() : Boolean =
def : isVariableExp() : Boolean =
roundedBrackets = null
and not isNameExpOfACallExpCS()
- and expName.path->size() = 1 -- If using a qualified name, we assume we are looking for a fully qualified property
+ and expName.pathElements->size() = 1 -- If using a qualified name, we assume we are looking for a fully qualified property
and lookupVariableToDisambiguate() <> null
def : isPropCallExpWithImplicitSource() : Boolean =
roundedBrackets = null
diff --git a/doc/org.eclipse.qvtd.doc.minioclcs.xtext/model/MiniOCLCS2ASHelpers.ocl b/doc/org.eclipse.qvtd.doc.minioclcs.xtext/model/MiniOCLCS2ASHelpers.ocl
index 5ef7caaff..f0fa61bb8 100644
--- a/doc/org.eclipse.qvtd.doc.minioclcs.xtext/model/MiniOCLCS2ASHelpers.ocl
+++ b/doc/org.eclipse.qvtd.doc.minioclcs.xtext/model/MiniOCLCS2ASHelpers.ocl
@@ -18,7 +18,7 @@ def : isNameExpOfACallExpCS() : Boolean =
-- in parentCallExpCS <> null and parentCallExpCS.nameExp = self
in if parentCallExpCS = null
then false
- else parentCallExpCS.nameExp = self
+ else parentCallExpCS.navExp = self
endif
endpackage \ No newline at end of file
diff --git a/doc/org.eclipse.qvtd.doc.minioclcs.xtext/model/MiniOCLCS2ASLookup.ocl b/doc/org.eclipse.qvtd.doc.minioclcs.xtext/model/MiniOCLCS2ASLookup.ocl
index d4f044604..a858972ec 100644
--- a/doc/org.eclipse.qvtd.doc.minioclcs.xtext/model/MiniOCLCS2ASLookup.ocl
+++ b/doc/org.eclipse.qvtd.doc.minioclcs.xtext/model/MiniOCLCS2ASLookup.ocl
@@ -102,7 +102,7 @@ def : lookupNamedElement(aPathElementCS : cs::PathElementCS) : NamedElement[?] =
context Package
-
+
def : _lookupQualifiedPackage(pName : String) : Package[?] =
let foundPackage = _lookupPackage(_qualified_env_Package(), pName)
in if foundPackage->isEmpty()
@@ -115,7 +115,7 @@ def : _qualified_env_Package() : lookup::LookupEnvironment =
.addElements(ownedPackages)
def : lookupQualifiedPackage(aPathElementCS : cs::PathElementCS) : Package[?] =
_lookupQualifiedPackage(aPathElementCS.elementName)
-
+
def : _lookupQualifiedClass(cName : String) : Class[?] =
let foundClass = _lookupClass(_qualified_env_Class(), cName)
in if foundClass->isEmpty()
@@ -165,7 +165,7 @@ def : lookupPackage(segments : OrderedSet(cs::PathElementCS)) : Package[?] =
endif
context Class
-
+
def : _lookupQualifiedOperation(oName : String, args : OrderedSet(OCLExpression)) : Operation[?] =
let foundOperation = _lookupOperation(_qualified_env_Operation(), oName, args)
in if foundOperation->isEmpty()
@@ -178,7 +178,7 @@ def : _qualified_env_Operation() : lookup::LookupEnvironment =
.addElements(ownedOperations)
def : lookupQualifiedOperation(aPathElementCS : cs::PathElementCS, args : OrderedSet(OCLExpression)) : Operation[?] =
_lookupQualifiedOperation(aPathElementCS.elementName, args)
-
+
def : _lookupQualifiedProperty(pName : String) : Property[?] =
let foundProperty = _lookupProperty(_qualified_env_Property(), pName)
in if foundProperty->isEmpty()
@@ -382,19 +382,22 @@ def : _unqualified_env_Operation(child : ocl::OclElement) : lookup::LookupEnviro
def : _unqualified_env_Property(child : ocl::OclElement) : lookup::LookupEnvironment =
let superClasses = self->closure(superClass)
- in
-
+ in
parentEnv_Property().nestedEnv()
.addElements(superClasses.ownedProperties)
.nestedEnv()
.addElements(ownedProperties)
def : _exported_env_Operation(importer : ocl::OclElement) : lookup::LookupEnvironment =
+ let superClasses = self->closure(superClass)
+ in
let env = lookup::LookupEnvironment {}
in env
.addElements(ownedOperations)
def : _exported_env_Property(importer : ocl::OclElement) : lookup::LookupEnvironment =
+ let superClasses = self->closure(superClass)
+ in
let env = lookup::LookupEnvironment {}
in env
.addElements(ownedProperties)
diff --git a/doc/org.eclipse.qvtd.doc.minioclcs.xtext/src/org/eclipse/qvtd/doc/MiniOCLCS.xtext b/doc/org.eclipse.qvtd.doc.minioclcs.xtext/src/org/eclipse/qvtd/doc/MiniOCLCS.xtext
index b543e4706..868a5249c 100644
--- a/doc/org.eclipse.qvtd.doc.minioclcs.xtext/src/org/eclipse/qvtd/doc/MiniOCLCS.xtext
+++ b/doc/org.eclipse.qvtd.doc.minioclcs.xtext/src/org/eclipse/qvtd/doc/MiniOCLCS.xtext
@@ -6,15 +6,19 @@ RootCS:
(packages+=PackageCS
| contraints+=ConstraintsDefCS)*
;
-
+
PackageCS:
'package' name=ID '{'
(packages+=PackageCS
- |classes+=ClassCS
+ |classifiers+=ClassifierCS
)*
'}'
;
+ClassifierCS:
+ ClassCS | DatatypeCS
+;
+
ClassCS:
'class' name=ID ('extends' extends=PathNameCS)? '{'
( properties+=PropertyCS
@@ -22,15 +26,26 @@ ClassCS:
'}'
;
+DatatypeCS:
+ 'datatype' name=ID ':' typeName=STRING ';'
+;
+
PropertyCS:
- 'prop' name=ID ':' typeRef=PathNameCS ';'
+ ('attribute' | 'containment' | 'cross_reference')
+ name=ID ':' typeRef=PathNameCS
+ (multiplicity=MultiplicityCS)? ';'
;
+MultiplicityCS:
+ '['
+ (opt?='?' | mult?='*' | (lower=INT '..' (upperInt=INT | upperMult?='*')))
+ ']'
+;
OperationCS:
'op' name=ID
'(' (params+=ParameterCS (','params+=ParameterCS)*)? ')'
':' resultRef=PathNameCS
- '=' body=ExpCS
+ '=' body=ExpCS
';'
;
@@ -59,11 +74,39 @@ LogicExpCS:
;
CallExpCS:
- PrimaryExpCS ({CallExpCS.source=current} op=('.' | '->') nameExp=NameExpCS)*
+ PrimaryExpCS ({CallExpCS.source=current} op=('.' | '->') navExp=NavigationExpCS)*
;
PrimaryExpCS:
- NameExpCS | LiteralExpCS
+ SelfExpCS | NameExpCS | LiteralExpCS | LetExpCS
+;
+
+SelfExpCS:
+ {SelfExpCS} 'self'
+;
+
+NavigationExpCS:
+ LoopExpCS | NameExpCS
+;
+
+LoopExpCS:
+ CollectExpCS | IterateExpCS
+;
+
+CollectExpCS:
+ 'collect' '(' (itVar=IteratorVarCS '|')? exp=ExpCS')'
+;
+
+IteratorVarCS:
+ itName = ID (':' itType=PathNameCS)?
+;
+
+IterateExpCS:
+ 'iterate' '(' itVar=IteratorVarCS ';' accVar=AccVarCS '|' exp=ExpCS ')'
+;
+
+AccVarCS:
+ accName = ID (':' accType=PathNameCS)? '=' accInitExp=ExpCS
;
NameExpCS:
@@ -74,33 +117,58 @@ NameExpCS:
RoundedBracketClauseCS:
{RoundedBracketClauseCS}
'('
- (args+=ExpCS (','args+=ExpCS)* )?
+ (args+=ExpCS (','args+=ExpCS)* )?
')'
;
LiteralExpCS:
- IntLiteralExpCS | StringLiteralExpCS | BooleanLiteralExpCS
+ IntLiteralExpCS | BooleanLiteralExpCS | NullLiteralExpCS | CollectionLiteralExpCS
;
IntLiteralExpCS :
intSymbol=INT
;
-StringLiteralExpCS:
- stringSymbol=STRING
-;
-
BooleanLiteralExpCS:
{BooleanExpCS}
(boolSymbol?='true'
| 'false')
- ;
+;
+
+NullLiteralExpCS:
+ {NullLiteralExpCS}
+ 'null'
+;
+
+enum CollectionKindCS:
+ Collection='Collection'
+;
+
+CollectionLiteralExpCS:
+ kind=CollectionKindCS '{'
+ (parts+=CollectionLiteralPartCS)*
+ '}'
+;
+
+CollectionLiteralPartCS:
+ first=ExpCS
+ ('..' last=ExpCS)?
+;
+
+LetExpCS:
+ 'let' letVars+=LetVarCS (',' letVars+=LetVarCS)*
+ 'in' inExp=ExpCS
+;
+
+LetVarCS:
+ name=ID (':' typeRef=PathNameCS)? '=' initExp=ExpCS
+;
PathNameCS :
- path+=PathElementCS
- ('::'pathElements+=PathElementCS)*
+ pathElements+=PathElementCS
+ ('::'pathElements+=PathElementCS)*
;
PathElementCS:
elementName=ID
-; \ No newline at end of file
+;

Back to the top