Minimal Imperative Parsing Library | https://docs.rs/mipl
1//! [Parsers](Parser) that consume parts of other [Parser]'s tokens.
2
3use crate::prelude::*;
4
5/// Functionality to build blanket [Parsers](Parser) using
6/// a parent [Parser] by consuming its
7/// tokens based on some pattern.
8///
9/// The pattern depends on the generic `C`, which corresponds
10/// to a concrete parser. (See [concrete_parser].)
11pub trait ConcreteSubparser<C> {
12 /// Build the subparser based on the concrete parser.
13 fn subparse
14 (value: C::Input, parser: &mut Parser) -> Parser
15 where
16 C: concrete_parser::ContainerCp;
17}
18
19/// Functionality to build blanket [Parsers](Parser) using
20/// a parent [Parser] by consuming a list of tokens from it.
21pub trait VariadicConcreteSubparser<C> {
22 /// Build the subparser based on the concrete parser.
23 fn subparse
24 (values: Vec<C::Input>, parser: &mut Parser) -> Parser
25 where
26 C: concrete_parser::ContainerCp;
27}
28
29mod collect_until;
30mod collect_while;
31mod collect_if_sequence;
32pub use {
33 collect_until::CollectUntil,
34 collect_while::CollectWhile,
35 collect_if_sequence::{CollectIfSeq, CollectIfExactSeq},
36};