/* * TokenStream.h * * Created on: Feb 8, 2010 * Author: petergoodman * Version: $Id$ */ #ifndef TOKENGENERATOR_H_ #define TOKENGENERATOR_H_ #include #include #include #include #include #include "Token.h" #include "ParseError.h" using namespace std; struct TokenGenerator { struct iterator : std::iterator { explicit iterator(string::iterator begin, string::iterator end) throw(ParseError); ~iterator(); // iterator interface reference operator*(); iterator &operator++ (); iterator operator++ (int); bool operator!=(const iterator& other); bool operator==(const iterator& other); private: // make things happen string::iterator it; string::iterator it_end; bool at_end; Token *curr; bool generateNext() throw(ParseError); Token *parseIntLiteral(); Token *parseStringLiteral(); Token *parseAlphaNumName(const Token::Type type); Token *parseOperator(); }; // operations TokenGenerator(const string &s = ""); ~TokenGenerator(); void assign(const string &s); // iterators iterator begin() throw(ParseError); iterator end() throw(ParseError); private: static const string operators; string str; }; #endif /* TOKENGENERATOR_H_ */