Expand description
Expression and scripting evaluator (manifest §4, §25).
The “evaluator” is really a lowerer + resolver: it walks a
[SyntaxTree] from mos-parse and builds the typed semantic
[Document] graph from mos-core (manifest §6 stage 2), then
runs the resolve pass to assign section numbers and rewrite
@label cross-references (§6 stage 3, MVP 1).
Modules§
- bibliography 🔒
- Lower
#bibliography(...)directives into a semantic node. - dependency 🔒
- External files a lowering read, with the fingerprint each had at the
time, so a cached
LowerResultcan be checked against the filesystem before it is reused (issue #125). - image_
lower 🔒 - Lower
#imageand#figureparser directives into semantic nodes. - semantic_
hash 🔒 - Authored semantic input snapshots, taken before resolution mutates nodes.
- suggest 🔒
- Conservative nearest-match selection for “did you mean” diagnostics.
Structs§
- Bibliography
- A parsed bibliography: every [
BibEntry] keyed by its citation key. - Document
Metadata - Document-level metadata harvested from
#set document(...)directives. - Evaluation
State 🔒 - Evaluator
- Lowerer from parse syntax to semantic document graph.
- External
Dependency - One external file a lowering depended on: an
#image/#figureraster or a#bibliographysource. - File
Identity - The device and inode numbers and the status-change time of a file on
Unix. Unlike the modification time, none of these can be set from
userspace, so a rewrite that restores the old mtime still moves one of
them. Every field is
Noneon platforms that do not expose them. - Fingerprint
- What a regular file looked like when it was read: its
statfields, the moment thatstatwas taken, and afingerprint_byteshash of its contents. - Lower
Result - Result of lowering a [
SyntaxTree] into a [Document].
Enums§
- Page
Fixpoint Outcome - The result of driving page references to a fixpoint.
Constants§
- CODE_
LANGUAGE_ ATTR - Authored language name on a
#codenode, available to editor consumers. - DOC_
ATTR - Attribute key holding a node’s attached
/** … */doc-comment text. Read by the LSP hover handler. - LABEL_
SPAN_ 🔒END_ ATTR - LABEL_
SPAN_ 🔒START_ ATTR - RACY_
WINDOW - A modification time this close to the moment the fingerprint was taken is
not trusted by
ExternalDependency::is_current: a second write inside the same filesystem timestamp tick would leavestatunchanged. Two seconds covers FAT’s timestamp resolution.
Functions§
- fingerprint_
bytes - Fingerprint raw file bytes for dependency comparison.
- fingerprint_
file - The
Fingerprintof the regular file atpath, orNonewhen there is no readable regular file there. Directories, devices, and pipes are never opened. - insert_
label_ 🔒attributes - lower
- Convenience: parse + lower + resolve in one step. Concatenates the diagnostics from each stage so callers can render them uniformly.
- lower_
raw_ 🔒block - lower_
tree - Lower an already-parsed [
SyntaxTree]. - resolve
- Run the resolver pass over
documentin place. Returns any diagnostics produced; the document is modified regardless of whether errors are present so partial output is still renderable. - resolve_
page_ reference_ fixpoint - Drive page-reference resolution to a fixpoint against an injected
layout. - resolve_
page_ references - Rewrite every
@page(label)reference’s visible text. - string_
content_ 🔒span - The span of a string literal’s contents, excluding its quotes.