With classical Attribute Grammars it is not possible to accurately describe the dynamic semantics of a language containing loops (such as a while statement). In this example, we extend a classical production with a scheme that allows the introduction of circularities into the tree. In this scheme, an element in the RHS of the production (the second Expr) is a reference to (the LHS of) the production itself. In the second scheme, we have ``forgotten'' about the loop body, which allows us to avoid specifying and evaluating its attributes.
We now describe part of an interpreter for the while instruction as an Attribute Grammar specification. The attributes $s.env and $h.env contain the execution environment; $c contains the value of the condition.
As a last example, we show that we can describe the double functional, which was deemed impossible in [DJL88, p.46,]: