#ifndef TOKENIZE_H #define TOKENIZE_H #include #include #include #include using namespace std; enum class TokenType { Type, Identifier, Int, Plus, Minus, DoublePlus, DoubleMinus, DoubleEqual, Star, Slash, Percent, Equal, Semicolon, LParenthese, RParenthese, LCurlyBracket, RCurlyBracket, If, Else }; enum class Type { Int }; using TokenData = variant; struct CodePosition { int line; int column; }; struct Token { TokenType type; TokenData data { }; CodePosition pos; }; class TokenError : public runtime_error { public: explicit TokenError(const string& message, CodePosition pos) : runtime_error(message), pos(pos) {} const CodePosition pos; }; /* Parses a string into a vector of tokens */ vector tokenize(vector str, int initial_line=0); /* Format and print a Token */ void _debug_print_token(Token token); /* Formats a list of tokens and prints it */ void _debug_print_tokens(vector tokens); #endif