#ifndef LEX_H #define LEX_H #include enum token_type { TOK_NAME, // foo, bar_quux123, loop TOK_LABEL, // 'my_loop TOK_INTEGER, // -123, 16#DEADBEEF TOK_STRING, // "..." TOK_OPERATOR, TOK_OPEN_GROUP, // ( TOK_CLOSE_GROUP, // ) TOK_OPEN_BLOCK, // { TOK_CLOSE_BLOCK, // } TOK_TERMINATOR, // ; TOK_SEPARATOR, // , TOK_EOF, // end of file }; enum operator_ { OP_EQ, // = OP_ADD, // + OP_SUB, // - OP_MUL, // * OP_DIV, // / OP_MOD, // % OP_INV, // ~ OP_AND, // & OP_OR, // | OP_XOR, // ^ OP_SHL, // << OP_SAR, // >> OP_SHR, // >>> OP_NOT, // ! OP_GT, // > OP_LT, // < OP_GTE, // >= OP_LTE, // <= OP_NE, // != OP_TYPE, // : OP_FUN, // -> }; union token_data { char* name; char* label; char* string; int64_t int_; enum operator_ op; }; struct token { enum token_type type; union token_data data; }; struct token lex(void); #endif