Skip to main content



      Home
Home » Modeling » ATL » Generate two targets from one source respectively
Generate two targets from one source respectively [message #1726095] Wed, 09 March 2016 09:51 Go to next message
Eclipse UserFriend
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)"/>

Re: Generate two targets from one source respectively [message #1726123 is a reply to message #1726095] Wed, 09 March 2016 15:26 Go to previous messageGo to next message
Eclipse UserFriend
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
    )
}
Re: Generate two targets from one source respectively [message #1726134 is a reply to message #1726123] Wed, 09 March 2016 19:11 Go to previous message
Eclipse UserFriend
Thank you so much for your reply.

It works perfectly now.
Previous Topic:Create Tree out of a List
Next Topic:Re: local variables: self=IN!&lt;unnamed&gt;
Goto Forum:
  


Current Time: Wed Jul 23 13:37:26 EDT 2025

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

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

Back to the top