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 |
#1523 in Parser implementations
88 downloads per month
Used in 7 crates
(4 directly)
145KB
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.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.3–3MB
~62K SLoC