blob: dfb2db2c6109439fc135481e9ff9f3bcecd80a9c [file] [log] [blame]
<html><head><META http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"><title>4.3.8.&nbsp;Iterate Rule</title><link href="style.css" rel="stylesheet" type="text/css"><meta content="DocBook XSL Stylesheets V1.72.0" name="generator"><link rel="start" href="index.html" title="The VIATRA2 Model Transformation Framework"><link rel="up" href="sec_ASMCompoundRules.html" title="4.3.&nbsp;Compound ASM Rules"><link rel="prev" href="def_ForallRule.html" title="4.3.7.&nbsp;Forall Rule"><link rel="next" href="def_IfRule.html" title="4.3.9.&nbsp;If Rule"></head><body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"><div class="navheader"><table summary="Navigation header" width="100%"><tr><th align="center" colspan="3">4.3.8.&nbsp;Iterate Rule</th></tr><tr><td align="left" width="20%"><a accesskey="p" href="def_ForallRule.html">Prev</a>&nbsp;</td><th align="center" width="60%">4.3.&nbsp;Compound ASM Rules</th><td align="right" width="20%">&nbsp;<a accesskey="n" href="def_IfRule.html">Next</a></td></tr></table><hr></div><div class="sect3" lang="en"><div class="titlepage"><div><div><h4 class="title"><a name="def_IterateRule"></a>4.3.8.&nbsp;Iterate Rule</h4></div></div></div><div class="tip" style="margin-left: 0.5in; margin-right: 0.5in;"><table border="0" summary="Tip: Description"><tr><td valign="top" align="center" rowspan="2" width="25"><img alt="[Tip]" src="images/tip.png"></td><th align="left"><a name="def_IterateRule_Description"></a>Description</th></tr><tr><td valign="top" align="left"><p>
Using an <span class="strong"><strong>iterate rule</strong></span><a name="N119A6" class="indexterm"></a> is a
possible way to manage loop execution in a transformation.
</p></td></tr></table></div><div class="important" style="margin-left: 0.5in; margin-right: 0.5in;"><table border="0" summary="Important: Syntax"><tr><td valign="top" align="center" rowspan="2" width="25"><img alt="[Important]" src="images/important.png"></td><th align="left"><a name="def_IterateRule_Syntax"></a>Syntax</th></tr><tr><td valign="top" align="left"><pre class="programlisting">
IterateRuleAST ::= <span class="token">iterate</span> <a href="def_AsmRuleInvoc.html" title="4.1.2.&nbsp;ASM Rule Invocation">AsmRuleAST</a>
</pre><p>
The <span class="strong"><strong>iterate rule</strong></span> contains a single body ASM rule.
</p></td></tr></table></div><div class="note" style="margin-left: 0.5in; margin-right: 0.5in;"><table border="0" summary="Note: Semantics"><tr><td valign="top" align="center" rowspan="2" width="25"><img alt="[Note]" src="images/note.png"></td><th align="left"><a name="def_IterateRule_Semantics"></a>Semantics</th></tr><tr><td valign="top" align="left"><p>
The <span class="strong"><strong>iterate rule</strong></span> applies its body rule as long as possible, i.e.
until its body fails.
</p></td></tr></table></div><div class="highlights"><a name="def_IterateRule_Remark"></a><p><b>Remark.&nbsp;</b>
A rule can fail in the following situations:
<div class="itemizedlist"><ul type="disc"><li><p>it is the <a href="def_FailRule.html" title="4.2.4.&nbsp;Fail Rule">fail rule</a> itself,
</p></li><li><p>it is the <a href="def_ChooseRule.html" title="4.3.6.&nbsp;Choose Rule">choose rule</a> and no matching is found,
</p></li><li><p>it is a <a href="def_CompoundRule.html" title="4.3.1.&nbsp;Compound Rule">compound rule</a> and an executed contained rule fails.
</p></li></ul></div>
Since the execution of an <a href="def_AsmRuleInvoc.html" title="4.1.2.&nbsp;ASM Rule Invocation">ASM rule</a> does not necessarily fails it can
happen that the <span class="strong"><strong>iterate rule</strong></span> does <span class="emphasis"><em>not terminate</em></span>. It can
be avoided only with careful transformation design.
The <span class="strong"><strong>iterate rule</strong></span> construct combined with a single
<a href="def_ChooseRule.html" title="4.3.6.&nbsp;Choose Rule">choose rule</a>
execution of a GT rule (as its body) applies the GT rule as long as possible,
i.e. as long as a matching of the GT rule can be found by the choose
construct. In other terms, first we apply the GT rule on a single
(non-deterministically selected) matching and only after rule application do we
recompute the next available matching.
As a consequence, the incorrect precondition of the GT rule may cause
<span class="emphasis"><em>non-termination</em></span> when combined with the iterate construct. For
instance, the most typical problem is when a transformation designer does not
prevent to apply the GT rule twice on the same matching (by using an
appropriate negative condition).
</p></div><div class="highlights"><a name="def_IterateRule_DefinedIn"></a><p><b>Defined In:&nbsp;</b>
<a href="def_CompoundRule.html" title="4.3.1.&nbsp;Compound Rule">compound rule</a>
</p></div><div class="highlights"><a name="def_IterateRule_SeeAlso"></a><p><b>See Also:&nbsp;</b>
<a href="def_ForallRule.html" title="4.3.7.&nbsp;Forall Rule">forall rule</a>, <a href="def_ChooseRule.html" title="4.3.6.&nbsp;Choose Rule">choose rule</a>, <a href="def_FailRule.html" title="4.2.4.&nbsp;Fail Rule">fail rule</a>, <a href="def_TryRule.html" title="4.3.10.&nbsp;Try Rule">try rule</a>
</p></div></div><div class="navfooter"><hr><table summary="Navigation footer" width="100%"><tr><td align="left" width="40%"><a accesskey="p" href="def_ForallRule.html">Prev</a>&nbsp;</td><td align="center" width="20%"><a accesskey="u" href="sec_ASMCompoundRules.html">Up</a></td><td align="right" width="40%">&nbsp;<a accesskey="n" href="def_IfRule.html">Next</a></td></tr><tr><td valign="top" align="left" width="40%">4.3.7.&nbsp;Forall Rule&nbsp;</td><td align="center" width="20%"><a accesskey="h" href="index.html">Home</a></td><td valign="top" align="right" width="40%">&nbsp;4.3.9.&nbsp;If Rule</td></tr></table></div></body></html>