Skip to main content

Module render

Module render 

Source
Expand description

The projection renderer: a stored tree → the Section 5 text.

Read-only and total: there is no parser, and text is never the source of truth (docs/design.md Section 4). The renderer follows the Section 5 conventions for the seed model’s constructs:

  • end-delimited keyword blocks, no braces, no significant whitespace
  • the contract header (given/produces/requires/on_failure) before do
  • pure for an empty effect set
  • confidence as Type @ level, with the structural baseline elided
  • named call arguments, resolved from the enclosing module

Full fidelity to every Section 5 example waits on operators, handlers, and record/variant definitions existing in the model; those are later slices. A hole renders as <hole: …> and a missing child as <missing> so an incomplete or broken tree still renders for review rather than failing.

Structs§

Addressed
The Section-5 projection plus the span index that maps any byte position back to the node hash there — the editor substrate.
Span
A node’s byte range in the rendered text. Spans nest: a node’s range strictly contains every child’s; the root is 0..text.len().

Functions§

node_at
The deepest (most specific) node whose span contains offset — the node a cursor at offset edits. None if out of range.
render
Render the subtree at root as Section 5 text. No trailing newline.
render_addressed
Render root and return the projection text together with the hash↔span index. text is byte-identical to render; the spans come from the same renderer run with node bracketing on.