parser_compose/
lib.rs

1//! See the
2//! [README.md](https://gitlab.com/wake-sleeper/parser-compose/-/blob/main/README.md?ref_type=heads)
3//! for the introduction and examples
4//!
5//! ## Parsers
6//!
7//! Any rust item that implements the [`Parser`] trait can parse input by
8//! calling [try_parse()](crate::parser::Parser::try_parse)
9//!
10//! Strings and slices implement the `Parser` trait:
11//! - [`&str`](crate::Parser#parser-implementation-for-string-slices)
12//! - [`slice`s](crate::Parser#parser-implementation-for-slices)
13//!
14//! Additionally the `Parser` trait is implemented for [all functions with the following
15//! signature](crate::parser::Parser#parser-implementation-for-functions).
16//!
17//! Lastly, a few utility parsers are provided:
18//!
19//! - [`utf8_scalar()`](crate::utf8_scalar)
20//! - [`byte()`](crate::byte)
21//! - [`first_utf8_scalar()`](crate::first_utf8_scalar)
22//! - [`first_slice_item()`](crate::first_slice_item)
23//!
24//!
25//! ## Parser combinators
26//!
27//! The associated methods on the [`Parser`] trait are used to combine parsers.
28//!
29//! - [`or()`](crate::Parser::or)
30//! - [`when()`](crate::Parser::when)
31//! - [`fold()`](crate::Parser::fold)
32//! - [`accumulate()`](crate::Parser::accumulate)
33//! - [`repeats()`](crate::Parser::repeats)
34//! - [`map()`](crate::Parser::map)
35//! - [`peek()`](crate::Parser::peek)
36//! - [`not()`](crate::Parser::not)
37//! - [`input()`](crate::Parser::input)
38//! - [`and_then()`](crate::Parser::and_then)
39//! - [`optional()`](crate::Parser::optional)
40//!
41//! The sequence combinator is so common that it has a special form. [Tuples of parsers implement
42//! `Parser`](crate::parser::Parser#impl-Parser<In>-for-(P0,+P1)) such that the tuple parser succeeds if all its parsers succeed.
43//!
44//! ## Errors
45//!
46//! `parser-compose` take a simple approach to error handling: If a parser fails, it returns `None`
47//!
48
49mod parser;
50pub use parser::Parser;
51pub use parser::{byte, first_slice_item, first_utf8_scalar, utf8_scalar};
52pub use parser::{
53    AccumulateInit, AccumulateOperation, AndThen, Byte, Fold, Map, Optional, Or, Peek, Predicate,
54    RepeatsInit, RepeatsOperation, RepetitionArgument, Utf8Scalar,
55};