Looping Structure [message #1233995] |
Mon, 20 January 2014 20:29  |
Eclipse User |
|
|
|
Hi everyone
I checked some manuals and web pages of viatra2, but couldnt find. Do you know we can do a conditional execution or a loop like structure in viatra2?
Like: If ruleA.success; then apply ruleB, else apply ruleC.
OR: (Apply ruleA, then ruleB) -> do this sequence until one fails (or first one fail)?
By the way, I had a 2006 dated manual pdf, do you know a newer version?
[Updated on: Mon, 20 January 2014 20:30] by Moderator
|
|
|
Re: Looping Structure [message #1234269 is a reply to message #1233995] |
Tue, 21 January 2014 10:26  |
Eclipse User |
|
|
|
There are two ASM functions related to repeated execution, forall and iterate. Combining them with try, if and choose will give you a quite powerful language.
Additionally, while GT rules are supported by VIATRA2, you may be better off using ASM rules instead.
For the example you mentioned:
rule ifAthenBelseC() = seq{
try call AthenB(); // if AthenC fails, then C is executed
else call C(); // if C fails, ifAthenBelseC fails as well
}
rule main() = seq{
iterate call ifAthenBelseC(); // ifAthenBelseC is executed repeatedly, until it fails
}
Finally, for a more recent example set, see our Hello World solution for TTC 2011 in the case studies page.
|
|
|
Powered by
FUDForum. Page generated in 0.08581 seconds