Expand description
A simple, fast, intuitive parser combinator framework for Rust.
§Get Started
use whitehole::{
combinator::eat,
parser::Parser,
};
// define the kind of the output
#[derive(Debug, Clone, PartialEq, Eq)]
enum Kind {
A,
}
let mut parser = Parser::builder() // create a parser builder
.entry(eat("a").bind(Kind::A)) // set the entry action
.build("a"); // build the parser with the input
let output = parser.next().unwrap(); // yield the next output
assert_eq!(output.value, Kind::A); // check the output
See the combinator
module to learn how to compose the entry action.
See the parser
module to learn how to use the parser.
§Read the Source Code
Here is the recommended order to read the source code:
Modules§
- action
- The basic building block of a parser.
- combinator
Combinator
is a wrapper around anAction
to provide decorators and operator overloads.- digest
- Digest-able byte sequence. See
Digest
. - instant
- The instantaneous state of a parser (a.k.a the “configuration” in the automata theory).
See
Instant
. - parser
- Manage the
State
,Heap
and the parsing progress. - range
- Utilities for working with byte ranges.
Macros§
- contextual
- Generate contextual combinators.