Parsanol - Highly Optimized Rust PEG Parser Library
This is a generic PEG parser library that can be used for any language. It provides:
- Core PEG parsing with packrat memoization
- Arena allocation for zero-copy AST construction
- Parser DSL for idiomatic grammar definition
- Generic lexer framework
- Rich error reporting with tree-structured errors
- Transformation system for converting parse trees to typed structs
- Infix expression parsing with precedence handling
- Developer tools (debug tracing, visualization)
- Optional Ruby FFI bindings
- Optional WASM bindings
Quick Start
use ;
// Define grammar via JSON
let grammar_json = r#"{
"atoms": [
{ "Str": { "pattern": "hello" } }
],
"root": 0
}"#;
let grammar: Grammar = from_str.unwrap;
let input = "hello";
let mut arena = for_input;
let mut parser = new;
let ast = parser.parse.unwrap;
Using the Parser DSL
use *;
let grammar = new
.rule
.build;
Feature Flags
ruby- Enable Ruby FFI bindings via magnuswasm- Enable WebAssembly bindingslogging- Enable debug logging using thelogcrateparallel- Enable parallel parsing with rayon