[−][src]Crate parze
Parze is a clean, efficient parser combinator written in Rust.
Features
- All the usual parser combinator operations
- Operator overloading for simpler parser declaration
- Support for recursive parser definitions
- Custom error types - define your own!
- Prioritised / merged failure for more useful errors
- No dependencies - fast compilation!
no_std
support
Example
use parze::prelude::*;
#[derive(Clone, Debug, PartialEq)]
enum Instr { Add, Sub, Left, Right, In, Out, Loop(Vec<Instr>) }
let bf: Parser<_, _> = recursive(|bf| (
sym('+') - Instr::Add
| sym('-') - Instr::Sub
| sym('<') - Instr::Left
| sym('>') - Instr::Right
| sym(',') - Instr::In
| sym('.') - Instr::Out
| (sym('[') >> bf << sym(']')) % |ts| Instr::Loop(ts)
) * Any);
Modules
error | |
prelude | |
repeat |
Structs
Declaration | A type used to separate the declaration and definition of a parser such that it may be defined in terms of itself. |
Parser | A type that represents a rule that may be used to parse a list of symbols. |
Functions
all_of | A parser that accepts all of the given list of symbols, one after another. |
call | A parser that invokes another parser, as generated by the given function. |
declare | Declare a parser before defining it. A definition can be given later with the |
maybe_map | A parser that accepts one symbol provided it passes the given test, mapping it to another symbol in the process. |
none_of | A parser that accepts any one symbol that is not within the given set of symbols. |
not_sym | A parser that accepts any one thing that is not the given symbol. |
one_of | A parser that accepts one of the given set of symbols. |
permit | A parser that accepts one symbol provided it passes the given test. |
recursive | A wrapper function for recursive parser declarations. |
sym | A parser that accepts the given symbol. |