next up previous
Next: Changer subclass definitions Up: The AST Level Previous: Invoking a Walker

Changers

Changers let you change the AST in C-Breeze. A changer is a subclass of Changer, which walks the AST, changing nodes as it goes. A changer is similar to a Walker subclass. You define your changer and override the at_-functions of the nodes you're interested in, but your new member functions must now return a Node * ; this is a pointer to the new value you want that node to assume.

Note: You need to be careful what you return from a changer's at_-function; it must ``fit'' in the AST where the old node was. For instance, if you return some sort of expression node from, say, the at_stmt member function, something is going to go wrong because somewhere in the tree there will be an expression node where a statement node belongs.



Subsections

Adam C. Brown 2006-01-26