|
Re: Entry Point called rule [message #907086 is a reply to message #907043] |
Mon, 03 September 2012 09:10 |
Hugo Bruneliere Messages: 674 Registered: July 2009 |
Senior Member |
|
|
Hello,
Quote:1. i wanted to know about entry point called rule. can the entry point called rule call other called rule which are recursive .
Well i need to navigate the source model first and assign an integer value to each element and store it in a MAP helper and then based on this map helper i need to bind values to the source model in the matched rule.
So i thought of an entry point called rule which will populate the MAP helper since entry point called rule is executed prior to matched rules.
For recursion, you have to implement it by helpers navigating the source model(s).
http://wiki.eclipse.org/ATL/User_Guide_-_The_ATL_Language#ATL_Helpers
If you create an "attribute helper" (your map), it's going to be initialized before any rule is matched.
For example:
helper def : myMap : Map(key_type, value_type) = exp;
So you don't need to use/declare an entry point called rule for this.
Quote:
2. is it necessary for a simple called rule to return something???
Yes, always.
Quote:
3. If the source model element multiplicity is many then can we assign values through a sequence which is returned by a called rule.
for example
rule TextBT {
from
s: IN!TextBT
to
t: OUT!Graph (
type <- 'digraph',
statements <- thismodule.getpcseq(s)
I don't know exactly your metamodel and the details of your transformation, but it is fundamental to understand that ATL has an automated resolution mechanism (resolving target elements created by other matched rules from corresponding source elements).
I.e. if your refer to an element A from your source model in the "to" part of a given matched rule, ATL is going to automatically resolve it by looking to the element B created by the other rule matching this element A.
So you don't have to implement this binding by yourself using a Map or something similar.
In the rare cases you want to refer to another element created by a given matched rule, there is the resolveTemp specific operation that can be called explicitly.
However, most of the times, if your transformation is well-structured, it does not need to be called and the ATL automated resolution mechanism is sufficient.
I hope this helps.
Best regards,
Hugo
--------------------------------------------------------
Hugo Bruneliere, PhD
NaoMod team (IMT Atlantique & LS2N-CNRS)
Nantes - France
--------------------------------------------------------
|
|
|
Powered by
FUDForum. Page generated in 0.02868 seconds