aboutsummaryrefslogtreecommitdiff
path: root/parse.c
diff options
context:
space:
mode:
authorBruce Hill <bruce@bruce-hill.com>2024-05-16 00:55:16 -0400
committerBruce Hill <bruce@bruce-hill.com>2024-05-16 00:55:16 -0400
commitee9a40f9102f12357e7a46c3b48a486c62c2311e (patch)
treea30b93c781ddf7db6462e738171635fc519b404a /parse.c
parentc1e4730f353aa5424a038bfdc39d338ca8a1cb73 (diff)
Fix 'else if'
Diffstat (limited to 'parse.c')
-rw-r--r--parse.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/parse.c b/parse.c
index cdebf0fb..868c8bb9 100644
--- a/parse.c
+++ b/parse.c
@@ -889,7 +889,8 @@ PARSER(parse_if) {
const char *else_start = pos;
if (get_indent(ctx, tmp) == starting_indent && match_word(&tmp, "else")) {
pos = tmp;
- expect_str(ctx, start, &pos, ":", "I expected a ':' here");
+ if (!match_word(&tmp, "if"))
+ expect_str(ctx, start, &pos, ":", "I expected a ':' here");
else_body = expect(ctx, else_start, &pos, parse_opt_indented_block, "I expected a body for this 'else'");
}
return NewAST(ctx->file, start, pos, If, .condition=condition, .body=body, .else_body=else_body);