Puma Reference Manual Puma: Puma::CVisitor Class Reference



Puma::CVisitor Class Reference

Tree visitor implementation for CTree based syntax trees. More...

#include <Puma/CVisitor.h>

Inherited by Puma::CCSemVisitor [private], Puma::CPrintVisitor [private], Puma::CSemVisitor [private], and Puma::CTreeMatcher.

List of all members.

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.

Detailed 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.


Constructor & Destructor Documentation

Puma::CVisitor::CVisitor (  )  [inline]

Constructor.

virtual Puma::CVisitor::~CVisitor (  )  [inline, virtual]

Destructor.


Member Function Documentation

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

Set the aborted state.

Parameters:
v True 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:
node The node to visit.

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

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

Apply actions before the given node is visited.

To be implemented by derived visitors.

Parameters:
node The node to visit.

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

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

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

Parameters:
v True 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:
node The node to visit.



Puma Reference Manual. Created on 11 Sep 2009.