Namespace tree
, delivered for T5. The implementation of the
intermediate representation. The file tree/README should give
enough explanations to understand how it works.
Reading the corresponding explanations in Appel's book is mandatory.
It is worth noting that contrary to A. Appel, just as we did for
ast
, we use n-ary structures. For instance, where Appel uses a
binary seq
, we have an n-ary seq
which allows us to put as
many statements as we want.
To avoid gratuitous name clashes, what Appel denotes exp
is
denoted sxp
(Statement Expression), implemented in
translate::Sxp
.
Please, pay extra attention to the fact that there are temp::Temp
used to create unique temporaries (similar to symbol::Symbol
),
and tree::Temp
which is the intermediate representation
instruction denoting a temporary (hence a tree::Temp
needs a
temp::Temp
). Similarly, on the one hand, there is
temp::Label
which is used to create unique labels, and on the
other hand there are tree::Label
which is the IR statement to
define to a label, and tree::Name
used to refer to
a label (typically, a tree::Jump
needs a tree::Name
which
in turn needs a temp::Label
).