Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » ATL » Entry Point called rule
Entry Point called rule [message #907043] Mon, 03 September 2012 03:45 Go to next message
noi poi is currently offline noi poi
Messages: 29
Registered: June 2012
Junior Member
Hey there!
I am new to the ATL and i have 3 questions
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.

2. is it necessary for a simple called rule to return something???

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)Wink

now inthis getpcseq() is a called rule that returns a sequence of strings. and statements is an attribute of graph with multplicity of 1 or many .

Thanks in advance
Re: Entry Point called rule [message #907086 is a reply to message #907043] Mon, 03 September 2012 05:10 Go to previous message
Hugo Bruneliere is currently offline Hugo Bruneliere
Messages: 588
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 - R&D Engineer
AtlanMod research team (Inria, EMN & LINA)
Ecole des Mines de Nantes
Nantes - France
------------------------------------------
Previous Topic:Milan Milanovic's code running problem
Next Topic:Reference Attributes in XMI
Goto Forum:
  


Current Time: Sun Apr 20 02:53:59 EDT 2014

Powered by FUDForum. Page generated in 0.01667 seconds