|Re: creating two different target elements from one source element based on its subtypes [message #912815 is a reply to message #912506]
||Fri, 14 September 2012 08:32
| Hugo Bruneliere
Registered: July 2009
noi poi wrote on Thu, 13 September 2012 19:25
i tried simple matched rule but if you put a guard to filter only behavior elements of type state then i cannot access behavior elements of type event.
if i dont put the guard and use helpers then the number of target elements generated are greater. Any help?
As far as I understand, you could simply create two distinct matched rules respectively taking as input pattern State and Event.
Another option is two create two distinct matched rules taking as input pattern Behavior and then checking the actual type (i.e. State and Event, as inheriting from Behavior) in the respective guards.
In this second option, some generalization is possible by defining an abstract matched rule and then using rule inheritance: http://wiki.eclipse.org/ATL/User_Guide_-_The_ATL_Language#Rule_inheritance
Also i dont know why i cant use if statement in my do imperative section of a matched rule. It gives me syntax error??
You have to put a semicolon at the end of each instruction in a "do" section.
However, it is fundamental to understand that the use of imperative sections in ATL has to be restricted to very limited cases. By experience, in a (very) large majority of the cases, using only declarative constructs such as matched rules is possible, simpler and more efficient.
I also wanted to know about iterative target patterns, The ATL user guide tells me that the use of distinct foreach is deprecated. How can i work around it??
As stated in the ATL documentation, the "distinct foreach" construct is deprecated as it can be systematically replaced by the use of lazy (matched) rules.
Powered by FUDForum
. Page generated in 0.02382 seconds