[ATL] Lazy rules & resolveTemp? [message #103247] |
Thu, 09 April 2009 09:59  |
Eclipse User |
|
|
|
Hello,
I created an ATL transformation that uses lazy rules to implement
recursion over a collection of elements. It creates the new elements in
the appropriate way. However, I cannot get them in the right containment
reference. I tried to use resolveTemp, but this fails.
Can anybody explain me how to get the newly created model elements in the
right containment reference?
Here follows a sketch of my transformation:
rule Transition_split_effect{
from transition_in : slco!Transition
using{s : Sequence(Sequence(slco!Statement)) =
transition_in.splitEffect();
s_head: Sequence(slco!Statement) = s->first();
s_tail: Sequence(Sequence(slco!Statement)) = s->excluding(s_head);
}
to transition_out: slco!Transition(...)
do{...
if s_tail->size() > 1
then thisModule.makeStateAndTransitionRecurse(s_tail)
else thisModule.makeStateAndTransitionEnd(s_tail)
endif;
}
}
lazy rule makeStateAndTransitionRecurse{
from ss_in: Sequence(Sequence(slco!Statement))
using{s_head: Sequence(slco!Statement) = ss_in->first();
s_tail: Sequence(Sequence(slco!Statement)) =
ss_in->excluding(s_head);
}
to t_out: slco!Transition(...),
s_out: slco!State(...)
do{...
if s_tail->size() > 1
then thisModule.makeStateAndTransitionRecurse(s_tail)
else thisModule.makeStateAndTransitionEnd(s_tail)
endif;
}
}
lazy rule makeStateAndTransitionEnd{
from ss_in: Sequence(Sequence(slco!Statement))
to t_out: slco!Transition(...),
s_out: slco!State(...)
}
|
|
|
|
|
Re: [ATL] Lazy rules & resolveTemp? [message #104155 is a reply to message #104076] |
Mon, 27 April 2009 04:20   |
Eclipse User |
|
|
|
Hi,
I am pretty sure of the structure. I solved the problem in another way
using lazy rules.
However, I still have a question regarding lazy rules and resolveTemp that
is very much related to this one.
My transformation builds a state machine. A state machine consists of
states and transitions.
I create a new state and a new transition in a lazy rule. How can I add
the state created in the lazy rule to the set of states of the state
machine and the transition created in the lazy rule to the set of
transitions of the state machine.
The structure is roughly as follows:
rule Class{
from
class_in: slco!Class
to
class_out: slco!Class(
...
stateMachines <- class_in.stateMachines->append(token_server)
),
token_server: slco!StateMachine (
states <- Bag{initial, idle}->union('states generated by the lazy
rule'),
transitions <- Bag{initial_to_idle}->union('transitions generated by
the lazy rule')
),
inital: slco!State(...),
idle: slco!State(...),
initial_to_idle: slco!Transition(...)
}
lazy rule tokenClient(
from sm_in: slco!stateMachine
...
to
s_out: slco!State (...)
...
t_out: slco!Transition(...)
)
For every state machine in 'class_in.stateMachines', the lazy rule should
be called.
How should I call this lazy rule such that the states end up in the bag
containing states and the transitions in the bag containing transitions?
Thanks!
Marcel
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.04599 seconds