diff options
| author | Mel <mel@rnrd.eu> | 2025-07-06 03:57:37 +0200 |
|---|---|---|
| committer | Mel <mel@rnrd.eu> | 2025-07-06 03:57:37 +0200 |
| commit | 660808af50780dae5292c8064d5bddd77246c52b (patch) | |
| tree | e8ee1f609977e116c0766b2344310f682bbe639a /boot/parse.c | |
| parent | ebd176b8e7eb14060375a28d6ac50500d9d2c808 (diff) | |
| download | catskill-660808af50780dae5292c8064d5bddd77246c52b.tar.zst catskill-660808af50780dae5292c8064d5bddd77246c52b.zip | |
Correct handling of empty block nodes
Signed-off-by: Mel <mel@rnrd.eu>
Diffstat (limited to 'boot/parse.c')
| -rw-r--r-- | boot/parse.c | 6 |
1 files changed, 5 insertions, 1 deletions
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; |
