1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
//! See the
//! [README.md](https://gitlab.com/wake-sleeper/parser-compose/-/blob/main/README.md?ref_type=heads)
//! for a crash course in parser combinators.
//!
//! The crate is logically organized into three parts
//!
//! ## Parsers
//!
//! Any rust item that implements the [Parser](crate::parser::Parser) trait can parse input by
//! calling [try_parse()](crate::parser::Parser::try_parse)
//!
//! - [`&str`](crate::Parser#impl-Parser<%26'input+str>-for-%26'pat+str)
//! - [`slice`s](crate::Parser#impl-Parser<%26'i+[T]>-for-%26'p+[T])
//! - [`utf8_str`](crate::utf8_str)
//! - [`any_utf8_str`](crate::any_utf8_str)
//! - [`any_slice`](crate::any_slice)
//! - [`end`](crate::end)
//!
//! Additionally the `Parser` trait is implemented for [all function with a particular signature](crate::parser::Parser#impl-Parser<In>-for-F).
//!
//!
//! ## Parser combinators
//!
//! The associated methods on the [Parser](crate::parser::Parser) trait are used to combine with
//! other parsers.
//!
//! - [`or()`](crate::Parser::or)
//! - [`when()`](crate::Parser::when)
//! - [`fold()`](crate::Parser::fold)
//! - [`accumulate()`](crate::Parser::accumulate)
//! - [`repeats()`](crate::Parser::repeats)
//! - [`map()`](crate::Parser::map)
//! - [`peek()`](crate::Parser::peek)
//! - [`not()`](crate::Parser::not)
//! - [`input()`](crate::Parser::input)
//! - [`and_then()`](crate::Parser::and_then)
//! - [`optional()`](crate::Parser::optional)
//! - [`label()`](crate::Parser::label)
//!
//! The sequence combinator is so common that it has a special form. [Tuples of parsers implement
//! `Parser`](crate::parser::Parser#impl-Parser<In>-for-(P0,+P1)) such that the tuple parser succeeds if all its parsers succeed.
//!
//! ## Errors
//!
//! `parser-compose` take a simple approach to error handling: Builtin parsers report errors by
//! appendding to a [`Failurelog`](crate::FailureLog). If the top level parser fails, the result
//! will contain an instance of this structure.
//!
//!
//! ## Examples
//!
//! Checkout the [integration test
//! directory](https://gitlab.com/wake-sleeper/parser-compose/-/tree/main/tests) for concrete
//! parsing examples.

mod error;
mod input;
mod parser;
mod result;

pub use error::{FailureLog, ParserFailure, Reason};
pub use input::ParserContext;
pub use parser::Parser;
pub use parser::{any_slice, any_utf8_str, end, utf8_str};
pub use parser::{
    AccumulateInit, AccumulateOperation, AndThen, Fold, Map, Optional, Or, Peek, Predicate,
    RepeatsInit, RepeatsOperation, RepetitionArgument, Utf8Str,
};
pub use result::Res;