TCPU/src/compiler/token.h
2024-11-21 12:03:53 +05:00

25 lines
630 B
C

#pragma once
#include "../std.h"
typedef enum TokenType {
TokenType_Unset,
TokenType_SingleLineComment,
TokenType_MultiLineComment,
TokenType_Label,
TokenType_Instruction,
TokenType_Argument,
TokenType_Number,
TokenType_Char,
TokenType_String,
} TokenType;
cstr 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;
#define Token_construct(TYPE, BEGIN, END) ((Token){ .type = TYPE, .begin = BEGIN, .length = END })