4 releases
Uses new Rust 2024
new 0.1.13 | Mar 30, 2025 |
---|---|
0.1.12 | Mar 30, 2025 |
0.1.11 | Mar 29, 2025 |
0.1.10 | Mar 29, 2025 |
#1 in #dep
85 downloads per month
Used in 6 crates
(4 directly)
175KB
4K
SLoC
Swamp Dependency Loader
Parses Swamp source files, identifies module dependencies (mod
and use
statements), and calculates the correct order for semantic analysis.
Overview
This crate orchestrates the initial parsing phase of the Swamp compilation process. Starting from an entry point module, it recursively:
- Parses Swamp source files into ASTs (
swamp-ast
) usingswamp-parser
. - Scans the AST for
mod
(import) anduse
declarations to discover dependencies on other modules. - Maps module paths (e.g.,
crate.My.Module
,some_package.Lib
) to file system paths usingswamp-source-map
. - Builds a dependency graph of the modules.
- Determines the correct topological order in which modules must be analyzed to satisfy dependencies.
Key Functionality
DependencyParser
: Manages the state of parsed modules and scanned dependencies.parse_local_modules
: Recursively parses the entry module and its dependencies.get_analysis_order
: Calculates the topological sort of the module dependency graph.- Path Resolution: Handles finding module files based on conventions (
crate
vs. registry packages,.swamp
extension).
Installation
This crate is primarily used internally by the Swamp compiler.
[dependencies]
swamp-dep-loader = "0.1.13"
License
This project is licensed under the MIT License - see the LICENSE file for details.
Copyright
Copyright (c) Peter Bjorklund. All rights reserved. https://github.com/swamp/swamp
Dependencies
~2.4–9.5MB
~98K SLoC