PUMA Library Reference Manual
Puma::CVisitor Class Reference

#include <Puma/CVisitor.h>

+ Inheritance diagram for Puma::CVisitor:

Description

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. More...
 
virtual ~CVisitor ()
 Destructor. More...
 
void abort (bool v=true)
 Set the aborted state. More...
 
void prune (bool v=true)
 Set the pruned state (don't visit the sub-tree). More...
 
bool aborted () const
 Check if the node visiting is aborted. More...
 
bool pruned () const
 Check if the visiting the sub-tree is aborted. More...
 
void visit (CTree *node)
 Visit the given syntax tree node. More...
 
virtual void pre_visit (CTree *node)
 Apply actions before the given node is visited. More...
 
virtual void post_visit (CTree *node)
 Apply actions after the given node is visited. More...
 

Constructor & Destructor Documentation

Puma::CVisitor::CVisitor ( )
inline

Constructor.

virtual Puma::CVisitor::~CVisitor ( )
inlinevirtual

Destructor.

Member Function Documentation

void Puma::CVisitor::abort ( bool  v = true)
inline

Set the aborted state.

Parameters
vTrue for aborted, false for not aborted.
bool Puma::CVisitor::aborted ( ) const
inline

Check if the node visiting is aborted.

virtual void Puma::CVisitor::post_visit ( CTree node)
virtual

Apply actions after the given node is visited.

To be implemented by derived visitors.

Parameters
nodeThe node to visit.

Reimplemented in Puma::CSemVisitor, and Puma::CCSemVisitor.

virtual void Puma::CVisitor::pre_visit ( CTree node)
virtual

Apply actions before the given node is visited.

To be implemented by derived visitors.

Parameters
nodeThe node to visit.

Reimplemented in Puma::CSemVisitor, and Puma::CCSemVisitor.

void Puma::CVisitor::prune ( bool  v = true)
inline

Set the pruned state (don't visit the sub-tree).

Parameters
vTrue for pruned, false for not pruned.
bool Puma::CVisitor::pruned ( ) const
inline

Check if the visiting the sub-tree is aborted.

void Puma::CVisitor::visit ( CTree node)

Visit the given syntax tree node.

Parameters
nodeThe node to visit.