From 989dc3f4428fd3185753336cb91baf48e0c85ad0 Mon Sep 17 00:00:00 2001 From: Bruce Hill Date: Wed, 11 Sep 2024 01:48:15 -0400 Subject: Support `if x := blah: ...` --- parse.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'parse.c') diff --git a/parse.c b/parse.c index 95b05cbc..6191ceaf 100644 --- a/parse.c +++ b/parse.c @@ -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"); -- cgit v1.2.3