Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Archived » M2M (model-to-model transformation) » [ATL} It is possible to have several rules with the same source type?
[ATL} It is possible to have several rules with the same source type? [message #106833] Thu, 18 June 2009 16:28 Go to next message
Eclipse UserFriend
Originally posted by: donwhy.gmail.com

Hi, It is possible to have several matched rules with the same source type?

e.g.:

It is possible to write this:

rule Attributes {
from:
s : Class!Attribute
to
t : Class!Attribute (t.name <- s.name)
}

rule Getter {
from:
s : Class!Attribute
to
t : Class!Method ( t.name <- 'get' + s.name)
}

rule Setter {
from:
s : Class!Attribute
to
t : Class!AttMethodribute (t.name <- 'get' + s.name)
}

Instead of:

rule Attributes {
from:
s : Class!Attribute
to
a: Class!Attribute (a.name <- s.name),

g: Class!Method ( g.name <- 'get' + s.name),

s: Class!AttMethodribute (s.name <- 'get' + s.name)
}

Thanks in advance

John
Re: [ATL} It is possible to have several rules with the same source type? [message #106863 is a reply to message #106833] Fri, 19 June 2009 07:53 Go to previous message
William Piers is currently offline William PiersFriend
Messages: 301
Registered: July 2009
Senior Member
Hello,

John a écrit :
> Hi, It is possible to have several matched rules with the same source type?
>

Yes, but one element can't be matched by more than one matched rule: it
implies that if you have two rules with the same source element, each
must define constraints which are not realized by other rules.

e.g.

from:
s : Class!Attribute (s.isAbstract)

and

from:
s : Class!Attribute (not s.isAbstract)

However, you can use lazy rules instead of matched rules - this will
allow you to create rules with same source pattern and call them when
needed:
http://wiki.eclipse.org/ATL/User_Guide#Lazy_Rules

Best regards,

William

> e.g.:
>
> It is possible to write this:
>
> rule Attributes {
> from:
> s : Class!Attribute
> to
> t : Class!Attribute (t.name <- s.name)
> }
>
> rule Getter {
> from:
> s : Class!Attribute
> to
> t : Class!Method ( t.name <- 'get' + s.name)
> }
>
> rule Setter {
> from:
> s : Class!Attribute
> to
> t : Class!AttMethodribute (t.name <- 'get' + s.name)
> }
>
> Instead of:
>
> rule Attributes {
> from:
> s : Class!Attribute
> to
> a: Class!Attribute (a.name <- s.name),
>
> g: Class!Method ( g.name <- 'get' + s.name),
>
> s: Class!AttMethodribute (s.name <- 'get' + s.name)
> }
>
> Thanks in advance
>
> John
>
Previous Topic:[ATL] - How can I get the result from the amount of abstract classes (ECORE)
Next Topic:Using model already loaded via EMF as source?
Goto Forum:
  


Current Time: Thu Apr 25 02:31:47 GMT 2024

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

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

Back to the top