diff options
| -rw-r--r-- | src/parse/controlflow.c | 12 | ||||
| -rw-r--r-- | test/enums.tm | 3 |
2 files changed, 3 insertions, 12 deletions
diff --git a/src/parse/controlflow.c b/src/parse/controlflow.c index 2f07d925..1087e20e 100644 --- a/src/parse/controlflow.c +++ b/src/parse/controlflow.c @@ -131,18 +131,8 @@ ast_t *parse_while(parse_ctx_t *ctx, const char *pos) { // while condition ["do"] [<indent>] body const char *start = pos; if (!match_word(&pos, "while")) return NULL; - - const char *tmp = pos; - // Shorthand form: `while when ...` - if (match_word(&tmp, "when")) { - ast_t *when = expect(ctx, start, &pos, parse_when, "I expected a 'when' block after this"); - if (!when->__data.When.else_body) when->__data.When.else_body = NewAST(ctx->file, pos, pos, Stop); - return NewAST(ctx->file, start, pos, Repeat, .body = when); - } - - (void)match_word(&pos, "do"); // Optional 'do' - ast_t *condition = expect(ctx, start, &pos, parse_expr, "I don't see a viable condition for this 'while'"); + (void)match_word(&pos, "do"); // Optional 'do' ast_t *body = expect(ctx, start, &pos, parse_block, "I expected a body for this 'while'"); return NewAST(ctx->file, start, pos, While, .condition = condition, .body = body); } diff --git a/test/enums.tm b/test/enums.tm index 080e5d97..1d00cd1a 100644 --- a/test/enums.tm +++ b/test/enums.tm @@ -61,9 +61,10 @@ func main() i := 1 cases := [Foo.One(1), Foo.One(2), Foo.Zero] - while when cases[i] is One(x) + repeat when cases[i] is One(x) >> x i += 1 + else stop >> [ ( |
