Using Extensions With Tree Productions

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.

tex2html_wrap582

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.

tex2html_wrap584

We can express this same example in ML and in Typol:

tex2html_wrap586

tex2html_wrap588

As a last example, we show that we can describe the double functional, which was deemed impossible in [DJL88, p.46,]:

tex2html_wrap590

with a simple flow of information across the two occurrences of p.



Web page maintained by Didier Parigot
Fri Feb 27 10:05:31 MET 1998