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 |
#578 in Programming languages
952 downloads per month
Used in 11 crates
(3 directly)
160KB
3.5K
SLoC
Swamp Parser
Parses Swamp programming language source code text into an Abstract Syntax Tree (AST).
Overview
This crate takes a string containing Swamp source code and attempts to parse it according to the grammar defined in src/grammar.pest
. If successful, it produces an AST representation using the data structures defined in the swamp-ast
crate. If the source code contains syntax errors, it returns a ParseError
.
The parser is built using the pest parser generator library.
Key Features
- Input: Swamp source code as a
&str
. - Output: A
Result<swamp_ast::Module, ParseError>
. - AST: The success variant contains the root of the Abstract Syntax Tree (
swamp_ast::Module
). - Error Handling: The error variant (
ParseError
) provides information about the location and nature of the syntax error. - Span Information: Attaches source location information (
swamp_ast::Node
containingSpanWithoutFileId
) to the generated AST nodes.
Installation
Add this to your Cargo.toml
:
[dependencies]
swamp-parser = "0.2.7"
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.3–3MB
~61K SLoC