Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » OCL » Traversing AST nodes of an OCL constraint programatically
Traversing AST nodes of an OCL constraint programatically [message #1102927] Fri, 06 September 2013 07:52 Go to next message
Amine BENELALLAM is currently offline Amine BENELALLAM
Messages: 13
Registered: January 2013
Junior Member
Hi all,
Can you please point me to an apropriate library or documentation to traverse an OCL abstract tree and return the typedElements tied to each node.
Cheers.
Re: Traversing AST nodes of an OCL constraint programatically [message #1103035 is a reply to message #1102927] Fri, 06 September 2013 10:09 Go to previous messageGo to next message
Ed Willink is currently offline Ed Willink
Messages: 4046
Registered: July 2009
Senior Member
Hi

The pivot OCL AS supports Visitors so you can just visit each node in
turn to determine whatever you want. (The classic OCL AS also supports
Visitors but only on the OCL nodes; not on the Ecore/UML metamodel nodes).

I'm not sure what you mean by TypedElements tied to each node. Some of
the nodes are TypedElement, so maybe you just want to do a generic tree
contents traversal with an instanceof.

Regards

Ed Willink


On 06/09/2013 08:52, Amine BEN wrote:
> Hi all,
> Can you please point me to an apropriate library or documentation to
> traverse an OCL abstract tree and return the typedElements tied to
> each node.
> Cheers.
>
Re: Traversing AST nodes of an OCL constraint programatically [message #1103057 is a reply to message #1103035] Fri, 06 September 2013 10:39 Go to previous messageGo to next message
Amine BENELALLAM is currently offline Amine BENELALLAM
Messages: 13
Registered: January 2013
Junior Member
Thank you Ed,

I want to mark all the attributes that are involved in an OCL constraint (attributes' name are fine for me ). For instance, in the following invariant the involved attributes are isMarried : EBoolean and age : EInt
Context Person
inv canMarry : self.isMarried implies self.age >18

N.B : I am working with the classical OCL

[Updated on: Fri, 06 September 2013 10:43]

Report message to a moderator

Re: Traversing AST nodes of an OCL constraint programatically [message #1103083 is a reply to message #1103057] Fri, 06 September 2013 11:07 Go to previous messageGo to next message
Ed Willink is currently offline Ed Willink
Messages: 4046
Registered: July 2009
Senior Member
Hi

So do a tree search for all PropertyCallExp and gather the
referredProperty values.

Regards

Ed Willink


On 06/09/2013 11:39, Amine BEN wrote:
> I want to mark all the attributes that are involved in an OCL
> constraint (attributes' name are fine for me ). For instance, in the
> following invariant the involved attributes are isMarried : EBoolean
> and age : EInt Context Person
> inv canMarry : self.isMarried implies self.age >18
>
> N.B : I am working with the classical OCL
Re: Traversing AST nodes of an OCL constraint programatically [message #1103090 is a reply to message #1103083] Fri, 06 September 2013 11:16 Go to previous message
Amine BENELALLAM is currently offline Amine BENELALLAM
Messages: 13
Registered: January 2013
Junior Member
That's what I am doing !
Thank you for your help I appreciate it !
Previous Topic:Checking OCL programmatically
Next Topic:Validating OCL in EMF - RCP
Goto Forum:
  


Current Time: Thu Sep 18 16:02:54 GMT 2014

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

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