diff options
| author | nsfisis <nsfisis@gmail.com> | 2025-05-04 14:21:40 +0900 |
|---|---|---|
| committer | nsfisis <nsfisis@gmail.com> | 2025-05-04 14:21:40 +0900 |
| commit | 8a323fe3f7a964040c085a67cc8868f07b63bb6a (patch) | |
| tree | dc287b84af4059fc88c838b880971d72ed3db62e | |
| parent | 17db00d6d50c849ad4cf65f434c06ceedc20f97d (diff) | |
| download | P4Dcc-8a323fe3f7a964040c085a67cc8868f07b63bb6a.tar.gz P4Dcc-8a323fe3f7a964040c085a67cc8868f07b63bb6a.tar.zst P4Dcc-8a323fe3f7a964040c085a67cc8868f07b63bb6a.zip | |
support more primitive types
| -rw-r--r-- | main.c | 13 |
1 files changed, 11 insertions, 2 deletions
@@ -650,7 +650,7 @@ AST* parse_continue_stmt(PARSER* p) { } int is_type_token(int token_kind) { - return token_kind == TK_K_INT; + return token_kind == TK_K_INT || token_kind == TK_K_LONG || token_kind == TK_K_CHAR || token_kind == TK_K_VOID; } TYPE* parse_type(PARSER* p) { @@ -658,7 +658,16 @@ TYPE* parse_type(PARSER* p) { if (!is_type_token(t->kind)) { fatal_error("parse_type: unknown type"); } - TYPE* ty = type_new(TK_K_INT); + TYPE* ty = type_new(TY_UNKNOWN); + if (t->kind == TK_K_INT) { + ty->kind = TY_INT; + } else if (t->kind == TK_K_LONG) { + ty->kind = TY_LONG; + } else if (t->kind == TK_K_CHAR) { + ty->kind = TY_CHAR; + } else if (t->kind == TK_K_VOID) { + ty->kind = TY_VOID; + } return ty; } |
