The basic structure of a node

A node in a child-sibling tree has at least two pointers: one to the child and one to the sibling. These can be called whatever you like, and we'll choose "child" and "sib" for use in this document.

To be useful, the node usually contains other information such as a variable name, a type, or a current value. This information may be filled in and/or modified as needed during different compiler passes.

Eventually, the tree will be walked by a code generator, which will convert the structure and information stored in the tree into output.

Internal nodes have non-NULL child and/or sibling pointers, and form the interior of the tree. They usually correspond to operations or language constructs.

Leaf nodes have NULL child and sibling pointers, and form the exterior of the tree. They usually correspond to variable declarations and references, and constants.

For a variable reference, we might expect the node to contain the variable name, type, dimension, and current value. For a constant, we might expect the node to contain the constant's value and type.


This page was last modified .