summaryrefslogtreecommitdiffstats
path: root/vendor/winnow/src/multi.rs
blob: 3e92f70be0ab48ebd868f953764d9ba835f109bf (plain)
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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
//! Deprecated, see [`combinator`]
#![deprecated(since = "0.4.2", note = "Replaced with `combinator`")]

use crate::binary;
use crate::combinator;
use crate::error::ParseError;
use crate::stream::Accumulate;
use crate::stream::Stream;
use crate::Parser;

/// Deprecated, replaced by [`combinator::repeat`]
#[deprecated(since = "0.4.2", note = "Replaced with `combinator::repeat`")]
#[inline(always)]
pub fn many0<I, O, C, E, F>(f: F) -> impl Parser<I, C, E>
where
    I: Stream,
    C: Accumulate<O>,
    F: Parser<I, O, E>,
    E: ParseError<I>,
{
    combinator::repeat(0.., f)
}

/// Deprecated, replaced by [`combinator::repeat`]
#[deprecated(since = "0.4.2", note = "Replaced with `combinator::repeat`")]
#[inline(always)]
pub fn many1<I, O, C, E, F>(f: F) -> impl Parser<I, C, E>
where
    I: Stream,
    C: Accumulate<O>,
    F: Parser<I, O, E>,
    E: ParseError<I>,
{
    combinator::repeat(1.., f)
}

/// Deprecated, replaced by [`combinator::repeat_till0`]
#[deprecated(since = "0.4.2", note = "Replaced with `combinator::repeat_till0`")]
#[inline(always)]
pub fn many_till0<I, O, C, P, E, F, G>(f: F, g: G) -> impl Parser<I, (C, P), E>
where
    I: Stream,
    C: Accumulate<O>,
    F: Parser<I, O, E>,
    G: Parser<I, P, E>,
    E: ParseError<I>,
{
    combinator::repeat_till0(f, g)
}

pub use combinator::separated0;
pub use combinator::separated1;
pub use combinator::separated_foldl1;
#[cfg(feature = "alloc")]
pub use combinator::separated_foldr1;

/// Deprecated, replaced by [`combinator::repeat`]
#[deprecated(since = "0.4.2", note = "Replaced with `combinator::repeat`")]
#[inline(always)]
pub fn many_m_n<I, O, C, E, F>(min: usize, max: usize, parse: F) -> impl Parser<I, C, E>
where
    I: Stream,
    C: Accumulate<O>,
    F: Parser<I, O, E>,
    E: ParseError<I>,
{
    combinator::repeat(min..=max, parse)
}

#[allow(deprecated)]
pub use combinator::count;
pub use combinator::fill;

/// Deprecated, replaced by [`combinator::fold_repeat`]
#[deprecated(since = "0.4.2", note = "Replaced with `combinator::fold_repeat`")]
#[inline(always)]
pub fn fold_many0<I, O, E, F, G, H, R>(f: F, init: H, g: G) -> impl Parser<I, R, E>
where
    I: Stream,
    F: Parser<I, O, E>,
    G: FnMut(R, O) -> R,
    H: FnMut() -> R,
    E: ParseError<I>,
{
    combinator::fold_repeat(0.., f, init, g)
}

/// Deprecated, replaced by [`combinator::fold_repeat`]
#[deprecated(since = "0.4.2", note = "Replaced with `combinator::fold_repeat`")]
#[inline(always)]
pub fn fold_many1<I, O, E, F, G, H, R>(f: F, init: H, g: G) -> impl Parser<I, R, E>
where
    I: Stream,
    F: Parser<I, O, E>,
    G: FnMut(R, O) -> R,
    H: FnMut() -> R,
    E: ParseError<I>,
{
    combinator::fold_repeat(1.., f, init, g)
}

/// Deprecated, replaced by [`combinator::fold_repeat`]
#[deprecated(since = "0.4.2", note = "Replaced with `combinator::fold_repeat`")]
#[inline(always)]
pub fn fold_many_m_n<I, O, E, F, G, H, R>(
    min: usize,
    max: usize,
    parse: F,
    init: H,
    fold: G,
) -> impl Parser<I, R, E>
where
    I: Stream,
    F: Parser<I, O, E>,
    G: FnMut(R, O) -> R,
    H: FnMut() -> R,
    E: ParseError<I>,
{
    combinator::fold_repeat(min..=max, parse, init, fold)
}

pub use binary::length_count;
pub use binary::length_data;
pub use binary::length_value;