summaryrefslogtreecommitdiff
path: root/attocc.c
diff options
context:
space:
mode:
Diffstat (limited to 'attocc.c')
-rw-r--r--attocc.c26
1 files changed, 24 insertions, 2 deletions
diff --git a/attocc.c b/attocc.c
index 82ea8d8..b608805 100644
--- a/attocc.c
+++ b/attocc.c
@@ -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;
}