Expand description
Multi-file loading layer for SATySFi documents: resolves @require: /
@import: headers to files on disk, recursively parses the whole
dependency graph, and returns it in dependency-first (topological) load
order.
Transcribed from v0.0.6’s src/frontend/main.ml (lines ~95-140):
@import: nameresolves relative to the directory of the file containing the header (not the entry document’s directory).@require: nameresolves against the package/library root (LoadOptions::lib_root).- Candidate extensions, tried in order:
.satyh, then.satyg(the mode-specific.satyh-<mode>extensions frommain.mlare out of scope here). - The same file reached through two different headers is one graph node (deduplicated by canonical path).
- Every dependency must be a library file (
body: None); the entry must be a document (body: Some(..)). - A cycle in the dependency graph is an error naming the files involved.
Structs§
- Load
Options - Options controlling header resolution.
- Loaded
File - One parsed file in a loaded program.
- Loaded
Program - A fully loaded, dependency-resolved program.
Enums§
- File
Origin - Where a loaded file came from — metadata for diagnostics and for a
future
used_as→ module binding. Nothing inrustyfi-langreads it yet. - Load
Error - Everything that can go wrong while loading a multi-file SATySFi program.
- Load
Mode - How multi-file dependencies are declared and resolved — Axis B,
orthogonal to
RustyfiVersion(Axis A, the grammar generation), except that the one combination with no upstream analogue —V0_0+Envelopes— is rejected byloadup front. - Loaded
Cst - A parsed file’s CST, tagged by which grammar generation produced it.
load()picks the variant per file, from that file’s ownLoadedFile::version— which a cross-version Legacy load can vary WITHIN one program (see that field). The enum exists soLoadedFilehas a single field type rather than forcing every consumer ofLoadedProgramto be generic over the CST type. - Rustyfi
Version - Target SATySFi language version.
Functions§
- load
- Load
entry(a.satydocument) and its full transitive dependency graph, dispatching onLoadOptions::mode(Axis B).LoadMode::Legacyresolves@require:/@import:headers (load_legacy);LoadMode::Envelopesresolvesuse package/use … ofheaders (v01x::open_doc).