Skip to main content

Crate mos_eval

Crate mos_eval 

Source
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 LowerResult can be checked against the filesystem before it is reused (issue #125).
image_lower 🔒
Lower #image and #figure parser 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.
DocumentMetadata
Document-level metadata harvested from #set document(...) directives.
EvaluationState 🔒
Evaluator
Lowerer from parse syntax to semantic document graph.
ExternalDependency
One external file a lowering depended on: an #image / #figure raster or a #bibliography source.
FileIdentity
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 None on platforms that do not expose them.
Fingerprint
What a regular file looked like when it was read: its stat fields, the moment that stat was taken, and a fingerprint_bytes hash of its contents.
LowerResult
Result of lowering a [SyntaxTree] into a [Document].

Enums§

PageFixpointOutcome
The result of driving page references to a fixpoint.

Constants§

CODE_LANGUAGE_ATTR
Authored language name on a #code node, 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 leave stat unchanged. Two seconds covers FAT’s timestamp resolution.

Functions§

fingerprint_bytes
Fingerprint raw file bytes for dependency comparison.
fingerprint_file
The Fingerprint of the regular file at path, or None when 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 document in 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.