swamp-source-map

Crates.ioswamp-source-map
lib.rsswamp-source-map
version0.1.10
created_at2025-03-29 15:01:03.102217+00
updated_at2025-03-29 15:01:03.102217+00
descriptionSource map cache for Swamp
homepage
repositoryhttps://github.com/swamp/swamp
max_upload_size
id1611379
size26,107
Peter Bjorklund (piot)

documentation

README

Swamp Source Map

Manages source files for the Swamp programming language compiler, providing mapping between file IDs, paths, and source locations (line/column).

Overview

This crate provides the SourceMap struct, which is responsible for:

  • Mounting Directories: Associates symbolic names ("mounts") with file system directories containing source code.
  • Reading & Caching: Reads source files either by absolute path or relative to a mount point, caching their contents and metadata.
  • File IDs: Assigns a unique FileId (u16) to each loaded file.
  • Location Mapping: Efficiently converts byte offsets within a file (often obtained from parsers or lexers using crates like swamp-node) into human-readable line and column numbers.
  • Source Snippets: Retrieves the source text corresponding to a given span (file ID, offset, length).

Installation

Add this to your Cargo.toml:

[dependencies]
swamp-source-map = "0.1.10"

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