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" />
|
||||
|
|
22
token.cpp
22
token.cpp
|
@ -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
10
token.h
|
@ -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 );
|
||||
|
|
Loading…
Reference in New Issue