diff options
author | metamuffin <metamuffin@disroot.org> | 2025-06-28 03:08:04 +0200 |
---|---|---|
committer | metamuffin <metamuffin@disroot.org> | 2025-06-28 03:08:04 +0200 |
commit | 06bf61c38929060704e65855bf35b7e6004eb72c (patch) | |
tree | 1e259be9c6a12aebc5787bb660cabf7f59010a64 | |
parent | fbb4db921ec1cb59c9264aab78d4dd3a7ef6d030 (diff) | |
download | attocc-master.tar attocc-master.tar.bz2 attocc-master.tar.zst |
-rw-r--r-- | attocc.c | 26 |
1 files changed, 24 insertions, 2 deletions
@@ -663,6 +663,8 @@ struct global_context { char **enums; }; +struct function_context {}; + int gcx_find_enum(struct global_context *gcx, char *name) { for (int i = 0; i < gcx->num_enums; i++) if (strlen(gcx->enums[i]) == strlen(name) && @@ -735,6 +737,8 @@ int enum_decl(struct global_context *gcx, struct token_iter *iter, int read_type(struct global_context *gcx, struct token_iter *iter, struct token *a, struct type *ty) { + ty->pointer_level = 0; + if (a->kind != TOK_KEYWORD) return 1; if (a->data.keyword == KW_STRUCT) { @@ -815,8 +819,26 @@ int function_decl(struct global_context *gcx, struct token_iter *iter, fprintf(stderr, "expected lcurly after function head\n"); return 1; } - if (token_step(iter, a)) // lcurly - return 1; + + while (1) { + if (a->kind == TOK_SEPERATOR && a->data.seperator == SEP_RCURLY) + break; + struct type type; + int res = read_type(gcx, iter, a, &type); + if (!res) { + // var decl + if (a->kind != TOK_IDENTIFIER) { + fprintf(stderr, "expected ident after type\n"); + return 1; + } + char *varname = strdup_failsafe(a->data.identifier); + if (token_step(iter, a)) + return 1; + + } else { + TRAP + } + } return 0; } |