#ifndef TOKENS_H #define TOKENS_H #include #include #include namespace token { enum class Type { Ident, Symbol, LiteralInt, ReturnKeyword, Whitespace, Eof, }; std::string type_name(Type& type); struct Token { Type type; std::string content; std::string formatted(); }; class TokenStream { private: std::vector& m_tokens; public: int m_position; TokenStream(std::vector& tokens); Token peek(int length); Token peek(); Token next(); Token expect(Type type); Token expect(Type type, std::string_view content); }; std::ostream& operator<<(std::ostream& stream, Token& token); std::vector tokenize(std::string_view text); } #endif