swamp-dep-loader

Crates.ioswamp-dep-loader
lib.rsswamp-dep-loader
version0.2.26
created_at2025-03-29 16:11:26.624355+00
updated_at2025-08-18 11:24:45.468515+00
descriptionParses Swamp modules, scans for dependencies (`mod` and `use`), and determines the correct analysis order.
homepage
repositoryhttps://github.com/swamp/swamp
max_upload_size
id1611432
size30,247
Peter Bjorklund (piot)

documentation

README

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:

  1. Parses Swamp source files into ASTs (swamp-ast) using swamp-parser.
  2. Scans the AST for mod (import) and use declarations to discover dependencies on other modules.
  3. Maps module paths (e.g., crate.My.Module, some_package.Lib) to file system paths using swamp-source-map.
  4. Builds a dependency graph of the modules.
  5. 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.2.26"

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

Commit count: 802

cargo fmt