[ATL] how to define multiples guards in from clause of a rule ? [message #38220] |
Tue, 15 May 2007 16:45 |
Eclipse User |
|
|
|
Originally posted by: sylvain.maillard.univ-nantes.fr
Hi again,
I have a little problem: I can do this:
rule elements {
from
e1 : MMa!Element,
e2 : MMA!Element (
e1.elements->includes(e2)
)
to etc.....
but not this
rule elements {
from
e2 : MMA!Element (
e1.elements->includes(e2)
),
e1 : MMa!Element
to etc.....
The file can't be compiled in the second case. It is also impossible to
add another condition on the second element. It says that the ',' is
not expected.
Is there a raison for that ?
Sylvain
--
Sylvain
|
|
|
Re: [ATL] how to define multiples guards in from clause of a rule ? [message #38291 is a reply to message #38220] |
Tue, 15 May 2007 16:55 |
Frédéric Jouault Messages: 572 Registered: July 2009 |
Senior Member |
|
|
Hello,
> I have a little problem: I can do this:
>
> rule elements {
> from
> e1 : MMa!Element,
> e2 : MMA!Element (
> e1.elements->includes(e2)
> )
> to etc.....
>
> but not this
>
> rule elements {
> from
> e2 : MMA!Element (
> e1.elements->includes(e2)
> ),
> e1 : MMa!Element
> to etc.....
>
> The file can't be compiled in the second case. It is also impossible to
> add another condition on the second element. It says that the ',' is not
> expected.
As Marcos pointed out in the following post:
http://www.eclipse.org/newsportal/article.php?id=429&gro up=eclipse.modeling.m2m#429
there should be only one guard, which comes after all the source elements.
> Is there a raison for that ?
http://en.wikipedia.org/wiki/K.I.S.S.
You may add as many conditions using the Boolean "and" operator,
therefore it is not necessary to have a distinct guard per element ;-).
Moreover, in your case you use e1 and e2 in your condition. Therefore,
it does not even apply to e2 only, and it makes sense to write it after
having defined both e1 and e2.
Best regards,
Frédéric Jouault
|
|
|
Powered by
FUDForum. Page generated in 0.01797 seconds