[−][src]Crate parze
Parze is a clean, efficient parser combinator written in Rust.
Features
- All the usual parser combinator operations
- Macro for simple rule and 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
A parser capable of parsing all valid Brainfuck code into an AST.
#![cfg(feature = "macros")] #![feature(proc_macro_hygiene)] use parze::prelude::*; #[derive(Clone, Debug, PartialEq)] enum Instr { Add, Sub, Left, Right, In, Out, Loop(Vec<Instr>) } parsers! { bf: Parser<char, _> = { ( '+' -> { Instr::Add } | '-' -> { Instr::Sub } | '<' -> { Instr::Left } | '>' -> { Instr::Right } | ',' -> { Instr::In } | '.' -> { Instr::Out } | '[' -& bf &- ']' => { |i| Instr::Loop(i) } ) * } }
Modules
chain | |
error | |
pad | |
parse_fn | |
prelude | |
reduce | |
repeat |
Macros
parsers | A macro to define recursive parsers. |
parze_error | |
rule | A macro to define parser rules. |
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. |
Traits
Captures |
Functions
all_of | A parser that accepts all of the given list of symbols, one after another. |
all_sym | A parser that accepts all input symbols. |
any_sym | A parser that accepts any single symbol. |
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 |
empty | A parser that accepts no symbols. |
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. |
nothing | A parser that does not accept any input symbols. |
one_of | A parser that accepts one of the given set of symbols. |
padding | A parser that accepts any number of 'padding' symbols. Usually, this is taken to mean whitespace. |
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. |
try_map | A parser that accepts one symbol provided it passes the given test, mapping it to another symbol in the process. |