summaryrefslogtreecommitdiff
path: root/examples/loop_do.fy
AgeCommit message (Collapse)Author
2026-02-19Add assert checks to break/next and loop/do examplesPaul Buetow
Replace bare say statements with assert expected == say value; so that each example self-verifies its output at runtime — matching the convention used in expressions.fy and types.fy. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-02-19Implement loop (infinite) and do...while/until loopsPaul Buetow
Completes the 'loop, next, break, do' TODO entry — break and next were landed in the previous commit; this adds the remaining two forms: - loop { body } — infinite loop; the only exit is break. Simpler than while/until since there is no condition expression to evaluate. - do { body } while expr; / do { body } until expr; — post-condition loop: body always executes at least once, condition is checked at the bottom of each iteration. Condition tokens are collected until ';' (mirrors _expression_get but stops at semicolon instead of '{'), then replayed each iteration using the same temp-stack/temp-iterator technique as while/until. Both break and next are supported. Token changes: TT_LOOP and TT_DO added to the keyword enum in token.h, registered in get_tt() and tt_get_name() in token.c. Add examples/loop_do.fy; expected output: 5 / 12 / 11 / 5. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>