diff options
author | Quinn Stephens <quinn@osmora.org> | 2025-06-10 08:47:55 -0400 |
---|---|---|
committer | Quinn Stephens <quinn@osmora.org> | 2025-06-10 08:47:55 -0400 |
commit | dd893942f89d2942a764b07cf5cdece57390f146 (patch) | |
tree | 500d752c7c76ec20e6ffe168e42163a763bb2a64 /src/parser/parser.c | |
parent | 24522c8496c2661ba90b560bed0da482a85c3c8d (diff) |
parser: Parse empty function definitions
Signed-off-by: Quinn Stephens <quinn@osmora.org>
Diffstat (limited to 'src/parser/parser.c')
-rw-r--r-- | src/parser/parser.c | 17 |
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; } |