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
blockas a context-sensitive keyword ONLY when immediately followed by:(else a plain identifier —let block = 5stays valid). ori-syntax.md already listsblockcontext-sensitive; wire parser dispatch incompiler/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 ablock_expr. - Rust parser tests (sibling tests.rs): basic
block:r { break:r v }, nested blocks,blockas bare identifier (negative — must NOT trigger labeled-block parse), block inside loop/for/while.