From a207a7f39514f03ddfafbe39e52a3fae57a414b4 Mon Sep 17 00:00:00 2001 From: Carson Fleming Date: Wed, 5 Aug 2026 01:05:22 -0400 Subject: got hello world working with some hacks --- parser.c | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) (limited to 'parser.c') diff --git a/parser.c b/parser.c index bdf266d..c4fa8b7 100644 --- a/parser.c +++ b/parser.c @@ -576,14 +576,14 @@ static void parse_fn_decl(struct fn_decl_node* p_node) { expect(TK_IDENT); - if (scope_define_var(scope, (struct var_def) { - .name = tok.data.ident, - .loc = { - .type = STO_FN, - .decl = p_node, - }, - }) == NULL) - PARSER_PANIC("redefinition of '%s'", tok.data.ident) + /* redefinition is allowed */ + scope_define_var(scope, (struct var_def) { + .name = tok.data.ident, + .loc = { + .type = STO_FN, + .decl = p_node, + }, + }); p_node->name = tok.data.ident; @@ -600,7 +600,12 @@ static void parse_fn_decl(struct fn_decl_node* p_node) { expect(TK_RPAREN); - parse_group(&p_node->body); + peek_or_panic(); + if (tok.type == TK_SEMI) expect(TK_SEMI); + else { + p_node->body = ccc_alloc(sizeof(struct group_node)); + parse_group(p_node->body); + } scope_pop(&scope); } -- cgit v1.2.3