Home » Modeling » OCL » Problem with OCL forall primitive
Problem with OCL forall primitive [message #68629] 
Thu, 12 March 2009 09:36 
Olivier BERNARD Messages: 12 Registered: July 2009 
Junior Member 


Hi all,
After some days spent in the newsgroups, I could finally make the example
presented in the paper "Implementing Model Integrity in EMF with MDT OCL"
work with Eclipse 3.4.
I extented the example with very simple classes A,B,C just to try to
better understand OCL (I'm new in both OCL & Eclipse):
B,C inherit from A
B has an association "c_list" with C (no containment)
C has attribute
 isOK
 isNotOK, derived as an OCL expression "not isOK" // indeed !
If in the OCL console (very helpful !), I execute:
self.c_list>exists(c  c.isOK)
or self.c_list>exists(c: C  c.isOK)
I get a correct result (i.e. if at least one C object in c_list is Ok, I
get "true").
The problem is with the forall primitive. I copy/paste the previous
command (with exists) and replace "exists" by "forall". I get:
=> self.c_list>forall(c: C  c.isOK)
I get the error message:
": self.c_list>forall(" misplaced construct(s)
If I use the alternative
=> self.c_list>forall(c  c.isOK)
I get the error message:
1:25:1:25 "::" expected instead of ""
Could someone tell me what is wrong ?
 Olivier



Re: Problem with OCL forall primitive [message #68770 is a reply to message #68629] 
Sat, 14 March 2009 14:19 

Originally posted by: give.a.damus.gmail.com
Hi, Olivier,
It looks like you have simply misspelled the forAll iterator: it has a
capital "A."
The confusing error message is caused by the construction of the OCL
grammar: only iterator expressions have vertical bars (""), and the
set of iterators is fixed and know at the grammar level. So, "forall"
was assumed to be an operation, which would not have a bar in it.
HTH,
Christian
Olivier BERNARD wrote:
> Hi all,
>
> After some days spent in the newsgroups, I could finally make the
> example presented in the paper "Implementing Model Integrity in EMF with
> MDT OCL" work with Eclipse 3.4.
> I extented the example with very simple classes A,B,C just to try to
> better understand OCL (I'm new in both OCL & Eclipse):
> B,C inherit from A
> B has an association "c_list" with C (no containment)
>
> C has attribute  isOK
>  isNotOK, derived as an OCL expression "not isOK" // indeed !
>
> If in the OCL console (very helpful !), I execute:
> self.c_list>exists(c  c.isOK)
> or self.c_list>exists(c: C  c.isOK)
>
> I get a correct result (i.e. if at least one C object in c_list is Ok, I
> get "true").
>
> The problem is with the forall primitive. I copy/paste the previous
> command (with exists) and replace "exists" by "forall". I get:
> => self.c_list>forall(c: C  c.isOK)
>
> I get the error message:
> ": self.c_list>forall(" misplaced construct(s)
>
> If I use the alternative
> => self.c_list>forall(c  c.isOK)
>
> I get the error message:
> 1:25:1:25 "::" expected instead of ""
>
> Could someone tell me what is wrong ?
>
>  Olivier
>
>


 
Goto Forum:
Current Time: Fri Jul 25 14:29:57 EDT 2014
Powered by FUDForum. Page generated in 0.01700 seconds
