token_type_t -> Token::Type

Implicit namespacing using the struct
This commit is contained in:
2024-06-01 01:49:24 +01:00
parent f5d8777b7a
commit 83ad8b832b
3 changed files with 150 additions and 153 deletions

View File

@@ -18,66 +18,64 @@
#include <tuple>
#include <vector>
enum class token_type_t
{
PP_CONST, // %const(<symbol>)...
PP_USE, // %use <string>
PP_END, // %end
PP_REFERENCE, // $<symbol>
GLOBAL,
STAR,
LITERAL_NUMBER,
LITERAL_CHAR,
LITERAL_STRING,
NOOP,
HALT,
PUSH,
POP,
PUSH_REG,
MOV,
DUP,
MALLOC,
MALLOC_STACK,
MSET,
MSET_STACK,
MGET,
MGET_STACK,
MDELETE,
MSIZE,
NOT,
OR,
AND,
XOR,
EQ,
LT,
LTE,
GT,
GTE,
PLUS,
SUB,
MULT,
PRINT,
JUMP_ABS,
JUMP_STACK,
JUMP_IF,
CALL,
CALL_STACK,
RET,
SYMBOL,
};
const char *token_type_as_cstr(token_type_t type);
struct Token
{
token_type_t type;
enum class Type
{
PP_CONST, // %const(<symbol>)...
PP_USE, // %use <string>
PP_END, // %end
PP_REFERENCE, // $<symbol>
GLOBAL,
STAR,
LITERAL_NUMBER,
LITERAL_CHAR,
LITERAL_STRING,
NOOP,
HALT,
PUSH,
POP,
PUSH_REG,
MOV,
DUP,
MALLOC,
MALLOC_STACK,
MSET,
MSET_STACK,
MGET,
MGET_STACK,
MDELETE,
MSIZE,
NOT,
OR,
AND,
XOR,
EQ,
LT,
LTE,
GT,
GTE,
PLUS,
SUB,
MULT,
PRINT,
JUMP_ABS,
JUMP_STACK,
JUMP_IF,
CALL,
CALL_STACK,
RET,
SYMBOL,
} type;
size_t column, line;
std::string content;
Token();
Token(token_type_t, std::string, size_t col = 0, size_t line = 0);
Token(Token::Type, std::string, size_t col = 0, size_t line = 0);
};
const char *token_type_as_cstr(Token::Type type);
std::ostream &operator<<(std::ostream &, Token &);
enum class lerr_type_t