[−][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_stdsupport
Example
A parser capable of parsing all valid Brainfuck code into an AST.
use parze::prelude::*; #[derive(Clone, Debug, PartialEq)] enum Instr { Add, Sub, Left, Right, In, Out, Loop(Vec<Instr>) } parsers! { bf: Parser<_, _> = { ( '+' -> { Instr::Add } | '-' -> { Instr::Sub } | '<' -> { Instr::Left } | '>' -> { Instr::Right } | ',' -> { Instr::In } | '.' -> { Instr::Out } | '[' -& bf &- ']' => { |ts| Instr::Loop(ts) } ) * } }
Modules
| also | |
| chain | |
| error | |
| 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. |
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 |
| 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 accepts no input symbols. |
| 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. |