diff options
| author | Bruce Hill <bruce@bruce-hill.com> | 2024-09-11 01:48:15 -0400 |
|---|---|---|
| committer | Bruce Hill <bruce@bruce-hill.com> | 2024-09-11 01:48:15 -0400 |
| commit | 989dc3f4428fd3185753336cb91baf48e0c85ad0 (patch) | |
| tree | 15eb26b7161f9953039f98625a42f7c68c688c86 /parse.c | |
| parent | 23209a0aab983501701c62ac87c891309a7d3d58 (diff) | |
Support `if x := blah: ...`
Diffstat (limited to 'parse.c')
| -rw-r--r-- | parse.c | 5 |
1 files changed, 3 insertions, 2 deletions
@@ -1003,8 +1003,9 @@ PARSER(parse_if) { if (!match_word(&pos, "if")) return NULL; - ast_t *condition = expect(ctx, start, &pos, parse_expr, - "I expected to find a condition for this 'if'"); + ast_t *condition = optional(ctx, &pos, parse_declaration); + if (!condition) + condition = expect(ctx, start, &pos, parse_expr, "I expected to find a condition for this 'if'"); ast_t *body = expect(ctx, start, &pos, parse_block, "I expected a body for this 'if' statement"); |
