Skip to main content

Crate rustyfi_lang

Crate rustyfi_lang 

Source
Expand description

Abstract syntax tree, elaboration, evaluator, and primitives — the language core of the SATySFi port.

Modules§

ast
The elaborated abstract syntax tree (a subset of abstract_tree in types.cppo.ml). Produced from the surface CST by elaborate; consumed by the evaluator.
crossref
Cross-reference table + the fixpoint verdict, a small port of crossRef.ml. Owned by the compile driver (lib.rs::compile_document_cst), not reset per trial — it is the fixpoint state that persists while everything else (hooks, images, mutable store) resets each trial.
elaborate
Surface CST → Ast elaboration. Does scope resolution, operator- precedence/associativity resolution (the CST leaves that flattened, see cst.rs’s module doc comment), pattern lowering, the let-inline/ let-block context-argument desugaring, mutable/while/before desugaring, field access/record-update folding, itemize-tree reconstruction, quoted-math lowering, and (untyped) module name-mangling. This function’s signature is the seam where the typechecker (typechecker.ml / unification.ml port) slots in.
eval
Interpreter state and beta-reduction.
exhaustive
Match exhaustiveness and redundancy checking — a row-major reimplementation of the Maranget “usefulness” matrix algorithm v0.0.6 uses in src/frontend/exhchecker.ml. Non-fatal: this module only produces MatchWarnings, never a crate::typecheck::TypeError (mirrors exhchecker.ml’s own warn-and-continue policy — see that module’s main, lines 391-424).
hyphenation
Knuth–Liang hyphenation engine.
prim_types
Type signatures for every primitive registered in primitives.rs’s prims! table (plus the inline-fil constant), transcribed from v0.0.6’s tools/gencode/vminst.ml ~type_: fields (cited by line number at each entry below) and from src/frontend/primitives.cppo.ml for the handful of names vminst.ml doesn’t define directly (::, !, the comparison trio derived in general_table).
primitives
The primitive registry. Shaped so the ~300 vminst instructions can be ported one prims! line at a time; primitives are registered under their real v0.0.6 names so later stdlib loading finds them.
quoted
Quoted text in its compiled form — what { … } / '< … > / ${ … } become once crate::compile has lowered them, and what crate::value::Value’s InlineText/BlockText/MathText variants carry.
symbol
Interned identifiers: SymbolStore (an append-only unique-string registry) and Symbol (a Copy, u32-sized handle into one).
typecheck
The Hindley–Milner type inferencer: walks an crate::elaborate::Program and reports the first type error it finds, mirroring v0.0.6’s typecheck/typecheck_sub (src/frontend/typechecker.ml) — unification itself lives in crate::unify, generalization/instantiation in crate::types, this module only walks the AST applying those primitives at each rule, exactly as typechecker.ml does over its own unify/Typeenv.
types
The type language: base types, the mutable (union-find) representation of type/row variables, monomorphic and polymorphic types, and level-based generalization. Mirrors mono_type_main / poly_type / kind in v0.0.6’s src/frontend/types.cppo.ml, with two deliberate departures documented at their definitions:
unify
Structural unification over crate::types::MonoType, mirroring v0.0.6’s unify_sub (src/frontend/typechecker.ml:360-522): occurs check (extended to look through rows, since rows are first-class here — see the module doc comment on crate::types::Row), record/row unification, and the Kind::Record bridging case.
v1
SATySFi 0.1 (dev-0-1-0) support: lowering the cst_v1 CST into the shared 0.0.6-shaped pipeline (lower.rs), plus the module system.
value
Runtime values (a subset of syntactic_value).

Enums§

CompileError

Functions§

compile_document
Compile a .saty source string down to a typeset document: lex → parse → elaborate → evaluate.
compile_document_cst
Compile an already-parsed (possibly loader-merged) file. The multi-file loader concatenates library preludes into one synthetic cst::File and enters here.
compile_document_cst_with_aux
compile_document_cst_with_trials threading an AUXILIARY cross-reference table: aux seeds the fixpoint from a previous run and is overwritten with the final table. Seeding only affects how fast the fixpoint converges — see crossref::CrossRefs::seeded and crossref::CrossRefs::seed_unvalidated, which together guarantee the output is the same as a cold run’s.
compile_document_cst_with_stages
compile_document_cst_with_aux told which merged prelude entries came from a file that declared a non-default @stage:.
compile_document_cst_with_trials
Same as compile_document_cst, but also returns how many fixpoint trials it took (& the fixpoint) — exposed for tests that must confirm the fixpoint actually iterated, not just that it produced the right answer on a lucky first pass.
compile_document_v006_xver
Compile a loader-resolved SATySFi 0.0.6 program (LoadOptions { version: V0_0, .. }) whose entry (or one of its native 0.0.6 co-dependencies) @require:s at least one foreign 0.1 package.
compile_document_v006_xver_with_aux
compile_document_v006_xver_with_trials threading an AUXILIARY cross-reference table — see compile_document_cst_with_aux’s doc comment for what seeding aux does and why it can’t change the output.
compile_document_v006_xver_with_trials
Trial-count-reporting sibling, mirroring compile_document_v1_with_trials.
compile_document_v1
Compile a loader-resolved SATySFi 0.1 program (LoadOptions { version: V0_1, .. }): dependency libraries (files[..n-1], loader dependency-first order) are each lowered to one TopBinding::Module (qualified exports — see v1/lower.rs’s module doc) via v1::lower::lower_file_v1, the entry (files[n-1], always last — LoadedProgram::files’s contract) via v1::lower::lower_document_v1, assembled into ONE synthetic cst::File — the same shape the CLI’s merge_program builds for 0.0.6 — and pushed through the SHARED elaborate -> typecheck(V0_1) -> compile -> fixpoint-eval pipeline. Signature ascriptions (:>) are enforced per binding by v1::module_check::check_program.
compile_document_v1_with_aux
compile_document_v1_with_trials threading an AUXILIARY cross-reference table — see compile_document_cst_with_aux’s doc comment for what seeding aux does and why it can’t change the output.
compile_document_v1_with_trials
Trial-count-reporting sibling, mirroring compile_document_cst_with_trials (same rationale: fixture tests that must see the fixpoint iterate).
declared_stage
The stage a file’s @stage: header declares, if any.
fire_hooks
Fire every placed page-break hook and decoration, in document order, now that final page numbers and points are known. This is the port’s callback architecture: make_hook + handlePdf.ml:234/337’s invocation (hooks) and EvHorzFrame/EvVertFrame (decos), relocated to the one place that legally holds &mut Interp — the backend produced the geometry (POD HookId/DecoId tokens riding inside placed boxes, per hbox.rs); this reads them back and re-enters the evaluator.