Generate two targets from one source respectively [message #1726095] |
Wed, 09 March 2016 14:51 |
Yi Zhu Messages: 9 Registered: March 2016 Location: Boston |
Junior Member |
|
|
Dear All,
I am trying to generate two targets from one source with ATL respectively, the transformed result shows that every clause follows an extern,but I need put all externs together before all clauses. How can I do that? Please help me. Thanks in advanced.
ATL:
rule Pattern2Clause {
from
s : Enumeratives!Pattern
to
t1 : Functions!Extern(
declaration <- s.declarations
),
t2 : Functions!Clause (
clause <- s.constructor,
pattern <- s.patterns,
expression <- s.expressions
)
}
Generated model:
<Extern declaration="fprint_expr$Int: $d2ctype(fprint_expr<>)"/>
<Clause clause="Int" pattern="_" expression="fprint_expr$Int<>(out, arg0)"/>
<Extern declaration="fprint_expr$Var: $d2ctype(fprint_expr<>)"/>
<Clause clause="Var" pattern="_" expression="fprint_expr$Var<>(out, arg0)"/>
YI ZHU
|
|
|
Re: Generate two targets from one source respectively [message #1726123 is a reply to message #1726095] |
Wed, 09 March 2016 20:26 |
|
In ATL, the execution order of rules is not specified, so strictly speaking you cannot rely on it. Ordering of elements is normally achieved by setting the value of a containment reference on the parent element. This normally works, because most EMF models are designed to have a single root element. Since your elements have no parent, and are all roots, you need to find another way.
You can try to use an additional "nodefault" rule, which does not generate a default trace, and can therefore use the same input pattern. In ATL's current implementation, all rules are simply executed in order of appearance:
rule Pattern2Extern {
from
s : Enumeratives!Pattern
to
t1 : Functions!Extern(
declaration <- s.declarations
)
}
nodefault rule Pattern2Clause {
from
s : Enumeratives!Pattern
to
t2 : Functions!Clause (
clause <- s.constructor,
pattern <- s.patterns,
expression <- s.expressions
)
}
Cheers,
Dennis
|
|
|
|
Powered by
FUDForum. Page generated in 0.05237 seconds