Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Syntax.Layout

The Prism-language reimplementation of the compiler’s layout pass: the offside rule that splices the virtual block delimiters.

It turns the raw token stream into the post-layout parse stream by splicing VOpen/VClose/VSemi and by opening a bare-indent body after each class/instance/effect head. The Rust lex pipeline stays the authoritative oracle; this module reproduces its output so the two can be diffed, never used as a silent fallback.

The pipeline mirrors the compiler exactly: lex_raw (Syntax.Lex) yields the decoded raw tokens; inject splices a zero-width head opener after every declaration head (the head runs to the last token on the keyword’s line); the offside driver walks the injected stream with an indent stack, a bracket depth, and a carried-opener flag, emitting the virtual delimiters at zero-width spans; and the synthetic head openers are dropped from the result. The whole file is one Eager top-level block, opened at the first token and closed at end of input, and a block only opens after an opener that begins a deeper new line (the Conditional opener rule), so a one-line let x = e stays flat.

Functions and Values

layout

layout : (String) -> Result(List(Syntax.Token.Token), Syntax.Lex.LexError)

Tokenize and lay out text, reproducing the compiler’s post-layout parse stream: the raw tokens with the virtual block delimiters spliced in and the synthetic head openers stripped. A lexing failure is propagated unchanged.