Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » OCL » Reserved keywords?
Reserved keywords? [message #52976] Sat, 15 March 2008 04:41 Go to next message
Stefan Schulze is currently offline Stefan SchulzeFriend
Messages: 70
Registered: July 2009
Member
Hi!

In a testcase I defined an EClass "SomeClass" with the integer-attribute
"attr" and an according EObject with attr=1. I tried to evaluate the query
"SomeClass.allInstances()->select(o|o.attr=1)", but it fails with the
message "token 'attr' is invalid". If I change the attributes name to
"someattr" and the query to
"SomeClass.allInstances()->select(o|o.someattr=1)", everything works fine.
The same issue occures with a variable named "attr".
I guess, "attr" is somehow reserved. Can I find a list with all reserved
keywords anywhere?

Stefan
Re: Reserved keywords? [message #53110 is a reply to message #52976] Mon, 24 March 2008 15:14 Go to previous message
Eclipse UserFriend
Originally posted by: cdamus.ca.ibm.com

Hi, Stefan,

Yes, attr is defined by the OCL specification as a reserved word. I think
it is an anachronism, but the MDT implementation respects it.

You can escape this by enclosing the word in double-quotes:

"attr"

Note, however, that this is a non-standard capability.

The OCL Specification lists reserved words in Section 7.4.9 "Keywords."

You can also find them listed in the OCLKWLexer.g file in the MDT OCL CVS,
in the org.eclipse.ocl.parser package.

HTH,

Christian


Stefan Schulze wrote:

> Hi!
>
> In a testcase I defined an EClass "SomeClass" with the integer-attribute
> "attr" and an according EObject with attr=1. I tried to evaluate the query
> "SomeClass.allInstances()->select(o|o.attr=1)", but it fails with the
> message "token 'attr' is invalid". If I change the attributes name to
> "someattr" and the query to
> "SomeClass.allInstances()->select(o|o.someattr=1)", everything works fine.
> The same issue occures with a variable named "attr".
> I guess, "attr" is somehow reserved. Can I find a list with all reserved
> keywords anywhere?
>
> Stefan
Previous Topic:[Announce] MDT OCL 1.2.0 I200803191800 is available
Next Topic:OCL AuditRule Constraining a String Property
Goto Forum:
  


Current Time: Tue Apr 23 07:05:15 GMT 2024

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

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

Back to the top