whitehole
A simple, fast, intuitive parser combinator framework for Rust.
Features
- Simple: only a handful of combinators to remember:
eat,next,till,wrap. - Operator overloading: use
+and|to compose combinators, use*to repeat a combinator. - Zero heap allocation: this framework only uses stack memory.
- Re-usable heap memory: if you need allocation, never clone or reallocate it.
- Stateful-able: control the parsing flow with an optional custom state.
- Safe by default, with
unsafevariants for performance.
Installation
Examples
Here is a simple example to parse hexadecimal color codes:
use ;
let double_hex = ;
// Concat multiple combinators with `+`.
// Tuple values will be concatenated into a single tuple.
// Here `() + (u8,) + (u8,) + (u8,)` will be `(u8, u8, u8)`.
let entry = eat + double_hex + double_hex + double_hex;
let mut parser = new.entry.build;
let output = parser.parse.unwrap;
assert_eq!;
assert_eq!;
Documentation
Related
in_str: a procedural macro to generate a closure that checks if a character is in the provided literal string.
Credits
This project is inspired by: