Project file updated (testtoken.cpp was missing), added TOKEN::printOut() function to help with debugging.

This commit is contained in:
Reijo Tomperi 2008-12-09 22:03:05 +00:00
parent 237dc98ea5
commit cf2262aaf0
3 changed files with 31 additions and 2 deletions

View File

@ -77,6 +77,7 @@
<Unit filename="testsimplifytokens.cpp" />
<Unit filename="testsuite.cpp" />
<Unit filename="testsuite.h" />
<Unit filename="testtoken.cpp" />
<Unit filename="testtokenize.cpp" />
<Unit filename="testunusedprivfunc.cpp" />
<Unit filename="testunusedvar.cpp" />

View File

@ -19,7 +19,8 @@
#include "token.h"
#include <cstdlib>
#include <cstring>
#include <string>
#include <string>
#include <iostream>
#ifdef __BORLANDC__
#include <ctype.h> // isalpha, isdigit
@ -399,3 +400,22 @@ void TOKEN::linenr( unsigned int linenr )
{
_linenr = linenr;
}
void TOKEN::printOut( const char *title ) const
{
std::cout << std::endl << "###";
if( title )
std::cout << " " << title << " ";
else
std::cout << "########";
std::cout << "###" << std::endl;
for( const TOKEN *t = this; t; t = t->next() )
{
std::cout << t->linenr() << ": " << t->str();
if( t->varId() )
std::cout << " ("<< t->varId() <<")";
std::cout << std::endl;
}
}

10
token.h
View File

@ -146,7 +146,15 @@ public:
unsigned int varId() const;
void varId( unsigned int id );
void varId( unsigned int id );
/**
* For debugging purposes, prints token and all tokens
* followed by it.
* @param title Title for the printout or use default parameter or 0
* for no title.
*/
void printOut( const char *title = 0 ) const;
private:
void next( TOKEN *next );