TokenStream.h 689 B

123456789101112131415161718192021222324252627282930313233
  1. #ifndef TOKENSTREAM_H
  2. #define TOKENSTREAM_H
  3. #include <vector>
  4. #include "tokenizer/TokenType.h"
  5. class TokenStream final {
  6. public:
  7. TokenStream();
  8. bool hasToken() const;
  9. std::string nextTokenString();
  10. TokenType nextTokenType();
  11. unsigned int nextLine();
  12. std::string nextString();
  13. double nextDouble();
  14. void add(TokenType type, unsigned int line);
  15. void add(TokenType type, unsigned int line, double d);
  16. void add(TokenType type, unsigned int line, const std::string& text);
  17. private:
  18. void write(const void* data, size_t length);
  19. void read(void* data, size_t length);
  20. private:
  21. size_t nextToken;
  22. std::vector<char> bytes;
  23. };
  24. #endif