Skip to main content

Module source

Module source 

Source
Expand description

Source locations (see docs/done/2026-10-11_elly-ctx-chunks.md, Source locations).

A document is one input to muon::parse: a file, a REPL input or an eval source. A chunk records its documents and gives each a range of its own positions, a ChunkLoc; its code has spans in those positions, in side tables parallel to its nodes, patterns, lambdas and members. A realm gives each chunk a base in its own offset space when the chunk is added, so a Loc names a position in any of the realm’s chunks, and Ctx::locate resolves it to a Location in a document.

The realm keeps no source text. A line is found from the line starts a chunk records; a column is computed from the text on demand (Location::column).

Structs§

ChunkLoc
A position relative to a chunk: an offset into the concatenation of its documents. A chunk is built with no realm’s offsets; adding the base its realm gives it (see Ctx::chunk_bases) is the one way to a Loc.
ChunkSpan
len bytes from a ChunkLoc.
CtxSpan
len bytes from a Loc.
Doc
A document of a chunk: its source, and where its text and lines lie among the chunk’s.
Loc
A position in a realm’s offset space, which concatenates the documents of its chunks in the order the chunks were added.
Location
A Loc resolved: the document it falls in, and its line there.

Enums§

DocSource
Where a document came from. The realm keeps no source text, so this is what finds the text again.

Functions§

report
Reports message at span of the document name, whose text is text: a name:line:column: message line, then the span’s first line with the span underlined to that line’s end. Columns count code points, a tab as one, as Location::column does. A span past the text’s end is put at its end.

Type Aliases§

Len
A length in bytes.
Line
A line number, 1-based.
Pos
A position in a realm’s offset space or in a chunk’s.