next up previous
Next: The CBZ class Up: Terminology and Conventions Previous: Terminology and Conventions

Members of Nodes

Many nodes have fields pointing to children nodes. The fields are named according to the syntactical nature of the child. For example, a loopNode contains an exprNode* (an expression node pointer) referred to by the member function cond(). This expression node is the condition that continues the loop. loopNode also contains a blockNode* referred to by body(). This block (of statements) node contains the loop's body.

Another example is the blockNode, which contains two STL lists of declaration and statement nodes, referred to by decls() and stmts(), respectively. A block is simply whatever declarations and executable statements occur between curly braces in C. blockNode is a subclass of stmtNode (statement node), since a compound statement is a statement.

C-Breeze follows a simple naming convention to provide two kinds of access--destructive and nondestructive--to AST child nodes. In general, for an AST child field named x, there is a nondestructive x() method that returns a pointer to the field, and there is a destructive get_x() method that returns a pointer to the field and fills in the old value with NULL. This second type of accessor is useful to ensure that the AST remains a tree, as it disallows aliasing amongst AST nodes. Note, that these get_ methods are not consistently available, and their incorrect use may unintentionally remove portions of the tree.


next up previous
Next: The CBZ class Up: Terminology and Conventions Previous: Terminology and Conventions
Adam C. Brown 2006-01-26