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
| Scheme | Example | Description |
|---|---|---|
file: | file:./geometry.md | Local filesystem (relative) |
logos: | logos:std | Built-in standard library |
| (none) | geometry.md | Defaults 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.
- Module
Source - 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_preludeprepends), documentation notes stripped. Identical bytes on every target (include_str!is compile-time). - prelude_
module_ sources - The RAW embedded stdlib module sources,
## Notedocumentation 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.