diff options
| author | Bruce Hill <bruce@bruce-hill.com> | 2024-08-18 15:22:51 -0400 |
|---|---|---|
| committer | Bruce Hill <bruce@bruce-hill.com> | 2024-08-18 15:22:51 -0400 |
| commit | a49870f810f19bef7e1dae1f61681c1682823d00 (patch) | |
| tree | d00588be4f289c3036cdf2e7ad252f06663cd154 /parse.c | |
| parent | f4b04a1b8cd882e25fee592c819650c9b7e8566b (diff) | |
Add primality testing and next_prime()/prev_prime()
Diffstat (limited to 'parse.c')
| -rw-r--r-- | parse.c | 7 |
1 files changed, 5 insertions, 2 deletions
@@ -930,10 +930,13 @@ ast_t *parse_comprehension_suffix(parse_ctx_t *ctx, ast_t *expr) { expect_str(ctx, start, &pos, "in", "I expected an 'in' for this 'for'"); ast_t *iter = expect(ctx, start, &pos, parse_expr, "I expected an iterable value for this 'for'"); - whitespace(&pos); + const char *next_pos = pos; + whitespace(&next_pos); ast_t *filter = NULL; - if (match_word(&pos, "if")) + if (match_word(&next_pos, "if")) { + pos = next_pos; filter = expect(ctx, pos-2, &pos, parse_expr, "I expected a condition for this 'if'"); + } return NewAST(ctx->file, start, pos, Comprehension, .expr=expr, .vars=vars, .iter=iter, .filter=filter); } |
