4.3.8. Iterate Rule

[Tip]Description

Using an iterate rule is a possible way to manage loop execution in a transformation.

[Important]Syntax
IterateRuleAST ::= iterate AsmRuleAST 

The iterate rule contains a single body ASM rule.

[Note]Semantics

The iterate rule applies its body rule as long as possible, i.e. until its body fails.

Remark.  A rule can fail in the following situations:

Since the execution of an ASM rule does not necessarily fails it can happen that the iterate rule does not terminate. It can be avoided only with careful transformation design. The iterate rule construct combined with a single choose rule 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 non-termination 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).

Defined In:  compound rule

See Also:  forall rule, choose rule, fail rule, try rule