Project file updated (testtoken.cpp was missing), added TOKEN::printOut() function to help with debugging.
This commit is contained in:
parent
237dc98ea5
commit
cf2262aaf0
|
@ -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" />
|
||||
|
|
20
token.cpp
20
token.cpp
|
@ -20,6 +20,7 @@
|
|||
#include <cstdlib>
|
||||
#include <cstring>
|
||||
#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;
|
||||
}
|
||||
}
|
||||
|
|
8
token.h
8
token.h
|
@ -148,6 +148,14 @@ public:
|
|||
unsigned int varId() const;
|
||||
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 );
|
||||
void previous( TOKEN *previous );
|
||||
|
|
Loading…
Reference in New Issue