2007-05-26 08:45:00 +02:00
|
|
|
|
|
|
|
// Internal testing
|
|
|
|
// Tokenize a file and print tokens
|
|
|
|
|
|
|
|
#include <iostream>
|
|
|
|
#include "tokenize.h"
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
|
|
|
|
int main(int argc, char* argv[])
|
|
|
|
{
|
|
|
|
if (argc != 2)
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
tokens = tokens_back = NULL;
|
|
|
|
Tokenize(argv[1]);
|
2007-05-29 08:24:36 +02:00
|
|
|
SimplifyTokenList();
|
2007-05-26 08:45:00 +02:00
|
|
|
|
|
|
|
unsigned int linenr = 0;
|
|
|
|
for (TOKEN *tok = tokens; tok; tok = tok->next)
|
|
|
|
{
|
|
|
|
// Print either a "\n" or a " "
|
|
|
|
if (tok->linenr != linenr)
|
|
|
|
std::cout << "\n";
|
|
|
|
else
|
|
|
|
std::cout << " ";
|
|
|
|
|
|
|
|
std::cout << tok->str;
|
|
|
|
|
|
|
|
linenr = tok->linenr;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// Delete all tokens..
|
2007-05-29 19:12:14 +02:00
|
|
|
DeallocateTokens();
|
2007-05-26 08:45:00 +02:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
|