Home | Index | universal Index | gsp Index | Examples | Tutorial

BacktracerVisitor Class Reference

#include "gsp__Visitor.h"

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


Inherited Class(es)


Public Functions

BacktracerVisitor ( std::ostream & os 
~BacktracerVisitor ( ) 
  • bool 
process gsp::Symbol * & rpSymbol 
  • bool 
process ( const char * c_pszConstant gsp::Symbol & parent , unsigned long uSymbolRank 

Private Variables

  • std::ostream & 
m_os 

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 


Files Included

#include "universal.h"

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


This file is part of the LLOOP LL Object-Oriented Parser Generator and Object Expander Generator. Copyright (c) 2005-2006 Michel MEHL, France. All rights reserved. LLOOP is distributed by the company ERSA SaRL.


Copyright (c) 2005-2006 Michel MEHL, Haguenau, France
LLOOP version 1.1


Generated with makedoc.