aboutsummaryrefslogtreecommitdiff
path: root/parse.c
diff options
context:
space:
mode:
Diffstat (limited to 'parse.c')
-rw-r--r--parse.c5
1 files changed, 3 insertions, 2 deletions
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");