From 09a245679c8d01eaec71b22985a9895667280cad Mon Sep 17 00:00:00 2001 From: nsfisis Date: Mon, 1 Sep 2025 23:44:51 +0900 Subject: feat: partially support anonymous structs/unions/enums --- src/token.h | 20 ++++++++------------ 1 file changed, 8 insertions(+), 12 deletions(-) (limited to 'src/token.h') diff --git a/src/token.h b/src/token.h index 7a624fb..72db22b 100644 --- a/src/token.h +++ b/src/token.h @@ -4,7 +4,7 @@ #include "io.h" #include "json.h" -enum TokenKind { +typedef enum { TokenKind_eof, // Only preprocessing phase. @@ -143,35 +143,31 @@ enum TokenKind { TokenKind_star, TokenKind_tilde, TokenKind_xor, -}; -typedef enum TokenKind TokenKind; +} TokenKind; const char* token_kind_stringify(TokenKind k); BOOL is_pp_directive(TokenKind k); // TokenValue is externally tagged by Token's kind. -union TokenValue { +typedef union { const char* string; int integer; -}; -typedef union TokenValue TokenValue; +} TokenValue; -struct Token { +typedef struct { TokenKind kind; TokenValue value; SourceLocation loc; -}; -typedef struct Token Token; +} Token; const char* token_stringify(Token* tok); void token_build_json(JsonBuilder* builder, Token* tok); -struct TokenArray { +typedef struct { size_t len; size_t capacity; Token* data; -}; -typedef struct TokenArray TokenArray; +} TokenArray; void tokens_init(TokenArray* tokens, size_t capacity); void tokens_reserve(TokenArray* tokens, size_t size); -- cgit v1.2.3-70-g09d2