Module parsa::combinators
source · Expand description
Parsers that combine/manipulate other parsers in some way.
All of the types here have corresponding methods in Parser
for builder pattern-style construction.
§Error coercion rules
When dealing with multiple parsers with different error types, they must have a conversion to a single type.
This is usually determined by the first error type introduced, called the “target” type. The Parser::convert_err
method
can be used to set this target type explicitly.
For example with Chain
, P2::Err
must implement Into<P1::Err>
.
This is usually achieved with a higher ranked error type that fits the context of its usage.
ⓘ
#[derive(Debug, Error)]
pub enum MyErr {
Unique,
Empty(#[from] WordErr), // <- WordErr will implicitly be elevated to this type
}
Structs§
- Chains two parsers together.
- Repeatedly applies a parser, until it fails.
- Repeatedly applies a parser, until it fails. Unlike
Many
, this parser errors if the first run errors. - Attempts a second parser.