0%

parser

Goal

Parse block:name block_expr with block context-sensitive (before : only).

Implementation Sketch

Dispatch on block followed by : in expression position; build labeled-block AST; thread label; body is block_expr.

Spec References

labeled-block-early-exit-proposal.md Design (Syntax/Keyword); grammar.ebnf:408 + expression line 370.

Work Items

  • Recognize block as a context-sensitive keyword ONLY when immediately followed by : (else a plain identifier — let block = 5 stays valid). ori-syntax.md already lists block context-sensitive; wire parser dispatch in compiler/ori_parse/.
  • Parse labeled_block = "block" label block_expr . (grammar.ebnf:408) — dispatch in expression position, thread the label into a labeled-block AST node, body is a block_expr.
  • Rust parser tests (sibling tests.rs): basic block:r { break:r v }, nested blocks, block as bare identifier (negative — must NOT trigger labeled-block parse), block inside loop/for/while.