Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » ATL » Generate two targets from one source respectively
Generate two targets from one source respectively [message #1726095] Wed, 09 March 2016 14:51 Go to next message
Yi Zhu is currently offline Yi ZhuFriend
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&lt;>)"/>
<Clause clause="Int" pattern="_" expression="fprint_expr$Int&lt;>(out, arg0)"/>
<Extern declaration="fprint_expr$Var: $d2ctype(fprint_expr&lt;>)"/>
<Clause clause="Var" pattern="_" expression="fprint_expr$Var&lt;>(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 Go to previous messageGo to next message
Dennis Wagelaar is currently offline Dennis WagelaarFriend
Messages: 358
Registered: September 2012
Location: Belgium
Senior Member

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
Re: Generate two targets from one source respectively [message #1726134 is a reply to message #1726123] Thu, 10 March 2016 00:11 Go to previous message
Yi Zhu is currently offline Yi ZhuFriend
Messages: 9
Registered: March 2016
Location: Boston
Junior Member
Thank you so much for your reply.

It works perfectly now.


YI ZHU
Previous Topic:Create Tree out of a List
Next Topic:Re: local variables: self=IN!&lt;unnamed&gt;
Goto Forum:
  


Current Time: Fri Apr 27 08:41:24 GMT 2018

Powered by FUDForum. Page generated in 0.02746 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software