Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » OCL » OCL def: expressions in the interpreter
OCL def: expressions in the interpreter [message #7159] Tue, 20 February 2007 15:15 Go to next message
Eclipse UserFriend
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 19:26 Go to previous message
Eclipse UserFriend
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
Previous Topic:diagrams of the metamodel in SVG
Next Topic:def expressions again
Goto Forum:
  


Current Time: Thu Apr 25 11:54:39 GMT 2024

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

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

Back to the top