Reserved keywords? [message #52976] |
Sat, 15 March 2008 00:41  |
Eclipse User |
|
|
|
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 11:14  |
Eclipse User |
|
|
|
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
|
|
|
Powered by
FUDForum. Page generated in 0.03048 seconds