diff options
| author | Bruce Hill <bruce@bruce-hill.com> | 2024-03-31 13:13:08 -0400 |
|---|---|---|
| committer | Bruce Hill <bruce@bruce-hill.com> | 2024-03-31 13:13:08 -0400 |
| commit | b6534ce34706d1a98584e5f916107d91da072346 (patch) | |
| tree | dfb8578405cb0bf02fa573a344f0d0542e25599a /repl.c | |
| parent | 56a44684faa9f91f5d5a794c3413ddd7dca93ca1 (diff) | |
Implement REPL 'while'
Diffstat (limited to 'repl.c')
| -rw-r--r-- | repl.c | 15 |
1 files changed, 15 insertions, 0 deletions
@@ -299,6 +299,21 @@ void run(env_t *env, ast_t *ast) } break; } + case While: { + auto while_ = Match(ast, While); + bool condition; + type_t *cond_t = get_type(env, while_->condition); + assert(cond_t->tag == BoolType); + for (;;) { + eval(env, while_->condition, &condition); + if (!condition) break; + run(env, while_->body); + } + break; + } + // case For: { + // auto for_ = Match(ast, For); + // } default: { eval(env, ast, NULL); break; |
