From dd893942f89d2942a764b07cf5cdece57390f146 Mon Sep 17 00:00:00 2001 From: Quinn Stephens Date: Tue, 10 Jun 2025 08:47:55 -0400 Subject: parser: Parse empty function definitions Signed-off-by: Quinn Stephens --- src/parser/parser.c | 17 +++++++++++++++-- 1 file 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; } -- cgit v1.2.3