// Tokenizer.h Dave Reed 9/30/03 // // Tokenizer class -- used to read tokens (language elements) // Note: utilizes the Token class from Token.h // // constructor: create a Tokenizer connected to an input file // e.g., Tokenizer program("prog1.txt"); // // public member functions: // bool TokensRemain(); // returns true if tokens remain to be read // Token GetToken(); // returns next token from input stream // Token PeekAhead(); // returns next token without reading it ///////////////////////////////////////////////////////////////////////////////// #ifndef _TOKENIZER_ #define _TOKENIZER_ #include #include #include "Token.h" using namespace std; class Tokenizer { public: Tokenizer(const string & filename); bool TokensRemain() const; Token GetToken(); Token PeekAhead() const; private: Token nextToken; ifstream ifstr; bool remaining; bool ReadToken(Token & t); }; #endif