Skip to main content

Module loader

Module loader 

Source
Expand description

Module loader for multi-file LOGOS projects.

Handles resolution and loading of module sources from various URI schemes, with caching to prevent duplicate loading.

§Supported URI Schemes

SchemeExampleDescription
file:file:./geometry.mdLocal filesystem (relative)
logos:logos:stdBuilt-in standard library
(none)geometry.mdDefaults to file: scheme

§Security

The loader prevents path traversal attacks by checking that resolved paths remain within the project root directory.

§Caching

Modules are cached by their normalized URI. The same module loaded from different base paths will be cached separately.

§Example

let mut loader = Loader::new(project_root);
let source = loader.resolve(Path::new("main.md"), "file:./lib/math.md")?;
println!("Loaded: {}", source.path.display());

Structs§

Loader
Module loader that handles multiple URI schemes.
ModuleSource
A loaded module’s source content and metadata.

Functions§

apply_prelude
Prepend the stdlib modules a program actually uses. Returns the source unchanged when the program references no stdlib vocabulary or opts out with ## NoPrelude (in which case the opt-out marker is stripped so it never reaches the parser). This is the auto-import seam for both the interpreter and the compiler.
prelude
The full embedded prelude — every module’s CODE concatenated (what apply_prelude prepends), documentation notes stripped. Identical bytes on every target (include_str! is compile-time).
prelude_module_sources
The RAW embedded stdlib module sources, ## Note documentation included — the seam the LSP reads literate docs from (teach::extract_literate_docs).
prelude_vocabulary
Every identifier the prelude defines (across all modules) — derived from the modules.