© R.A. van Engelen, Florida State University, 2000

Ch. 2      Abstract Syntax (cont'd)      (33)

The four constructors are used to compose abstract syntax trees.



For example, consider the program
while E do S1 ; S2
Since the grammar is ambiguous, there are two parse trees for this program.



The ambiguous program can be rendered in two ways

abs1.gif

                                                               abs2.gif

representing the abstract syntax trees. Once an abstract syntax tree has been created, it can be easily manipulated, e.g. by a compiler.