PUMA Library Reference Manual
|
#include <Puma/CVisitor.h>
Tree visitor implementation for CTree based syntax trees.
To be derived for visiting concrete syntax trees.
This class performs depth-first tree-traversal based on CTree tree structures. The traversal is started by calling CVisitor::visit() with the root node of the tree to traverse as its argument. For every node of the tree CVisitor::pre_visit() is called before its child nodes are visited, and CVisitor::post_visit() is called after its child nodes are visited. To perform actions on the visited nodes, CVisitor::pre_visit() and CVisitor::post_visit() have to be overloaded.
Public Member Functions | |
CVisitor () | |
Constructor. | |
virtual | ~CVisitor () |
Destructor. | |
void | abort (bool v=true) |
Set the aborted state. | |
void | prune (bool v=true) |
Set the pruned state (don't visit the sub-tree). | |
bool | aborted () const |
Check if the node visiting is aborted. | |
bool | pruned () const |
Check if the visiting the sub-tree is aborted. | |
void | visit (CTree *node) |
Visit the given syntax tree node. | |
virtual void | pre_visit (CTree *node) |
Apply actions before the given node is visited. | |
virtual void | post_visit (CTree *node) |
Apply actions after the given node is visited. | |
|
inline |
Constructor.
|
inlinevirtual |
Destructor.
|
inline |
Set the aborted state.
v | True for aborted, false for not aborted. |
|
inline |
Check if the node visiting is aborted.
|
virtual |
Apply actions after the given node is visited.
To be implemented by derived visitors.
node | The node to visit. |
Reimplemented in Puma::CCSemVisitor, and Puma::CSemVisitor.
|
virtual |
Apply actions before the given node is visited.
To be implemented by derived visitors.
node | The node to visit. |
Reimplemented in Puma::CCSemVisitor, and Puma::CSemVisitor.
|
inline |
Set the pruned state (don't visit the sub-tree).
v | True for pruned, false for not pruned. |
|
inline |
Check if the visiting the sub-tree is aborted.
void Puma::CVisitor::visit | ( | CTree * | node | ) |
Visit the given syntax tree node.
node | The node to visit. |