// demo.cpp Dave Reed 9/30/02 // // This simple program demonstrates the Tokenizer class, which is able to // read tokens (language elements) from an input stream. // // Note: Token.cpp and Tokenizer.cpp must be added to the project. /////////////////////////////////////////////////////////////////////////////// #include #include #include "Tokenizer.h" using namespace std; int main() { Tokenizer program; // reads from cin by default while (program.TokensRemain()) { Token t = program.GetToken(); string ttype; switch (t.GetType()) { case STRING: ttype = "STRING"; break; case INTEGER: ttype = "INTEGER"; break; case IDENTIFIER: ttype = "IDENTIFIER"; break; case KEYWORD: ttype = "KEYWORD"; break; case OPERATOR: ttype = "OPERATOR"; break; case UNKNOWN: ttype = "UNKNOWN"; break; } cout << t.GetValue() << " (" << ttype << ")" << endl; } return 0; }