OCL def: expressions in the interpreter [message #7159] |
Tue, 20 February 2007 10:15  |
Eclipse User |
|
|
|
Originally posted by: joana.trindade.iese.fraunhofer.de
Hello, everyone,
I have read Christian's article on model integrity with OCL and I've tried
to to extend the interpreter to support "def:" expressions. I've done this
by using the IOCLHelper.define() operation, within the method evaluate()
at OCLConsolePage class. However, when I test the OCL Interpreter with a
def expression, it gives me an OCLParsingException ("Unexpected token").
The syntax I'm using is something like this:
context Type
def: expressionName() : ReturnType =
oclExpression
What is wrong? Is there something I should set prior to use the define()
method?
Thanks in advance,
Joana M. F. Trindade
|
|
|
Re: OCL def: expressions in the interpreter [message #7206 is a reply to message #7159] |
Tue, 20 February 2007 14:26  |
Eclipse User |
|
|
|
Originally posted by: cdamus.ca.ibm.com
Hi, Joana,
The IOCLHelper::define operation expects only the specification of the
attribute or operation and its value (see the javadoc for examples). So,
you want to omit the "context Type def:" part of the text. The OCL helper
API is designed to support parsing constraints embedded in models, in which
the context and the kind of constraint (def in this case) is implied from
the placement of the expression. For definitions it's a little awkward, as
compared to the other constraints (invariants, pre/post conditions, etc.).
Alternatively, if you move to the M5 build, you will be able to use the new
OCL::parse(OCLInput) API to parse a complete context declaration as you
show it below. See the org.eclipse.ocl.ecore.tests.OCLDocumentTest class
and the org.eclipse.ocl.ecore.tests/model/test_constraints.ocl file for an
example of how that works.
HTH,
Christian
Joana M. F. Trindade wrote:
> Hello, everyone,
>
> I have read Christian's article on model integrity with OCL and I've tried
> to to extend the interpreter to support "def:" expressions. I've done this
> by using the IOCLHelper.define() operation, within the method evaluate()
> at OCLConsolePage class. However, when I test the OCL Interpreter with a
> def expression, it gives me an OCLParsingException ("Unexpected token").
>
> The syntax I'm using is something like this:
>
> context Type
> def: expressionName() : ReturnType =
> oclExpression
>
> What is wrong? Is there something I should set prior to use the define()
> method?
>
> Thanks in advance,
> Joana M. F. Trindade
|
|
|
Powered by
FUDForum. Page generated in 0.02617 seconds