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 70
//! 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 items that implement 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,+String>-for-%26'pat+str)
//! - [`slice`s](crate::Parser#impl-Parser<%26'input+[T],+Vec<T,+Global>>-for-%26'pat+[T])
//! - [`any_str`](crate::any_str)
//! - [`any_byte`](crate::any_byte)
//! - [`ascii_str`](crate::ascii_str)
//! - [`byte`](crate::byte)
//!
//! Additionally, [any function with the right signature](crate::parser::Parser#impl-Parser<In,+Out,+E>-for-F) automatically becomes a parser.
//!
//!
//! ## 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)
//! - [`repeated()`](crate::Parser::repeated)
//! - [`map()`](crate::Parser::map)
//! - [`peeked()`](crate::Parser::peeked)
//! - [`not_peeked()`](crate::Parser::not_peeked)
//! - [`and_then()`](crate::Parser::peeked)
//! - [`optional()`](crate::Parser::optional)
//!
//! The sequence combinator is so common that it has a special form. [Tuples of parsers implement
//! `Parser`](crate::parser::Parser#impl-Parser<In,+(O0,+O1),+E>-for-(P0,+P1)) such that the tuple parser succeeds if all its parsers succeed.
//!
//! ## Errors
//!
//! Error handling is an important part of parsing. What good is a good parser if you cannot
//! understand what happened when it failed?
//!
//! `parser-compose` take a simple but comprehensive approach to error handling: All parsers and
//! combinators report errors by building up an [`ErrorTree`](crate::ErrorTree). If the top level
//! parser fails, the result will contain an instance of this tree.
//!
//!
//!
//! ## Examples
//!
//! Checkout the [integration test
//! directory](https://gitlab.com/wake-sleeper/parser-compose/-/tree/main/tests) for concrete
//! parsing examples.
mod input;
mod parser;
mod result;
#[doc = include_str!("../README.md")]
#[cfg(doctest)]
pub struct ReadmeDocTests;
pub use input::Input;
pub use parser::Parser;
pub use parser::{any_byte, any_str, ascii_str, byte};
pub use parser::{
AndThen, AsciiStr, Byte, Map, Optional, Or, Peeked, Predicate, Repeat, RepetitionArgument,
};
pub use result::{ErrorTree, Res};