PUMA Library Reference Manual
Loading...
Searching...
No Matches
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.
 
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.
 

Constructor & Destructor Documentation

◆ CVisitor()

Puma::CVisitor::CVisitor ( )
inline

Constructor.

◆ ~CVisitor()

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

Destructor.

Member Function Documentation

◆ abort()

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

Set the aborted state.

Parameters
vTrue for aborted, false for not aborted.

◆ aborted()

bool Puma::CVisitor::aborted ( ) const
inline

Check if the node visiting is aborted.

◆ post_visit()

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::CCSemVisitor, and Puma::CSemVisitor.

◆ pre_visit()

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::CCSemVisitor, and Puma::CSemVisitor.

◆ prune()

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.

◆ pruned()

bool Puma::CVisitor::pruned ( ) const
inline

Check if the visiting the sub-tree is aborted.

◆ visit()

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

Visit the given syntax tree node.

Parameters
nodeThe node to visit.