| Index |
The Backtracer Visitor's work consists in printing out a tree view of the parsed symbols. More...
#include "gsp__Visitor.h"
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:
Constructor.
See also:
Destructor.
See also:
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:
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: