diff options
| author | 2023-06-04 09:51:46 +0200 | |
|---|---|---|
| committer | 2023-06-04 10:20:27 +0200 | |
| commit | 9c6a0b4340fe430e941586134f585c27309a0084 (patch) | |
| tree | 69af1eca268250362385063545243f02415b9178 /parse.c | |
| parent | 73eaec109d01368dcc1869b1167adb6db7827bc9 (diff) | |
do while
Diffstat (limited to 'parse.c')
| -rw-r--r-- | parse.c | 20 |
1 files changed, 20 insertions, 0 deletions
@@ -1625,6 +1625,26 @@ stmt(struct parser *pr, struct function *fn) useblk(fn, end); } break; + case TKWdo: + lex(pr, NULL); + begin = end = NULL; + EMITS { + putbranch(fn, begin = newblk(fn)); + useblk(fn, begin); + } + terminates = stmt(pr, fn); + expect(pr, TKWwhile, NULL); + expect(pr, '(', NULL); + ex = commaexpr(pr); + expect(pr, ')', NULL); + if (!isscalar(ex.ty)) + error(&ex.span, "'while' condition is not a scalar (%ty)", ex.ty); + EMITS { + end = newblk(fn); + if (!terminates) condjump(fn, &ex, begin, end); + useblk(fn, end); + } + break; case TKWreturn: lex(pr, NULL); if (fn->retty.t != TYVOID) { |