16 releases
Uses new Rust 2024
new 0.2.7 | Jul 9, 2025 |
---|---|
0.2.6 | Jul 8, 2025 |
0.1.16 | Apr 7, 2025 |
0.1.13 | Mar 30, 2025 |
0.0.14 | Apr 1, 2025 |
#197 in Value formatting
943 downloads per month
Used in 8 crates
(via swamp-compile)
180KB
4.5K
SLoC
Swamp Pretty Printer
Provides functions to format and display internal data structures from the Swamp programming language compiler in a human-readable, colorized way.
Overview
This crate is a debugging and inspection tool for developers working on the Swamp compiler. It takes complex internal representations like the Abstract Semantic Graph (swamp_semantic::Expression
), type structures (swamp_types::Type
), symbol tables (swamp_modules::SymbolTable
), etc., and formats them into indented, color-coded strings.
It utilizes swamp-source-map-lookup
to include source text snippets and yansi
for terminal colorization.
Key Features
- Formats Internal Structures: Pretty-prints
Expression
,Type
,SymbolTable
,Modules
,AssociatedImpls
, and more. - Color Highlighting: Uses terminal colors to differentiate between different kinds of symbols, types, and syntax elements.
- Indentation: Uses indentation to reflect the structure of the data (e.g., nested expressions, struct fields).
- Source Integration: Leverages
SourceMapLookup
to display identifiers based on their source text.
Core Structures
SourceMapDisplay
: A wrapper around aSourceMapLookup
implementation that provides the core formatting methods.SymbolTableDisplay
,ExpressionDisplay
, etc.: Wrapper structs that implementstd::fmt::Display
by usingSourceMapDisplay
to format the contained compiler structure.
Installation
This crate is primarily intended for use within the Swamp compiler or related debugging tools.
[dependencies]
swamp-pretty-print = "0.2.7"
Dependencies
~600KB