Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » OCL » Problem with OCL forall primitive
Problem with OCL forall primitive [message #68629] Thu, 12 March 2009 13:36 Go to next message
Olivier BERNARD is currently offline 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 18:19 Go to previous messageGo to next message
Eclipse User
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
>
>
Re: Problem with OCL forall primitive [message #68924 is a reply to message #68770] Mon, 16 March 2009 08:24 Go to previous message
Olivier BERNARD is currently offline Olivier BERNARD
Messages: 12
Registered: July 2009
Junior Member
Ooops ! Shame on me !

-- Olivier
Previous Topic:OCL in Profile
Next Topic:[Announce] MDT OCL 1.3.0M6 is available
Goto Forum:
  


Current Time: Thu Oct 23 06:42:04 GMT 2014

Powered by FUDForum. Page generated in 0.11704 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software