Index

BacktracerVisitor Class Reference

The Backtracer Visitor's work consists in printing out a tree view of the parsed symbols. More...

#include "gsp__Visitor.h"


Inherited Class(es)


Public Functions

Private Variables


Detailed Description

The Backtracer Visitor's work consists in printing out a tree view of the parsed symbols.

The symbol's backtrace() functions are implemented using this visitor.

See also:

virtual bool gsp::Symbol::backtrace ( std::ostream & os ) = 0 


Functions Documentation

BacktracerVisitor ( std::ostream & os 

Constructor.

See also:

Back to index

~BacktracerVisitor ( )   [  virtual  ] 

Destructor.

See also:

Back to index

bool process ( gsp::Symbol * & rpSymbol   [  virtual  ] 

If the symbol is a non-terminal, prints out its name followed by the BNF description of the reduced rule for this symbol. Only the names of the reduced rule's right-hand symbols are shown. The meta-symbols [ ] and the { } are not shown.

If the symbol is a token, prints out its name followed by its value as it was parsed in the original input stream.

Returns true if the operation was successful, which is normally always the case if the backtraced symbol was initially parsed successfully.

The code executed is the following:

Example:

  if (rpSymbol)
    {
      if (rpSymbol->isToken())
	{
	  rpSymbol->backtrace(m_os);
	}
      else // (rpSymbol->isNonTerminal())
	{
	  if (rpSymbol != rpSymbol->getParent())
	    {
	      gsp::Symbol* pParent = rpSymbol->getParent();
	      gsp::Symbol* pPrevParent = NULL;
	      while (pParent != pPrevParent)
		{
		  m_os << "   ";
		  pPrevParent = pParent;
		  pParent = pParent->getParent();
		}
	      m_os << "|__ ";
	    }
	  m_os << rpSymbol->getSymbolName();
	  m_os << " => ";
	  rpSymbol->outputReducedRule(m_os);
	  m_os << "\n";
	}
      return true;
    }
  else
    {
      return false;
    }

See also:

virtual bool Visitor::process ( gsp::Symbol * & rpSymbol ) = 0 
virtual bool Visitor::process ( const char * c_pszConstant , gsp::Symbol & parent , unsigned long uSymbolRank ) = 0 
Back to index

bool process ( const char * c_pszConstant , gsp::Symbol & parent , unsigned long uSymbolRank   [  virtual  ] 

Constants are not shown during backtracing. They are already shown when the reduced rule is printed out for a backtraced non-terminal.

Returns always true.

The code executed is the following:

Example:

  return true;

See also:

virtual bool Visitor::process ( gsp::Symbol * & rpSymbol ) = 0 
virtual bool Visitor::process ( const char * c_pszConstant , gsp::Symbol & parent , unsigned long uSymbolRank ) = 0 
Back to index


Generated with makedoc.