From 660808af50780dae5292c8064d5bddd77246c52b Mon Sep 17 00:00:00 2001 From: Mel Date: Sun, 6 Jul 2025 03:57:37 +0200 Subject: Correct handling of empty block nodes Signed-off-by: Mel --- boot/parse.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'boot/parse.c') diff --git a/boot/parse.c b/boot/parse.c index cd5f019..264cf45 100644 --- a/boot/parse.c +++ b/boot/parse.c @@ -223,7 +223,11 @@ parser_block_node(struct Parser* p, struct Parser_Error* error) while (!parser_probe(p, TOKEN_CURLY_CLOSE)) { struct Statement* statement = CHECK_RETURN(parser_statement(p, error), struct Block_Node); - CHECK_RETURN(parser_end_statement(p, error), struct Block_Node); + + // statement ending token isn't required when the block ends on the same line, + // as in e.g.: `if (true) { print("yes") }` + if (!parser_probe(p, TOKEN_CURLY_CLOSE)) + CHECK_RETURN(parser_end_statement(p, error), struct Block_Node); if (!head) { head = statement; -- cgit 1.4.1