Skip to content

Parser: while, for, and loop (§5) #60

Description

@StreamDemon

Summary

Implement while, for, and loop parsing. All three keywords lex but have no parse production today; each fails with "expected expression".

Part of the v0.6.x parser-completeness work (see crates/AGENTS.md "Implemented subset"). Surfaced during PR #57 verification.

Spec

  • §5 control flow; §16 while_expr / for_expr / loop_expr, plus while let (§5.4) and for destructuring (§5.5).
  • The block-head restriction applies to the while condition and the for iterable (§5.1/§5.2, §16) — reuse the cond_expr helper from PR Start lexer parser compiler bootstrap #57.

Scope

  • while cond { ... } and while let pat = expr { ... }.
  • for pat in iter { ... } with destructuring patterns.
  • loop { ... }.
  • Confirm break / continue (already statements) nest correctly inside these; evaluate break value if §5 allows it.
  • AST nodes; corpus fixtures from §5 examples; unit tests incl. the condition/iterable restriction.

Notes

while let and for depend on pattern parsing — coordinate with the match issue so patterns land once and are shared.

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions