#pragma once #include "tlibc/std.h" #include "tlibc/string/str.h" #include "tlibc/collections/List.h" typedef enum TokenType { TokenType_Unset, // initial value TokenType_SingleLineComment, // //comment TokenType_MultiLineComment, // /* comment */ TokenType_Instruction, // abc TokenType_Label, // .abc: TokenType_Number, // 0123 TokenType_Char, // 'A' TokenType_String, // "aaaa" TokenType_Name, // xyz TokenType_NamedDataPointer, // @xyz TokenType_NamedDataSize, // #xyz TokenType_OperationEnd, // EOL or EOF or ; } TokenType; str TokenType_toString(TokenType t); typedef struct Token { u32 begin; // some index in Compiler->code u32 length : 24; // length in characters (24 bits) TokenType type : 8; // type of token (8 bits) } Token; List_declare(Token) #define Token_construct(TYPE, BEGIN, LEN) ((Token){ .type = TYPE, .begin = BEGIN, .length = LEN })