summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/parser/parser.c17
1 files changed, 15 insertions, 2 deletions
diff --git a/src/parser/parser.c b/src/parser/parser.c
index b947ea2..e5b9973 100644
--- a/src/parser/parser.c
+++ b/src/parser/parser.c
@@ -63,12 +63,25 @@ parse_func_decl(struct parser *ctx, struct ast_node *func)
return false;
}
+ parser_advance(ctx);
+ if (ctx->tok.kind == TOK_SEMICOLON) {
+ hashmap_add(ctx->syms, &func->hashmap_entry);
+ parser_advance(ctx);
+ return true;
+ }
+
+ if (ctx->tok.kind != TOK_LCURLY) {
+ tok_error(&ctx->tok, "expected \";\" or \"{\" after \")\"\n");
+ free(func);
+ return false;
+ }
+
/*
* TODO: Parse body.
*/
parser_advance(ctx);
- if (ctx->tok.kind != TOK_SEMICOLON) {
- tok_error(&ctx->tok, "expected \";\" after \")\"\n");
+ if (ctx->tok.kind != TOK_RCURLY) {
+ tok_error(&ctx->tok, "expected \"}\" after \"{\"\n");
free(func);
return false;
}