next up previous
Next: The CBZ class Up: ASTs Previous: Nodes

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 decl_list() and stmt_list(), 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.


next up previous
Next: The CBZ class Up: ASTs Previous: Nodes
Calvin Lin
2002-01-31