next up previous contents
Next: Other kinds of rules Up: Transformation rules Previous: Addition of edges to

Nested rule groups

Rule groups can be nested. Instead of a predicate in a rule test also a rule groups is allowed. The semantics is that after the (in specification order) last predicate the rule group is evaluated, and then the rule test continues. Thus nested rule groups are generated in the target code at the same place where target predicates are generated.

Nested rule groups can be used to factor out common rule parts. The following rule group with two rules


\begin{examplefoot}\{ RANGE P : Procedure; RULES
LinearBlocks(P,B), Stmts(B,S),...
...tmts(B,S), Expr(S,E),
Object(E,O)
==>
AllObjects(P,O);
\}
\end{examplefoot}

is equivalent to the following consisting of a nested rule group with rule nesting:


\begin{examplefoot}\{ RANGE P : Procedure; RULES
/* common rule part */
Linear...
...> AllExpr(P,E).
Object(E,O) ==> AllObjects(P,O);
}
==> ;
\}
\end{examplefoot}

The difference, however, is speed: the loops over LinearBlocks(P,B), Stmts(B,S), Expr(S,E) are generated twice inthe first example, and once in the second.



Uwe Assmann
1998-12-22