/rust/registry/src/index.crates.io-1949cf8c6b5b557f/combine-4.6.9/src/parser/choice.rs
Line | Count | Source |
1 | | //! Combinators which take one or more parsers and attempts to parse successfully with at least one |
2 | | //! of them. |
3 | | |
4 | | use crate::{ |
5 | | error::{ |
6 | | ParseError, |
7 | | ParseResult::{self, *}, |
8 | | ResultExt, StreamError, Tracked, |
9 | | }, |
10 | | parser::ParseMode, |
11 | | ErrorOffset, Parser, Stream, StreamOnce, |
12 | | }; |
13 | | |
14 | | /// Takes a number of parsers and tries to apply them each in order. |
15 | | /// Fails if all the parsers fails or if an applied parser fails after it has committed to its |
16 | | /// parse. |
17 | | /// |
18 | | /// ``` |
19 | | /// # #[macro_use] |
20 | | /// # extern crate combine; |
21 | | /// # use combine::*; |
22 | | /// # use combine::parser::char::{digit, letter, string}; |
23 | | /// # use combine::stream::easy::Error; |
24 | | /// # fn main() { |
25 | | /// let mut parser = choice!( |
26 | | /// many1(digit()), |
27 | | /// string("let").map(|s| s.to_string()), |
28 | | /// many1(letter())); |
29 | | /// assert_eq!(parser.parse("let"), Ok(("let".to_string(), ""))); |
30 | | /// assert_eq!(parser.parse("123abc"), Ok(("123".to_string(), "abc"))); |
31 | | /// assert!(parser.parse(":123").is_err()); |
32 | | /// # } |
33 | | /// ``` |
34 | | #[macro_export] |
35 | | macro_rules! choice { |
36 | | ($first : expr) => { |
37 | | $first |
38 | | }; |
39 | | ($first : expr, $($rest : expr),+) => { |
40 | | $first.or(choice!($($rest),+)) |
41 | | } |
42 | | } |
43 | | |
44 | | #[macro_export] |
45 | | #[doc(hidden)] |
46 | | macro_rules! parse_mode_choice { |
47 | | (Input) => { |
48 | 0 | fn parse_partial( |
49 | 0 | &mut self, |
50 | 0 | input: &mut Input, |
51 | 0 | state: &mut Self::PartialState, |
52 | 0 | ) -> ParseResult<Self::Output, <Input as StreamOnce>::Error> { |
53 | 0 | self.parse_mode_choice($crate::parser::PartialMode::default(), input, state) |
54 | 0 | } Unexecuted instantiation: <&mut _ as combine::parser::choice::ChoiceParser<_>>::parse_partial Unexecuted instantiation: <[_; 9] as combine::parser::choice::ChoiceParser<_>>::parse_partial Unexecuted instantiation: <[_; 10] as combine::parser::choice::ChoiceParser<_>>::parse_partial Unexecuted instantiation: <[_; 11] as combine::parser::choice::ChoiceParser<_>>::parse_partial Unexecuted instantiation: <[_; 12] as combine::parser::choice::ChoiceParser<_>>::parse_partial Unexecuted instantiation: <[_; 13] as combine::parser::choice::ChoiceParser<_>>::parse_partial Unexecuted instantiation: <[_; 14] as combine::parser::choice::ChoiceParser<_>>::parse_partial Unexecuted instantiation: <[_; 15] as combine::parser::choice::ChoiceParser<_>>::parse_partial Unexecuted instantiation: <[_; 16] as combine::parser::choice::ChoiceParser<_>>::parse_partial Unexecuted instantiation: <[_; 17] as combine::parser::choice::ChoiceParser<_>>::parse_partial Unexecuted instantiation: <[_; 18] as combine::parser::choice::ChoiceParser<_>>::parse_partial Unexecuted instantiation: <[_; 19] as combine::parser::choice::ChoiceParser<_>>::parse_partial Unexecuted instantiation: <[_; 20] as combine::parser::choice::ChoiceParser<_>>::parse_partial Unexecuted instantiation: <[_; 21] as combine::parser::choice::ChoiceParser<_>>::parse_partial Unexecuted instantiation: <[_; 22] as combine::parser::choice::ChoiceParser<_>>::parse_partial Unexecuted instantiation: <[_; 23] as combine::parser::choice::ChoiceParser<_>>::parse_partial Unexecuted instantiation: <[_; 24] as combine::parser::choice::ChoiceParser<_>>::parse_partial Unexecuted instantiation: <[_; 25] as combine::parser::choice::ChoiceParser<_>>::parse_partial Unexecuted instantiation: <[_; 26] as combine::parser::choice::ChoiceParser<_>>::parse_partial Unexecuted instantiation: <[_; 27] as combine::parser::choice::ChoiceParser<_>>::parse_partial Unexecuted instantiation: <[_; 28] as combine::parser::choice::ChoiceParser<_>>::parse_partial Unexecuted instantiation: <[_; 29] as combine::parser::choice::ChoiceParser<_>>::parse_partial Unexecuted instantiation: <[_; 30] as combine::parser::choice::ChoiceParser<_>>::parse_partial Unexecuted instantiation: <[_; 31] as combine::parser::choice::ChoiceParser<_>>::parse_partial Unexecuted instantiation: <[_; 32] as combine::parser::choice::ChoiceParser<_>>::parse_partial Unexecuted instantiation: <(_, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _) as combine::parser::choice::ChoiceParser<_>>::parse_partial Unexecuted instantiation: <(_, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _) as combine::parser::choice::ChoiceParser<_>>::parse_partial Unexecuted instantiation: <(_, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _) as combine::parser::choice::ChoiceParser<_>>::parse_partial Unexecuted instantiation: <(_, _, _, _, _, _, _, _, _) as combine::parser::choice::ChoiceParser<_>>::parse_partial Unexecuted instantiation: <(_, _, _, _, _, _, _, _) as combine::parser::choice::ChoiceParser<_>>::parse_partial Unexecuted instantiation: <(_, _, _, _, _, _, _) as combine::parser::choice::ChoiceParser<_>>::parse_partial Unexecuted instantiation: <(_, _, _, _, _, _) as combine::parser::choice::ChoiceParser<_>>::parse_partial Unexecuted instantiation: <(_, _, _, _, _) as combine::parser::choice::ChoiceParser<_>>::parse_partial Unexecuted instantiation: <(_, _, _, _) as combine::parser::choice::ChoiceParser<_>>::parse_partial Unexecuted instantiation: <(_, _, _) as combine::parser::choice::ChoiceParser<_>>::parse_partial Unexecuted instantiation: <(_, _) as combine::parser::choice::ChoiceParser<_>>::parse_partial Unexecuted instantiation: <(_,) as combine::parser::choice::ChoiceParser<_>>::parse_partial Unexecuted instantiation: <[_; 0] as combine::parser::choice::ChoiceParser<_>>::parse_partial Unexecuted instantiation: <[_; 1] as combine::parser::choice::ChoiceParser<_>>::parse_partial Unexecuted instantiation: <[_; 2] as combine::parser::choice::ChoiceParser<_>>::parse_partial Unexecuted instantiation: <[_; 3] as combine::parser::choice::ChoiceParser<_>>::parse_partial Unexecuted instantiation: <[_; 4] as combine::parser::choice::ChoiceParser<_>>::parse_partial Unexecuted instantiation: <[_; 5] as combine::parser::choice::ChoiceParser<_>>::parse_partial Unexecuted instantiation: <[_; 6] as combine::parser::choice::ChoiceParser<_>>::parse_partial Unexecuted instantiation: <[_; 7] as combine::parser::choice::ChoiceParser<_>>::parse_partial Unexecuted instantiation: <[_; 8] as combine::parser::choice::ChoiceParser<_>>::parse_partial Unexecuted instantiation: <(_, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _) as combine::parser::choice::ChoiceParser<_>>::parse_partial Unexecuted instantiation: <(_, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _) as combine::parser::choice::ChoiceParser<_>>::parse_partial Unexecuted instantiation: <(_, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _) as combine::parser::choice::ChoiceParser<_>>::parse_partial Unexecuted instantiation: <(_, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _) as combine::parser::choice::ChoiceParser<_>>::parse_partial Unexecuted instantiation: <(_, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _) as combine::parser::choice::ChoiceParser<_>>::parse_partial Unexecuted instantiation: <(_, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _) as combine::parser::choice::ChoiceParser<_>>::parse_partial Unexecuted instantiation: <(_, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _) as combine::parser::choice::ChoiceParser<_>>::parse_partial Unexecuted instantiation: <(_, _, _, _, _, _, _, _, _, _, _, _, _, _, _) as combine::parser::choice::ChoiceParser<_>>::parse_partial Unexecuted instantiation: <(_, _, _, _, _, _, _, _, _, _, _, _, _, _) as combine::parser::choice::ChoiceParser<_>>::parse_partial Unexecuted instantiation: <(_, _, _, _, _, _, _, _, _, _, _, _, _) as combine::parser::choice::ChoiceParser<_>>::parse_partial Unexecuted instantiation: <(_, _, _, _, _, _, _, _, _, _, _, _) as combine::parser::choice::ChoiceParser<_>>::parse_partial Unexecuted instantiation: <(_, _, _, _, _, _, _, _, _, _, _) as combine::parser::choice::ChoiceParser<_>>::parse_partial Unexecuted instantiation: <(_, _, _, _, _, _, _, _, _, _) as combine::parser::choice::ChoiceParser<_>>::parse_partial |
55 | | |
56 | 0 | fn parse_first( |
57 | 0 | &mut self, |
58 | 0 | input: &mut Input, |
59 | 0 | state: &mut Self::PartialState, |
60 | 0 | ) -> ParseResult<Self::Output, Input::Error> { |
61 | 0 | self.parse_mode_choice($crate::parser::FirstMode, input, state) |
62 | 0 | } Unexecuted instantiation: <&mut _ as combine::parser::choice::ChoiceParser<_>>::parse_first Unexecuted instantiation: <[_; 9] as combine::parser::choice::ChoiceParser<_>>::parse_first Unexecuted instantiation: <[_; 10] as combine::parser::choice::ChoiceParser<_>>::parse_first Unexecuted instantiation: <[_; 11] as combine::parser::choice::ChoiceParser<_>>::parse_first Unexecuted instantiation: <[_; 12] as combine::parser::choice::ChoiceParser<_>>::parse_first Unexecuted instantiation: <[_; 13] as combine::parser::choice::ChoiceParser<_>>::parse_first Unexecuted instantiation: <[_; 14] as combine::parser::choice::ChoiceParser<_>>::parse_first Unexecuted instantiation: <[_; 15] as combine::parser::choice::ChoiceParser<_>>::parse_first Unexecuted instantiation: <[_; 16] as combine::parser::choice::ChoiceParser<_>>::parse_first Unexecuted instantiation: <[_; 17] as combine::parser::choice::ChoiceParser<_>>::parse_first Unexecuted instantiation: <[_; 18] as combine::parser::choice::ChoiceParser<_>>::parse_first Unexecuted instantiation: <[_; 19] as combine::parser::choice::ChoiceParser<_>>::parse_first Unexecuted instantiation: <[_; 20] as combine::parser::choice::ChoiceParser<_>>::parse_first Unexecuted instantiation: <[_; 21] as combine::parser::choice::ChoiceParser<_>>::parse_first Unexecuted instantiation: <[_; 22] as combine::parser::choice::ChoiceParser<_>>::parse_first Unexecuted instantiation: <[_; 23] as combine::parser::choice::ChoiceParser<_>>::parse_first Unexecuted instantiation: <[_; 24] as combine::parser::choice::ChoiceParser<_>>::parse_first Unexecuted instantiation: <[_; 25] as combine::parser::choice::ChoiceParser<_>>::parse_first Unexecuted instantiation: <[_; 26] as combine::parser::choice::ChoiceParser<_>>::parse_first Unexecuted instantiation: <[_; 27] as combine::parser::choice::ChoiceParser<_>>::parse_first Unexecuted instantiation: <[_; 28] as combine::parser::choice::ChoiceParser<_>>::parse_first Unexecuted instantiation: <[_; 29] as combine::parser::choice::ChoiceParser<_>>::parse_first Unexecuted instantiation: <[_; 30] as combine::parser::choice::ChoiceParser<_>>::parse_first Unexecuted instantiation: <[_; 31] as combine::parser::choice::ChoiceParser<_>>::parse_first Unexecuted instantiation: <[_; 32] as combine::parser::choice::ChoiceParser<_>>::parse_first Unexecuted instantiation: <(_, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _) as combine::parser::choice::ChoiceParser<_>>::parse_first Unexecuted instantiation: <(_, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _) as combine::parser::choice::ChoiceParser<_>>::parse_first Unexecuted instantiation: <(_, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _) as combine::parser::choice::ChoiceParser<_>>::parse_first Unexecuted instantiation: <(_, _, _, _, _, _, _, _, _) as combine::parser::choice::ChoiceParser<_>>::parse_first Unexecuted instantiation: <(_, _, _, _, _, _, _, _) as combine::parser::choice::ChoiceParser<_>>::parse_first Unexecuted instantiation: <(_, _, _, _, _, _, _) as combine::parser::choice::ChoiceParser<_>>::parse_first Unexecuted instantiation: <(_, _, _, _, _, _) as combine::parser::choice::ChoiceParser<_>>::parse_first Unexecuted instantiation: <(_, _, _, _, _) as combine::parser::choice::ChoiceParser<_>>::parse_first Unexecuted instantiation: <(_, _, _, _) as combine::parser::choice::ChoiceParser<_>>::parse_first Unexecuted instantiation: <(_, _, _) as combine::parser::choice::ChoiceParser<_>>::parse_first Unexecuted instantiation: <(_, _) as combine::parser::choice::ChoiceParser<_>>::parse_first Unexecuted instantiation: <(_,) as combine::parser::choice::ChoiceParser<_>>::parse_first Unexecuted instantiation: <[_; 0] as combine::parser::choice::ChoiceParser<_>>::parse_first Unexecuted instantiation: <[_; 1] as combine::parser::choice::ChoiceParser<_>>::parse_first Unexecuted instantiation: <[_; 2] as combine::parser::choice::ChoiceParser<_>>::parse_first Unexecuted instantiation: <[_; 3] as combine::parser::choice::ChoiceParser<_>>::parse_first Unexecuted instantiation: <[_; 4] as combine::parser::choice::ChoiceParser<_>>::parse_first Unexecuted instantiation: <[_; 5] as combine::parser::choice::ChoiceParser<_>>::parse_first Unexecuted instantiation: <[_; 6] as combine::parser::choice::ChoiceParser<_>>::parse_first Unexecuted instantiation: <[_; 7] as combine::parser::choice::ChoiceParser<_>>::parse_first Unexecuted instantiation: <[_; 8] as combine::parser::choice::ChoiceParser<_>>::parse_first Unexecuted instantiation: <(_, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _) as combine::parser::choice::ChoiceParser<_>>::parse_first Unexecuted instantiation: <(_, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _) as combine::parser::choice::ChoiceParser<_>>::parse_first Unexecuted instantiation: <(_, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _) as combine::parser::choice::ChoiceParser<_>>::parse_first Unexecuted instantiation: <(_, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _) as combine::parser::choice::ChoiceParser<_>>::parse_first Unexecuted instantiation: <(_, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _) as combine::parser::choice::ChoiceParser<_>>::parse_first Unexecuted instantiation: <(_, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _) as combine::parser::choice::ChoiceParser<_>>::parse_first Unexecuted instantiation: <(_, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _) as combine::parser::choice::ChoiceParser<_>>::parse_first Unexecuted instantiation: <(_, _, _, _, _, _, _, _, _, _, _, _, _, _, _) as combine::parser::choice::ChoiceParser<_>>::parse_first Unexecuted instantiation: <(_, _, _, _, _, _, _, _, _, _, _, _, _, _) as combine::parser::choice::ChoiceParser<_>>::parse_first Unexecuted instantiation: <(_, _, _, _, _, _, _, _, _, _, _, _, _) as combine::parser::choice::ChoiceParser<_>>::parse_first Unexecuted instantiation: <(_, _, _, _, _, _, _, _, _, _, _, _) as combine::parser::choice::ChoiceParser<_>>::parse_first Unexecuted instantiation: <(_, _, _, _, _, _, _, _, _, _, _) as combine::parser::choice::ChoiceParser<_>>::parse_first Unexecuted instantiation: <(_, _, _, _, _, _, _, _, _, _) as combine::parser::choice::ChoiceParser<_>>::parse_first |
63 | | }; |
64 | | } |
65 | | |
66 | | /// `ChoiceParser` represents a parser which may parse one of several different choices depending |
67 | | /// on the input. |
68 | | /// |
69 | | /// This is an internal trait used to overload the `choice` function. |
70 | | pub trait ChoiceParser<Input: Stream> { |
71 | | type Output; |
72 | | type PartialState: Default; |
73 | | |
74 | | fn parse_first( |
75 | | &mut self, |
76 | | input: &mut Input, |
77 | | state: &mut Self::PartialState, |
78 | | ) -> ParseResult<Self::Output, <Input as StreamOnce>::Error>; |
79 | | |
80 | | fn parse_partial( |
81 | | &mut self, |
82 | | input: &mut Input, |
83 | | state: &mut Self::PartialState, |
84 | | ) -> ParseResult<Self::Output, <Input as StreamOnce>::Error>; |
85 | | |
86 | | fn parse_mode_choice<M>( |
87 | | &mut self, |
88 | | mode: M, |
89 | | input: &mut Input, |
90 | | state: &mut Self::PartialState, |
91 | | ) -> ParseResult<Self::Output, <Input as StreamOnce>::Error> |
92 | | where |
93 | | M: ParseMode, |
94 | | Self: Sized; |
95 | | |
96 | | fn add_error_choice(&mut self, error: &mut Tracked<<Input as StreamOnce>::Error>); |
97 | | } |
98 | | |
99 | | impl<'a, Input, P> ChoiceParser<Input> for &'a mut P |
100 | | where |
101 | | Input: Stream, |
102 | | P: ?Sized + ChoiceParser<Input>, |
103 | | { |
104 | | type Output = P::Output; |
105 | | type PartialState = P::PartialState; |
106 | | |
107 | | parse_mode_choice!(Input); |
108 | | #[inline] |
109 | 0 | fn parse_mode_choice<M>( |
110 | 0 | &mut self, |
111 | 0 | mode: M, |
112 | 0 | input: &mut Input, |
113 | 0 | state: &mut Self::PartialState, |
114 | 0 | ) -> ParseResult<Self::Output, <Input as StreamOnce>::Error> |
115 | 0 | where |
116 | 0 | M: ParseMode, |
117 | | { |
118 | 0 | if mode.is_first() { |
119 | 0 | (**self).parse_first(input, state) |
120 | | } else { |
121 | 0 | (**self).parse_partial(input, state) |
122 | | } |
123 | 0 | } |
124 | | |
125 | 0 | fn add_error_choice(&mut self, error: &mut Tracked<<Input as StreamOnce>::Error>) { |
126 | 0 | (**self).add_error_choice(error) |
127 | 0 | } |
128 | | } |
129 | | |
130 | | macro_rules! merge { |
131 | | ($head: ident) => { |
132 | | $head.error |
133 | | }; |
134 | | ($head: ident $($tail: ident)+) => { |
135 | | $head.error.merge(merge!($($tail)+)) |
136 | | }; |
137 | | } |
138 | | |
139 | | macro_rules! do_choice { |
140 | | ( |
141 | | $input: ident |
142 | | $before_position: ident |
143 | | $before: ident |
144 | | $partial_state: ident |
145 | | $state: ident |
146 | | ( ) |
147 | | $($parser: ident $error: ident)+ |
148 | | ) => { { |
149 | | let mut error = Tracked::from(merge!($($error)+)); |
150 | | // If offset != 1 then the nested parser is a sequence of parsers where 1 or |
151 | | // more parsers returned `PeekOk` before the parser finally failed with |
152 | | // `PeekErr`. Since we lose the offsets of the nested parsers when we merge |
153 | | // the errors we must first extract the errors before we do the merge. |
154 | | // If the offset == 0 on the other hand (which should be the common case) then |
155 | | // we can delay the addition of the error since we know for certain that only |
156 | | // the first parser in the sequence were tried |
157 | | $( |
158 | | if $error.offset != ErrorOffset(1) { |
159 | | error.offset = $error.offset; |
160 | | $parser.add_error(&mut error); |
161 | | error.offset = ErrorOffset(0); |
162 | | } |
163 | | )+ |
164 | | PeekErr(error) |
165 | | } }; |
166 | | ( |
167 | | $input: ident |
168 | | $before_position: ident |
169 | | $before: ident |
170 | | $partial_state: ident |
171 | | $state: ident |
172 | | ( $head: ident $($tail: ident)* ) |
173 | | $($all: ident)* |
174 | | ) => { { |
175 | | let parser = $head; |
176 | | let mut state = $head::PartialState::default(); |
177 | | match parser.parse_mode(crate::parser::FirstMode, $input, &mut state) { |
178 | | CommitOk(x) => CommitOk(x), |
179 | | PeekOk(x) => PeekOk(x), |
180 | | CommitErr(err) => { |
181 | | // If we get `CommitErr` but the input is the same this is a partial parse we |
182 | | // cannot commit to so leave the state as `Peek` to retry all the parsers |
183 | | // on the next call to `parse_partial` |
184 | | if $input.position() != $before_position { |
185 | | *$state = self::$partial_state::$head(state); |
186 | | } |
187 | | CommitErr(err) |
188 | | } |
189 | | PeekErr($head) => { |
190 | | ctry!($input.reset($before.clone()).committed()); |
191 | | do_choice!( |
192 | | $input |
193 | | $before_position |
194 | | $before |
195 | | $partial_state |
196 | | $state |
197 | | ( $($tail)* ) |
198 | | $($all)* |
199 | | parser |
200 | | $head |
201 | | ) |
202 | | } |
203 | | } |
204 | | } } |
205 | | } |
206 | | |
207 | | macro_rules! tuple_choice_parser { |
208 | | ($head: ident) => { |
209 | | tuple_choice_parser_inner!($head; $head); |
210 | | }; |
211 | | ($head: ident $($id: ident)+) => { |
212 | | tuple_choice_parser_inner!($head; $head $($id)+); |
213 | | tuple_choice_parser!($($id)+); |
214 | | }; |
215 | | } |
216 | | |
217 | | macro_rules! tuple_choice_parser_inner { |
218 | | ($partial_state: ident; $($id: ident)+) => { |
219 | | #[doc(hidden)] |
220 | | pub enum $partial_state<$($id),+> { |
221 | | Peek, |
222 | | $( |
223 | | $id($id), |
224 | | )+ |
225 | | } |
226 | | |
227 | | impl<$($id),+> Default for self::$partial_state<$($id),+> { |
228 | 0 | fn default() -> Self { |
229 | 0 | self::$partial_state::Peek |
230 | 0 | } Unexecuted instantiation: <combine::parser::choice::A<_, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _> as core::default::Default>::default Unexecuted instantiation: <combine::parser::choice::B<_, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _> as core::default::Default>::default Unexecuted instantiation: <combine::parser::choice::C<_, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _> as core::default::Default>::default Unexecuted instantiation: <combine::parser::choice::D<_, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _> as core::default::Default>::default Unexecuted instantiation: <combine::parser::choice::R<_, _, _, _, _, _, _, _> as core::default::Default>::default Unexecuted instantiation: <combine::parser::choice::S<_, _, _, _, _, _, _> as core::default::Default>::default Unexecuted instantiation: <combine::parser::choice::T<_, _, _, _, _, _> as core::default::Default>::default Unexecuted instantiation: <combine::parser::choice::U<_, _, _, _, _> as core::default::Default>::default Unexecuted instantiation: <combine::parser::choice::V<_, _, _, _> as core::default::Default>::default Unexecuted instantiation: <combine::parser::choice::X<_, _, _> as core::default::Default>::default Unexecuted instantiation: <combine::parser::choice::Y<_, _> as core::default::Default>::default Unexecuted instantiation: <combine::parser::choice::Z<_> as core::default::Default>::default Unexecuted instantiation: <combine::parser::choice::E<_, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _> as core::default::Default>::default Unexecuted instantiation: <combine::parser::choice::F<_, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _> as core::default::Default>::default Unexecuted instantiation: <combine::parser::choice::G<_, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _> as core::default::Default>::default Unexecuted instantiation: <combine::parser::choice::H<_, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _> as core::default::Default>::default Unexecuted instantiation: <combine::parser::choice::I<_, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _> as core::default::Default>::default Unexecuted instantiation: <combine::parser::choice::J<_, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _> as core::default::Default>::default Unexecuted instantiation: <combine::parser::choice::K<_, _, _, _, _, _, _, _, _, _, _, _, _, _, _> as core::default::Default>::default Unexecuted instantiation: <combine::parser::choice::L<_, _, _, _, _, _, _, _, _, _, _, _, _, _> as core::default::Default>::default Unexecuted instantiation: <combine::parser::choice::M<_, _, _, _, _, _, _, _, _, _, _, _, _> as core::default::Default>::default Unexecuted instantiation: <combine::parser::choice::N<_, _, _, _, _, _, _, _, _, _, _, _> as core::default::Default>::default Unexecuted instantiation: <combine::parser::choice::O<_, _, _, _, _, _, _, _, _, _, _> as core::default::Default>::default Unexecuted instantiation: <combine::parser::choice::P<_, _, _, _, _, _, _, _, _, _> as core::default::Default>::default Unexecuted instantiation: <combine::parser::choice::Q<_, _, _, _, _, _, _, _, _> as core::default::Default>::default |
231 | | } |
232 | | |
233 | | #[allow(non_snake_case)] |
234 | | impl<Input, Output $(,$id)+> ChoiceParser<Input> for ($($id,)+) |
235 | | where |
236 | | Input: Stream, |
237 | | $($id: Parser< Input, Output = Output>),+ |
238 | | { |
239 | | |
240 | | type Output = Output; |
241 | | type PartialState = self::$partial_state<$($id::PartialState),+>; |
242 | | |
243 | | parse_mode_choice!(Input); |
244 | | #[inline] |
245 | 0 | fn parse_mode_choice<Mode>( |
246 | 0 | &mut self, |
247 | 0 | mode: Mode, |
248 | 0 | input: &mut Input, |
249 | 0 | state: &mut Self::PartialState, |
250 | 0 | ) -> ParseResult<Self::Output, <Input as StreamOnce>::Error> |
251 | 0 | where |
252 | 0 | Mode: ParseMode, |
253 | | { |
254 | 0 | let ($(ref mut $id,)+) = *self; |
255 | 0 | let empty = match *state { |
256 | 0 | self::$partial_state::Peek => true, |
257 | 0 | _ => false, |
258 | | }; |
259 | 0 | if mode.is_first() || empty { |
260 | 0 | let before_position = input.position(); |
261 | 0 | let before = input.checkpoint(); |
262 | 0 | do_choice!(input before_position before $partial_state state ( $($id)+ ) ) |
263 | | } else { |
264 | 0 | match *state { |
265 | 0 | self::$partial_state::Peek => unreachable!(), |
266 | | $( |
267 | | self::$partial_state::$id(_) => { |
268 | 0 | let result = match *state { |
269 | 0 | self::$partial_state::$id(ref mut state) => { |
270 | 0 | $id.parse_mode(mode, input, state) |
271 | | } |
272 | 0 | _ => unreachable!() |
273 | | }; |
274 | 0 | if result.is_ok() { |
275 | 0 | *state = self::$partial_state::Peek; |
276 | 0 | } |
277 | 0 | result |
278 | | } |
279 | | )+ |
280 | | } |
281 | | } |
282 | 0 | } Unexecuted instantiation: <(_, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _) as combine::parser::choice::ChoiceParser<_>>::parse_mode_choice::<_> Unexecuted instantiation: <(_, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _) as combine::parser::choice::ChoiceParser<_>>::parse_mode_choice::<_> Unexecuted instantiation: <(_, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _) as combine::parser::choice::ChoiceParser<_>>::parse_mode_choice::<_> Unexecuted instantiation: <(_, _, _, _, _, _, _, _, _) as combine::parser::choice::ChoiceParser<_>>::parse_mode_choice::<_> Unexecuted instantiation: <(_, _, _, _, _, _, _, _) as combine::parser::choice::ChoiceParser<_>>::parse_mode_choice::<_> Unexecuted instantiation: <(_, _, _, _, _, _, _) as combine::parser::choice::ChoiceParser<_>>::parse_mode_choice::<_> Unexecuted instantiation: <(_, _, _, _, _, _) as combine::parser::choice::ChoiceParser<_>>::parse_mode_choice::<_> Unexecuted instantiation: <(_, _, _, _, _) as combine::parser::choice::ChoiceParser<_>>::parse_mode_choice::<_> Unexecuted instantiation: <(_, _, _, _) as combine::parser::choice::ChoiceParser<_>>::parse_mode_choice::<_> Unexecuted instantiation: <(_, _, _) as combine::parser::choice::ChoiceParser<_>>::parse_mode_choice::<_> Unexecuted instantiation: <(_, _) as combine::parser::choice::ChoiceParser<_>>::parse_mode_choice::<_> Unexecuted instantiation: <(_,) as combine::parser::choice::ChoiceParser<_>>::parse_mode_choice::<_> Unexecuted instantiation: <(_, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _) as combine::parser::choice::ChoiceParser<_>>::parse_mode_choice::<_> Unexecuted instantiation: <(_, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _) as combine::parser::choice::ChoiceParser<_>>::parse_mode_choice::<_> Unexecuted instantiation: <(_, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _) as combine::parser::choice::ChoiceParser<_>>::parse_mode_choice::<_> Unexecuted instantiation: <(_, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _) as combine::parser::choice::ChoiceParser<_>>::parse_mode_choice::<_> Unexecuted instantiation: <(_, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _) as combine::parser::choice::ChoiceParser<_>>::parse_mode_choice::<_> Unexecuted instantiation: <(_, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _) as combine::parser::choice::ChoiceParser<_>>::parse_mode_choice::<_> Unexecuted instantiation: <(_, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _) as combine::parser::choice::ChoiceParser<_>>::parse_mode_choice::<_> Unexecuted instantiation: <(_, _, _, _, _, _, _, _, _, _, _, _, _, _, _) as combine::parser::choice::ChoiceParser<_>>::parse_mode_choice::<_> Unexecuted instantiation: <(_, _, _, _, _, _, _, _, _, _, _, _, _, _) as combine::parser::choice::ChoiceParser<_>>::parse_mode_choice::<_> Unexecuted instantiation: <(_, _, _, _, _, _, _, _, _, _, _, _, _) as combine::parser::choice::ChoiceParser<_>>::parse_mode_choice::<_> Unexecuted instantiation: <(_, _, _, _, _, _, _, _, _, _, _, _) as combine::parser::choice::ChoiceParser<_>>::parse_mode_choice::<_> Unexecuted instantiation: <(_, _, _, _, _, _, _, _, _, _, _) as combine::parser::choice::ChoiceParser<_>>::parse_mode_choice::<_> Unexecuted instantiation: <(_, _, _, _, _, _, _, _, _, _) as combine::parser::choice::ChoiceParser<_>>::parse_mode_choice::<_> |
283 | | |
284 | 0 | fn add_error_choice( |
285 | 0 | &mut self, |
286 | 0 | error: &mut Tracked<<Input as StreamOnce>::Error> |
287 | 0 | ) { |
288 | 0 | if error.offset != ErrorOffset(0) { |
289 | 0 | let ($(ref mut $id,)+) = *self; |
290 | 0 | // Reset the offset to 1 on every add so that we always (and only) takes the |
291 | 0 | // error of the first parser. If we don't do this the first parser will consume |
292 | 0 | // the offset to the detriment for all the other parsers. |
293 | 0 | $( |
294 | 0 | error.offset = ErrorOffset(1); |
295 | 0 | $id.add_error(error); |
296 | 0 | )+ |
297 | 0 | } |
298 | 0 | } Unexecuted instantiation: <(_, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _) as combine::parser::choice::ChoiceParser<_>>::add_error_choice Unexecuted instantiation: <(_, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _) as combine::parser::choice::ChoiceParser<_>>::add_error_choice Unexecuted instantiation: <(_, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _) as combine::parser::choice::ChoiceParser<_>>::add_error_choice Unexecuted instantiation: <(_, _, _, _, _, _, _, _, _) as combine::parser::choice::ChoiceParser<_>>::add_error_choice Unexecuted instantiation: <(_, _, _, _, _, _, _, _) as combine::parser::choice::ChoiceParser<_>>::add_error_choice Unexecuted instantiation: <(_, _, _, _, _, _, _) as combine::parser::choice::ChoiceParser<_>>::add_error_choice Unexecuted instantiation: <(_, _, _, _, _, _) as combine::parser::choice::ChoiceParser<_>>::add_error_choice Unexecuted instantiation: <(_, _, _, _, _) as combine::parser::choice::ChoiceParser<_>>::add_error_choice Unexecuted instantiation: <(_, _, _, _) as combine::parser::choice::ChoiceParser<_>>::add_error_choice Unexecuted instantiation: <(_, _, _) as combine::parser::choice::ChoiceParser<_>>::add_error_choice Unexecuted instantiation: <(_, _) as combine::parser::choice::ChoiceParser<_>>::add_error_choice Unexecuted instantiation: <(_,) as combine::parser::choice::ChoiceParser<_>>::add_error_choice Unexecuted instantiation: <(_, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _) as combine::parser::choice::ChoiceParser<_>>::add_error_choice Unexecuted instantiation: <(_, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _) as combine::parser::choice::ChoiceParser<_>>::add_error_choice Unexecuted instantiation: <(_, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _) as combine::parser::choice::ChoiceParser<_>>::add_error_choice Unexecuted instantiation: <(_, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _) as combine::parser::choice::ChoiceParser<_>>::add_error_choice Unexecuted instantiation: <(_, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _) as combine::parser::choice::ChoiceParser<_>>::add_error_choice Unexecuted instantiation: <(_, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _) as combine::parser::choice::ChoiceParser<_>>::add_error_choice Unexecuted instantiation: <(_, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _) as combine::parser::choice::ChoiceParser<_>>::add_error_choice Unexecuted instantiation: <(_, _, _, _, _, _, _, _, _, _, _, _, _, _, _) as combine::parser::choice::ChoiceParser<_>>::add_error_choice Unexecuted instantiation: <(_, _, _, _, _, _, _, _, _, _, _, _, _, _) as combine::parser::choice::ChoiceParser<_>>::add_error_choice Unexecuted instantiation: <(_, _, _, _, _, _, _, _, _, _, _, _, _) as combine::parser::choice::ChoiceParser<_>>::add_error_choice Unexecuted instantiation: <(_, _, _, _, _, _, _, _, _, _, _, _) as combine::parser::choice::ChoiceParser<_>>::add_error_choice Unexecuted instantiation: <(_, _, _, _, _, _, _, _, _, _, _) as combine::parser::choice::ChoiceParser<_>>::add_error_choice Unexecuted instantiation: <(_, _, _, _, _, _, _, _, _, _) as combine::parser::choice::ChoiceParser<_>>::add_error_choice |
299 | | } |
300 | | } |
301 | | } |
302 | | |
303 | | tuple_choice_parser!(A B C D E F G H I J K L M N O P Q R S T U V X Y Z); |
304 | | |
305 | | macro_rules! array_choice_parser { |
306 | | ($($t: tt)+) => { |
307 | | $( |
308 | | impl<Input, P> ChoiceParser<Input> for [P; $t] |
309 | | where |
310 | | Input: Stream, |
311 | | P: Parser<Input>, |
312 | | { |
313 | | |
314 | | type Output = P::Output; |
315 | | type PartialState = <[P] as ChoiceParser<Input>>::PartialState; |
316 | | |
317 | | parse_mode_choice!(Input); |
318 | | #[inline] |
319 | 0 | fn parse_mode_choice<M>( |
320 | 0 | &mut self, |
321 | 0 | mode: M, |
322 | 0 | input: &mut Input, |
323 | 0 | state: &mut Self::PartialState, |
324 | 0 | ) -> ParseResult<Self::Output, <Input as StreamOnce>::Error> |
325 | 0 | where |
326 | 0 | M: ParseMode, |
327 | | { |
328 | 0 | if mode.is_first() { |
329 | 0 | self[..].parse_first(input, state) |
330 | | } else { |
331 | 0 | self[..].parse_partial(input, state) |
332 | | } |
333 | 0 | } Unexecuted instantiation: <[_; 9] as combine::parser::choice::ChoiceParser<_>>::parse_mode_choice::<_> Unexecuted instantiation: <[_; 10] as combine::parser::choice::ChoiceParser<_>>::parse_mode_choice::<_> Unexecuted instantiation: <[_; 11] as combine::parser::choice::ChoiceParser<_>>::parse_mode_choice::<_> Unexecuted instantiation: <[_; 12] as combine::parser::choice::ChoiceParser<_>>::parse_mode_choice::<_> Unexecuted instantiation: <[_; 13] as combine::parser::choice::ChoiceParser<_>>::parse_mode_choice::<_> Unexecuted instantiation: <[_; 14] as combine::parser::choice::ChoiceParser<_>>::parse_mode_choice::<_> Unexecuted instantiation: <[_; 15] as combine::parser::choice::ChoiceParser<_>>::parse_mode_choice::<_> Unexecuted instantiation: <[_; 16] as combine::parser::choice::ChoiceParser<_>>::parse_mode_choice::<_> Unexecuted instantiation: <[_; 17] as combine::parser::choice::ChoiceParser<_>>::parse_mode_choice::<_> Unexecuted instantiation: <[_; 18] as combine::parser::choice::ChoiceParser<_>>::parse_mode_choice::<_> Unexecuted instantiation: <[_; 19] as combine::parser::choice::ChoiceParser<_>>::parse_mode_choice::<_> Unexecuted instantiation: <[_; 20] as combine::parser::choice::ChoiceParser<_>>::parse_mode_choice::<_> Unexecuted instantiation: <[_; 21] as combine::parser::choice::ChoiceParser<_>>::parse_mode_choice::<_> Unexecuted instantiation: <[_; 22] as combine::parser::choice::ChoiceParser<_>>::parse_mode_choice::<_> Unexecuted instantiation: <[_; 23] as combine::parser::choice::ChoiceParser<_>>::parse_mode_choice::<_> Unexecuted instantiation: <[_; 24] as combine::parser::choice::ChoiceParser<_>>::parse_mode_choice::<_> Unexecuted instantiation: <[_; 25] as combine::parser::choice::ChoiceParser<_>>::parse_mode_choice::<_> Unexecuted instantiation: <[_; 26] as combine::parser::choice::ChoiceParser<_>>::parse_mode_choice::<_> Unexecuted instantiation: <[_; 27] as combine::parser::choice::ChoiceParser<_>>::parse_mode_choice::<_> Unexecuted instantiation: <[_; 28] as combine::parser::choice::ChoiceParser<_>>::parse_mode_choice::<_> Unexecuted instantiation: <[_; 29] as combine::parser::choice::ChoiceParser<_>>::parse_mode_choice::<_> Unexecuted instantiation: <[_; 30] as combine::parser::choice::ChoiceParser<_>>::parse_mode_choice::<_> Unexecuted instantiation: <[_; 31] as combine::parser::choice::ChoiceParser<_>>::parse_mode_choice::<_> Unexecuted instantiation: <[_; 32] as combine::parser::choice::ChoiceParser<_>>::parse_mode_choice::<_> Unexecuted instantiation: <[_; 0] as combine::parser::choice::ChoiceParser<_>>::parse_mode_choice::<_> Unexecuted instantiation: <[_; 1] as combine::parser::choice::ChoiceParser<_>>::parse_mode_choice::<_> Unexecuted instantiation: <[_; 2] as combine::parser::choice::ChoiceParser<_>>::parse_mode_choice::<_> Unexecuted instantiation: <[_; 3] as combine::parser::choice::ChoiceParser<_>>::parse_mode_choice::<_> Unexecuted instantiation: <[_; 4] as combine::parser::choice::ChoiceParser<_>>::parse_mode_choice::<_> Unexecuted instantiation: <[_; 5] as combine::parser::choice::ChoiceParser<_>>::parse_mode_choice::<_> Unexecuted instantiation: <[_; 6] as combine::parser::choice::ChoiceParser<_>>::parse_mode_choice::<_> Unexecuted instantiation: <[_; 7] as combine::parser::choice::ChoiceParser<_>>::parse_mode_choice::<_> Unexecuted instantiation: <[_; 8] as combine::parser::choice::ChoiceParser<_>>::parse_mode_choice::<_> |
334 | 0 | fn add_error_choice( |
335 | 0 | &mut self, |
336 | 0 | error: &mut Tracked<<Input as StreamOnce>::Error> |
337 | 0 | ) { |
338 | 0 | self[..].add_error_choice(error) |
339 | 0 | } Unexecuted instantiation: <[_; 9] as combine::parser::choice::ChoiceParser<_>>::add_error_choice Unexecuted instantiation: <[_; 10] as combine::parser::choice::ChoiceParser<_>>::add_error_choice Unexecuted instantiation: <[_; 11] as combine::parser::choice::ChoiceParser<_>>::add_error_choice Unexecuted instantiation: <[_; 12] as combine::parser::choice::ChoiceParser<_>>::add_error_choice Unexecuted instantiation: <[_; 13] as combine::parser::choice::ChoiceParser<_>>::add_error_choice Unexecuted instantiation: <[_; 14] as combine::parser::choice::ChoiceParser<_>>::add_error_choice Unexecuted instantiation: <[_; 15] as combine::parser::choice::ChoiceParser<_>>::add_error_choice Unexecuted instantiation: <[_; 16] as combine::parser::choice::ChoiceParser<_>>::add_error_choice Unexecuted instantiation: <[_; 17] as combine::parser::choice::ChoiceParser<_>>::add_error_choice Unexecuted instantiation: <[_; 18] as combine::parser::choice::ChoiceParser<_>>::add_error_choice Unexecuted instantiation: <[_; 19] as combine::parser::choice::ChoiceParser<_>>::add_error_choice Unexecuted instantiation: <[_; 20] as combine::parser::choice::ChoiceParser<_>>::add_error_choice Unexecuted instantiation: <[_; 21] as combine::parser::choice::ChoiceParser<_>>::add_error_choice Unexecuted instantiation: <[_; 22] as combine::parser::choice::ChoiceParser<_>>::add_error_choice Unexecuted instantiation: <[_; 23] as combine::parser::choice::ChoiceParser<_>>::add_error_choice Unexecuted instantiation: <[_; 24] as combine::parser::choice::ChoiceParser<_>>::add_error_choice Unexecuted instantiation: <[_; 25] as combine::parser::choice::ChoiceParser<_>>::add_error_choice Unexecuted instantiation: <[_; 26] as combine::parser::choice::ChoiceParser<_>>::add_error_choice Unexecuted instantiation: <[_; 27] as combine::parser::choice::ChoiceParser<_>>::add_error_choice Unexecuted instantiation: <[_; 28] as combine::parser::choice::ChoiceParser<_>>::add_error_choice Unexecuted instantiation: <[_; 29] as combine::parser::choice::ChoiceParser<_>>::add_error_choice Unexecuted instantiation: <[_; 30] as combine::parser::choice::ChoiceParser<_>>::add_error_choice Unexecuted instantiation: <[_; 31] as combine::parser::choice::ChoiceParser<_>>::add_error_choice Unexecuted instantiation: <[_; 32] as combine::parser::choice::ChoiceParser<_>>::add_error_choice Unexecuted instantiation: <[_; 0] as combine::parser::choice::ChoiceParser<_>>::add_error_choice Unexecuted instantiation: <[_; 1] as combine::parser::choice::ChoiceParser<_>>::add_error_choice Unexecuted instantiation: <[_; 2] as combine::parser::choice::ChoiceParser<_>>::add_error_choice Unexecuted instantiation: <[_; 3] as combine::parser::choice::ChoiceParser<_>>::add_error_choice Unexecuted instantiation: <[_; 4] as combine::parser::choice::ChoiceParser<_>>::add_error_choice Unexecuted instantiation: <[_; 5] as combine::parser::choice::ChoiceParser<_>>::add_error_choice Unexecuted instantiation: <[_; 6] as combine::parser::choice::ChoiceParser<_>>::add_error_choice Unexecuted instantiation: <[_; 7] as combine::parser::choice::ChoiceParser<_>>::add_error_choice Unexecuted instantiation: <[_; 8] as combine::parser::choice::ChoiceParser<_>>::add_error_choice |
340 | | } |
341 | | )+ |
342 | | }; |
343 | | } |
344 | | |
345 | | #[rustfmt::skip] |
346 | | array_choice_parser!( |
347 | | 0 1 2 3 4 5 6 7 8 9 |
348 | | 10 11 12 13 14 15 16 17 18 19 |
349 | | 20 21 22 23 24 25 26 27 28 29 |
350 | | 30 31 32 |
351 | | ); |
352 | | |
353 | | #[derive(Copy, Clone)] |
354 | | pub struct Choice<P>(P); |
355 | | |
356 | | impl<Input, P> Parser<Input> for Choice<P> |
357 | | where |
358 | | Input: Stream, |
359 | | P: ChoiceParser<Input>, |
360 | | { |
361 | | type Output = P::Output; |
362 | | type PartialState = P::PartialState; |
363 | | |
364 | | parse_mode!(Input); |
365 | | #[inline] |
366 | 0 | fn parse_mode_impl<M>( |
367 | 0 | &mut self, |
368 | 0 | mode: M, |
369 | 0 | input: &mut Input, |
370 | 0 | state: &mut Self::PartialState, |
371 | 0 | ) -> ParseResult<Self::Output, <Input as StreamOnce>::Error> |
372 | 0 | where |
373 | 0 | M: ParseMode, |
374 | | { |
375 | 0 | self.0.parse_mode_choice(mode, input, state) |
376 | 0 | } |
377 | | |
378 | 0 | fn add_error(&mut self, error: &mut Tracked<<Input as StreamOnce>::Error>) { |
379 | 0 | let before = error.offset.0; |
380 | 0 | self.0.add_error_choice(error); |
381 | 0 | error.offset.0 = before.saturating_sub(1); |
382 | 0 | } |
383 | | } |
384 | | |
385 | 0 | fn slice_parse_mode<Input, P, M>( |
386 | 0 | self_: &mut [P], |
387 | 0 | mode: M, |
388 | 0 | input: &mut Input, |
389 | 0 | state: &mut (usize, P::PartialState), |
390 | 0 | ) -> ParseResult<P::Output, <Input as StreamOnce>::Error> |
391 | 0 | where |
392 | 0 | P: Parser<Input>, |
393 | 0 | Input: Stream, |
394 | 0 | M: ParseMode, |
395 | | { |
396 | 0 | let mut prev_err = None; |
397 | 0 | let mut last_parser_having_non_1_offset = 0; |
398 | 0 | let before = input.checkpoint(); |
399 | | |
400 | 0 | let (ref mut index_state, ref mut child_state) = *state; |
401 | 0 | if !mode.is_first() && *index_state != 0 { |
402 | 0 | return self_[*index_state - 1] |
403 | 0 | .parse_partial(input, child_state) |
404 | 0 | .map(|x| { |
405 | 0 | *index_state = 0; |
406 | 0 | x |
407 | 0 | }); |
408 | 0 | } |
409 | | |
410 | 0 | for i in 0..self_.len() { |
411 | 0 | ctry!(input.reset(before.clone()).committed()); |
412 | | |
413 | 0 | match self_[i].parse_mode(mode, input, child_state) { |
414 | 0 | committed_err @ CommitErr(_) => { |
415 | 0 | *index_state = i + 1; |
416 | 0 | return committed_err; |
417 | | } |
418 | 0 | PeekErr(err) => { |
419 | 0 | prev_err = match prev_err { |
420 | 0 | None => Some(err), |
421 | 0 | Some(mut prev_err) => { |
422 | 0 | if prev_err.offset != ErrorOffset(1) { |
423 | | // First add the errors of all the preceding parsers which did not |
424 | | // have a sequence of parsers returning `PeekOk` before failing |
425 | | // with `PeekErr`. |
426 | 0 | let offset = prev_err.offset; |
427 | 0 | for p in &mut self_[last_parser_having_non_1_offset..(i - 1)] { |
428 | 0 | prev_err.offset = ErrorOffset(1); |
429 | 0 | p.add_error(&mut prev_err); |
430 | 0 | } |
431 | | // Then add the errors if the current parser |
432 | 0 | prev_err.offset = offset; |
433 | 0 | self_[i - 1].add_error(&mut prev_err); |
434 | 0 | last_parser_having_non_1_offset = i; |
435 | 0 | } |
436 | 0 | Some(Tracked { |
437 | 0 | error: prev_err.error.merge(err.error), |
438 | 0 | offset: err.offset, |
439 | 0 | }) |
440 | | } |
441 | | }; |
442 | | } |
443 | 0 | ok @ CommitOk(_) | ok @ PeekOk(_) => { |
444 | 0 | *index_state = 0; |
445 | 0 | return ok; |
446 | | } |
447 | | } |
448 | | } |
449 | 0 | PeekErr(match prev_err { |
450 | 0 | None => Input::Error::from_error( |
451 | 0 | input.position(), |
452 | 0 | StreamError::message_static_message("parser choice is empty"), |
453 | | ) |
454 | 0 | .into(), |
455 | 0 | Some(mut prev_err) => { |
456 | 0 | if prev_err.offset != ErrorOffset(1) { |
457 | 0 | let offset = prev_err.offset; |
458 | 0 | let len = self_.len(); |
459 | 0 | for p in &mut self_[last_parser_having_non_1_offset..(len - 1)] { |
460 | 0 | prev_err.offset = ErrorOffset(1); |
461 | 0 | p.add_error(&mut prev_err); |
462 | 0 | } |
463 | 0 | prev_err.offset = offset; |
464 | 0 | self_.last_mut().unwrap().add_error(&mut prev_err); |
465 | 0 | prev_err.offset = ErrorOffset(0); |
466 | 0 | } |
467 | 0 | prev_err |
468 | | } |
469 | | }) |
470 | 0 | } |
471 | | |
472 | | impl<Input, O, P> ChoiceParser<Input> for [P] |
473 | | where |
474 | | Input: Stream, |
475 | | P: Parser<Input, Output = O>, |
476 | | { |
477 | | type Output = O; |
478 | | type PartialState = (usize, P::PartialState); |
479 | | |
480 | | #[inline] |
481 | 0 | fn parse_partial( |
482 | 0 | &mut self, |
483 | 0 | input: &mut Input, |
484 | 0 | state: &mut Self::PartialState, |
485 | 0 | ) -> ParseResult<Self::Output, <Input as StreamOnce>::Error> { |
486 | 0 | slice_parse_mode(self, crate::parser::PartialMode::default(), input, state) |
487 | 0 | } |
488 | | |
489 | | #[inline] |
490 | 0 | fn parse_first( |
491 | 0 | &mut self, |
492 | 0 | input: &mut Input, |
493 | 0 | state: &mut Self::PartialState, |
494 | 0 | ) -> ParseResult<Self::Output, <Input as StreamOnce>::Error> { |
495 | 0 | slice_parse_mode(self, crate::parser::FirstMode, input, state) |
496 | 0 | } |
497 | | |
498 | | #[allow(dead_code)] // this needs to be there for rust 1.85 |
499 | | #[inline] |
500 | 0 | fn parse_mode_choice<M>( |
501 | 0 | &mut self, |
502 | 0 | _mode: M, |
503 | 0 | _input: &mut Input, |
504 | 0 | _state: &mut Self::PartialState, |
505 | 0 | ) -> ParseResult<Self::Output, <Input as StreamOnce>::Error> |
506 | 0 | where |
507 | 0 | M: ParseMode, |
508 | | { |
509 | 0 | unreachable!() |
510 | | } |
511 | | |
512 | 0 | fn add_error_choice(&mut self, error: &mut Tracked<<Input as StreamOnce>::Error>) { |
513 | 0 | if error.offset != ErrorOffset(0) { |
514 | 0 | for p in self { |
515 | 0 | error.offset = ErrorOffset(1); |
516 | 0 | p.add_error(error); |
517 | 0 | } |
518 | 0 | } |
519 | 0 | } |
520 | | } |
521 | | |
522 | | /// Takes a tuple, a slice or an array of parsers and tries to apply them each in order. |
523 | | /// Fails if all the parsers fails or if an applied parser consumes input before failing. |
524 | | /// |
525 | | /// ``` |
526 | | /// # extern crate combine; |
527 | | /// # use combine::*; |
528 | | /// # use combine::parser::char::{digit, string}; |
529 | | /// # fn main() { |
530 | | /// // `choice` is overloaded on tuples so that different types of parsers can be used |
531 | | /// // (each parser must still have the same input and output types) |
532 | | /// let mut parser = choice(( |
533 | | /// string("Apple").map(|s| s.to_string()), |
534 | | /// many1(digit()), |
535 | | /// string("Orange").map(|s| s.to_string()), |
536 | | /// )); |
537 | | /// assert_eq!(parser.parse("1234"), Ok(("1234".to_string(), ""))); |
538 | | /// assert_eq!(parser.parse("Orangexx"), Ok(("Orange".to_string(), "xx"))); |
539 | | /// assert!(parser.parse("Appl").is_err()); |
540 | | /// assert!(parser.parse("Pear").is_err()); |
541 | | /// |
542 | | /// // If arrays or slices are used then all parsers must have the same type |
543 | | /// // (`string` in this case) |
544 | | /// let mut parser2 = choice([string("one"), string("two"), string("three")]); |
545 | | /// // Fails as the parser for "two" consumes the first 't' before failing |
546 | | /// assert!(parser2.parse("three").is_err()); |
547 | | /// |
548 | | /// // Use 'attempt' to make failing parsers always act as if they have not committed any input |
549 | | /// let mut parser3 = choice([attempt(string("one")), attempt(string("two")), attempt(string("three"))]); |
550 | | /// assert_eq!(parser3.parse("three"), Ok(("three", ""))); |
551 | | /// # } |
552 | | /// ``` |
553 | 0 | pub fn choice<Input, P>(ps: P) -> Choice<P> |
554 | 0 | where |
555 | 0 | Input: Stream, |
556 | 0 | P: ChoiceParser<Input>, |
557 | | { |
558 | 0 | Choice(ps) |
559 | 0 | } |
560 | | |
561 | | #[derive(Copy, Clone)] |
562 | | pub struct Or<P1, P2>(Choice<(P1, P2)>); |
563 | | impl<Input, O, P1, P2> Parser<Input> for Or<P1, P2> |
564 | | where |
565 | | Input: Stream, |
566 | | P1: Parser<Input, Output = O>, |
567 | | P2: Parser<Input, Output = O>, |
568 | | { |
569 | | type Output = O; |
570 | | type PartialState = <Choice<(P1, P2)> as Parser<Input>>::PartialState; |
571 | | |
572 | | parse_mode!(Input); |
573 | | #[inline] |
574 | 0 | fn parse_mode_impl<M>( |
575 | 0 | &mut self, |
576 | 0 | mode: M, |
577 | 0 | input: &mut Input, |
578 | 0 | state: &mut Self::PartialState, |
579 | 0 | ) -> ParseResult<Self::Output, <Input as StreamOnce>::Error> |
580 | 0 | where |
581 | 0 | M: ParseMode, |
582 | | { |
583 | 0 | self.0.parse_mode(mode, input, state) |
584 | 0 | } |
585 | | |
586 | | #[inline] |
587 | 0 | fn add_error(&mut self, errors: &mut Tracked<<Input as StreamOnce>::Error>) { |
588 | 0 | if errors.offset != ErrorOffset(0) { |
589 | 0 | self.0.add_error(errors); |
590 | 0 | } |
591 | 0 | } |
592 | | } |
593 | | |
594 | | /// Equivalent to [`p1.or(p2)`]. |
595 | | /// |
596 | | /// If you are looking to chain 3 or more parsers using `or` you may consider using the |
597 | | /// [`choice!`] macro instead, which can be clearer and may result in a faster parser. |
598 | | /// |
599 | | /// ``` |
600 | | /// # extern crate combine; |
601 | | /// # use combine::*; |
602 | | /// # use combine::parser::choice::or; |
603 | | /// # use combine::parser::char::{digit, string}; |
604 | | /// # fn main() { |
605 | | /// let mut parser = or( |
606 | | /// string("let"), |
607 | | /// or(digit().map(|_| "digit"), string("led")), |
608 | | /// ); |
609 | | /// assert_eq!(parser.parse("let"), Ok(("let", ""))); |
610 | | /// assert_eq!(parser.parse("1"), Ok(("digit", ""))); |
611 | | /// assert!(parser.parse("led").is_err()); |
612 | | /// |
613 | | /// let mut parser2 = or(string("two"), string("three")); |
614 | | /// // Fails as the parser for "two" consumes the first 't' before failing |
615 | | /// assert!(parser2.parse("three").is_err()); |
616 | | /// |
617 | | /// // Use 'attempt' to make failing parsers always act as if they have not committed any input |
618 | | /// let mut parser3 = or(attempt(string("two")), attempt(string("three"))); |
619 | | /// assert_eq!(parser3.parse("three"), Ok(("three", ""))); |
620 | | /// # } |
621 | | /// ``` |
622 | | /// |
623 | | /// [`choice!`]: ../../macro.choice.html |
624 | | /// [`p1.or(p2)`]: ../trait.Parser.html#method.or |
625 | 0 | pub fn or<Input, P1, P2>(p1: P1, p2: P2) -> Or<P1, P2> |
626 | 0 | where |
627 | 0 | Input: Stream, |
628 | 0 | P1: Parser<Input>, |
629 | 0 | P2: Parser<Input, Output = P1::Output>, |
630 | | { |
631 | 0 | Or(choice((p1, p2))) |
632 | 0 | } |
633 | | |
634 | | #[derive(Copy, Clone)] |
635 | | pub struct Optional<P>(P); |
636 | | impl<Input, P> Parser<Input> for Optional<P> |
637 | | where |
638 | | Input: Stream, |
639 | | P: Parser<Input>, |
640 | | { |
641 | | type Output = Option<P::Output>; |
642 | | type PartialState = P::PartialState; |
643 | | |
644 | | parse_mode!(Input); |
645 | | #[inline] |
646 | 0 | fn parse_mode_impl<M>( |
647 | 0 | &mut self, |
648 | 0 | mode: M, |
649 | 0 | input: &mut Input, |
650 | 0 | state: &mut Self::PartialState, |
651 | 0 | ) -> ParseResult<Self::Output, <Input as StreamOnce>::Error> |
652 | 0 | where |
653 | 0 | M: ParseMode, |
654 | | { |
655 | 0 | let before = input.checkpoint(); |
656 | 0 | match self.0.parse_mode(mode, input, state) { |
657 | 0 | PeekOk(x) => PeekOk(Some(x)), |
658 | 0 | CommitOk(x) => CommitOk(Some(x)), |
659 | 0 | CommitErr(err) => CommitErr(err), |
660 | | PeekErr(_) => { |
661 | 0 | ctry!(input.reset(before).committed()); |
662 | 0 | PeekOk(None) |
663 | | } |
664 | | } |
665 | 0 | } |
666 | | |
667 | | forward_parser!(Input, add_error parser_count, 0); |
668 | | } |
669 | | |
670 | | /// Parses `parser` and outputs `Some(value)` if it succeeds, `None` if it fails without |
671 | | /// consuming any input. Fails if `parser` fails after having committed some input. |
672 | | /// |
673 | | /// ``` |
674 | | /// # extern crate combine; |
675 | | /// # use combine::*; |
676 | | /// # use combine::parser::char::string; |
677 | | /// # fn main() { |
678 | | /// let mut parser = optional(string("hello")); |
679 | | /// assert_eq!(parser.parse("hello"), Ok((Some("hello"), ""))); |
680 | | /// assert_eq!(parser.parse("world"), Ok((None, "world"))); |
681 | | /// assert!(parser.parse("heya").is_err()); |
682 | | /// # } |
683 | | /// ``` |
684 | 0 | pub fn optional<Input, P>(parser: P) -> Optional<P> |
685 | 0 | where |
686 | 0 | Input: Stream, |
687 | 0 | P: Parser<Input>, |
688 | | { |
689 | 0 | Optional(parser) |
690 | 0 | } |
691 | | |
692 | | #[macro_export] |
693 | | #[doc(hidden)] |
694 | | macro_rules! parse_mode_dispatch { |
695 | | () => { |
696 | | fn parse_partial( |
697 | | &mut self, |
698 | | input: &mut Input, |
699 | | state: &mut Self::PartialState, |
700 | | ) -> ParseResult<Self::Output, <Input as StreamOnce>::Error> { |
701 | | self.parse_mode_dispatch($crate::parser::PartialMode::default(), input, state) |
702 | | } |
703 | | |
704 | | fn parse_first( |
705 | | &mut self, |
706 | | input: &mut Input, |
707 | | state: &mut Self::PartialState, |
708 | | ) -> ParseResult<Self::Output, <Input as StreamOnce>::Error> { |
709 | | self.parse_mode_dispatch($crate::parser::FirstMode, input, state) |
710 | | } |
711 | | }; |
712 | | } |
713 | | |
714 | | #[macro_export] |
715 | | #[doc(hidden)] |
716 | | macro_rules! dispatch_parser_impl { |
717 | | ($parser_name: ident [$first_ident: ident $($id: ident)*] [$($collected_idents: ident)*] $expr: expr, $($rest: expr,)*) => { |
718 | | $crate::dispatch_parser_impl!{ $parser_name [ $($id)* ] [$($collected_idents)* $first_ident] $($rest,)*} |
719 | | }; |
720 | | ($parser_name: ident [$($id: ident)*] [$($collected_idents: ident)*]) => { |
721 | | $crate::dispatch_parser_impl!{ $parser_name; $($collected_idents)* } |
722 | | }; |
723 | | |
724 | | ($parser_name: ident; $($id: ident)*) => { |
725 | | pub enum $parser_name<$($id),*> { |
726 | | $( |
727 | | $id($id), |
728 | | )* |
729 | | } |
730 | | |
731 | | #[allow(non_snake_case)] |
732 | | impl<Input, Output, $($id),*> $crate::Parser<Input> for $parser_name<$($id),*> |
733 | | where |
734 | | $( $id: $crate::Parser<Input, Output = Output>, )* |
735 | | Input: $crate::Stream, |
736 | | { |
737 | | type Output = Output; |
738 | | type PartialState = Option<$parser_name<$($id::PartialState),*>>; |
739 | | |
740 | | $crate::parse_mode!(Input); |
741 | 7.88M | fn parse_mode<Mode>( |
742 | 7.88M | &mut self, |
743 | 7.88M | mode: Mode, |
744 | 7.88M | input: &mut Input, |
745 | 7.88M | state: &mut Self::PartialState, |
746 | 7.88M | ) -> $crate::error::ParseResult<Self::Output, <Input as $crate::StreamOnce>::Error> |
747 | 7.88M | where |
748 | 7.88M | Mode: $crate::parser::ParseMode, |
749 | | { |
750 | 7.88M | match self { |
751 | | $( |
752 | 6.60M | $parser_name::$id($id) => { |
753 | 6.60M | let state = match state { |
754 | 5.79M | Some($parser_name::$id(s)) => s, |
755 | | _ => { |
756 | 811k | *state = Some($parser_name::$id(Default::default())); |
757 | 811k | match state { |
758 | 811k | Some($parser_name::$id(s)) => s, |
759 | 0 | _ => unreachable!(), |
760 | | } |
761 | | } |
762 | | }; |
763 | 6.60M | $id.parse_mode(mode, input, state) |
764 | | } |
765 | | )* |
766 | | } |
767 | 7.88M | } <redis::parser::value::{closure#0}::{closure#1}::Dispatch<combine::parser::combinator::Map<combine::parser::combinator::AndThen<combine::parser::range::Recognize<combine::stream::easy::Stream<combine::stream::MaybePartialStream<&[u8]>>, combine::parser::sequence::With<combine::parser::byte::take_until_bytes<combine::stream::easy::Stream<combine::stream::MaybePartialStream<&[u8]>>>, combine::parser::combinator::Map<combine::parser::range::Take<combine::stream::easy::Stream<combine::stream::MaybePartialStream<&[u8]>>>, redis::parser::value<combine::stream::easy::Stream<combine::stream::MaybePartialStream<&[u8]>>>::{closure#0}::{closure#1}::{closure#0}::{closure#0}>>>, redis::parser::value<combine::stream::easy::Stream<combine::stream::MaybePartialStream<&[u8]>>>::{closure#0}::{closure#1}::{closure#0}::{closure#1}>, redis::parser::value<combine::stream::easy::Stream<combine::stream::MaybePartialStream<&[u8]>>>::{closure#0}::{closure#1}::{closure#1}::{closure#0}>, combine::parser::combinator::Map<combine::parser::combinator::AndThen<combine::parser::combinator::AndThen<combine::parser::range::Recognize<combine::stream::easy::Stream<combine::stream::MaybePartialStream<&[u8]>>, combine::parser::sequence::With<combine::parser::byte::take_until_bytes<combine::stream::easy::Stream<combine::stream::MaybePartialStream<&[u8]>>>, combine::parser::combinator::Map<combine::parser::range::Take<combine::stream::easy::Stream<combine::stream::MaybePartialStream<&[u8]>>>, redis::parser::value<combine::stream::easy::Stream<combine::stream::MaybePartialStream<&[u8]>>>::{closure#0}::{closure#1}::{closure#0}::{closure#0}>>>, redis::parser::value<combine::stream::easy::Stream<combine::stream::MaybePartialStream<&[u8]>>>::{closure#0}::{closure#1}::{closure#0}::{closure#1}>, redis::parser::value<combine::stream::easy::Stream<combine::stream::MaybePartialStream<&[u8]>>>::{closure#0}::{closure#1}::{closure#2}::{closure#0}>, redis::types::Value::Int>, combine::parser::sequence::ThenPartial<combine::parser::combinator::AndThen<combine::parser::combinator::AndThen<combine::parser::range::Recognize<combine::stream::easy::Stream<combine::stream::MaybePartialStream<&[u8]>>, combine::parser::sequence::With<combine::parser::byte::take_until_bytes<combine::stream::easy::Stream<combine::stream::MaybePartialStream<&[u8]>>>, combine::parser::combinator::Map<combine::parser::range::Take<combine::stream::easy::Stream<combine::stream::MaybePartialStream<&[u8]>>>, redis::parser::value<combine::stream::easy::Stream<combine::stream::MaybePartialStream<&[u8]>>>::{closure#0}::{closure#1}::{closure#0}::{closure#0}>>>, redis::parser::value<combine::stream::easy::Stream<combine::stream::MaybePartialStream<&[u8]>>>::{closure#0}::{closure#1}::{closure#0}::{closure#1}>, redis::parser::value<combine::stream::easy::Stream<combine::stream::MaybePartialStream<&[u8]>>>::{closure#0}::{closure#1}::{closure#2}::{closure#0}>, redis::parser::value<combine::stream::easy::Stream<combine::stream::MaybePartialStream<&[u8]>>>::{closure#0}::{closure#1}::{closure#3}::{closure#0}>, combine::parser::sequence::ThenPartial<combine::parser::combinator::AndThen<combine::parser::combinator::AndThen<combine::parser::range::Recognize<combine::stream::easy::Stream<combine::stream::MaybePartialStream<&[u8]>>, combine::parser::sequence::With<combine::parser::byte::take_until_bytes<combine::stream::easy::Stream<combine::stream::MaybePartialStream<&[u8]>>>, combine::parser::combinator::Map<combine::parser::range::Take<combine::stream::easy::Stream<combine::stream::MaybePartialStream<&[u8]>>>, redis::parser::value<combine::stream::easy::Stream<combine::stream::MaybePartialStream<&[u8]>>>::{closure#0}::{closure#1}::{closure#0}::{closure#0}>>>, redis::parser::value<combine::stream::easy::Stream<combine::stream::MaybePartialStream<&[u8]>>>::{closure#0}::{closure#1}::{closure#0}::{closure#1}>, redis::parser::value<combine::stream::easy::Stream<combine::stream::MaybePartialStream<&[u8]>>>::{closure#0}::{closure#1}::{closure#2}::{closure#0}>, redis::parser::value<combine::stream::easy::Stream<combine::stream::MaybePartialStream<&[u8]>>>::{closure#0}::{closure#1}::{closure#5}::{closure#0}>, combine::parser::sequence::ThenPartial<combine::parser::combinator::AndThen<combine::parser::combinator::AndThen<combine::parser::range::Recognize<combine::stream::easy::Stream<combine::stream::MaybePartialStream<&[u8]>>, combine::parser::sequence::With<combine::parser::byte::take_until_bytes<combine::stream::easy::Stream<combine::stream::MaybePartialStream<&[u8]>>>, combine::parser::combinator::Map<combine::parser::range::Take<combine::stream::easy::Stream<combine::stream::MaybePartialStream<&[u8]>>>, redis::parser::value<combine::stream::easy::Stream<combine::stream::MaybePartialStream<&[u8]>>>::{closure#0}::{closure#1}::{closure#0}::{closure#0}>>>, redis::parser::value<combine::stream::easy::Stream<combine::stream::MaybePartialStream<&[u8]>>>::{closure#0}::{closure#1}::{closure#0}::{closure#1}>, redis::parser::value<combine::stream::easy::Stream<combine::stream::MaybePartialStream<&[u8]>>>::{closure#0}::{closure#1}::{closure#2}::{closure#0}>, redis::parser::value<combine::stream::easy::Stream<combine::stream::MaybePartialStream<&[u8]>>>::{closure#0}::{closure#1}::{closure#7}::{closure#0}>, combine::parser::sequence::ThenPartial<combine::parser::combinator::AndThen<combine::parser::combinator::AndThen<combine::parser::range::Recognize<combine::stream::easy::Stream<combine::stream::MaybePartialStream<&[u8]>>, combine::parser::sequence::With<combine::parser::byte::take_until_bytes<combine::stream::easy::Stream<combine::stream::MaybePartialStream<&[u8]>>>, combine::parser::combinator::Map<combine::parser::range::Take<combine::stream::easy::Stream<combine::stream::MaybePartialStream<&[u8]>>>, redis::parser::value<combine::stream::easy::Stream<combine::stream::MaybePartialStream<&[u8]>>>::{closure#0}::{closure#1}::{closure#0}::{closure#0}>>>, redis::parser::value<combine::stream::easy::Stream<combine::stream::MaybePartialStream<&[u8]>>>::{closure#0}::{closure#1}::{closure#0}::{closure#1}>, redis::parser::value<combine::stream::easy::Stream<combine::stream::MaybePartialStream<&[u8]>>>::{closure#0}::{closure#1}::{closure#2}::{closure#0}>, redis::parser::value<combine::stream::easy::Stream<combine::stream::MaybePartialStream<&[u8]>>>::{closure#0}::{closure#1}::{closure#8}::{closure#0}>, combine::parser::sequence::ThenPartial<combine::parser::combinator::AndThen<combine::parser::combinator::AndThen<combine::parser::range::Recognize<combine::stream::easy::Stream<combine::stream::MaybePartialStream<&[u8]>>, combine::parser::sequence::With<combine::parser::byte::take_until_bytes<combine::stream::easy::Stream<combine::stream::MaybePartialStream<&[u8]>>>, combine::parser::combinator::Map<combine::parser::range::Take<combine::stream::easy::Stream<combine::stream::MaybePartialStream<&[u8]>>>, redis::parser::value<combine::stream::easy::Stream<combine::stream::MaybePartialStream<&[u8]>>>::{closure#0}::{closure#1}::{closure#0}::{closure#0}>>>, redis::parser::value<combine::stream::easy::Stream<combine::stream::MaybePartialStream<&[u8]>>>::{closure#0}::{closure#1}::{closure#0}::{closure#1}>, redis::parser::value<combine::stream::easy::Stream<combine::stream::MaybePartialStream<&[u8]>>>::{closure#0}::{closure#1}::{closure#2}::{closure#0}>, redis::parser::value<combine::stream::easy::Stream<combine::stream::MaybePartialStream<&[u8]>>>::{closure#0}::{closure#1}::{closure#9}::{closure#0}>, combine::parser::combinator::Map<combine::parser::combinator::Map<combine::parser::combinator::AndThen<combine::parser::range::Recognize<combine::stream::easy::Stream<combine::stream::MaybePartialStream<&[u8]>>, combine::parser::sequence::With<combine::parser::byte::take_until_bytes<combine::stream::easy::Stream<combine::stream::MaybePartialStream<&[u8]>>>, combine::parser::combinator::Map<combine::parser::range::Take<combine::stream::easy::Stream<combine::stream::MaybePartialStream<&[u8]>>>, redis::parser::value<combine::stream::easy::Stream<combine::stream::MaybePartialStream<&[u8]>>>::{closure#0}::{closure#1}::{closure#0}::{closure#0}>>>, redis::parser::value<combine::stream::easy::Stream<combine::stream::MaybePartialStream<&[u8]>>>::{closure#0}::{closure#1}::{closure#0}::{closure#1}>, redis::parser::err_parser>, redis::types::Value::ServerError>, combine::parser::combinator::Map<combine::parser::combinator::AndThen<combine::parser::range::Recognize<combine::stream::easy::Stream<combine::stream::MaybePartialStream<&[u8]>>, combine::parser::sequence::With<combine::parser::byte::take_until_bytes<combine::stream::easy::Stream<combine::stream::MaybePartialStream<&[u8]>>>, combine::parser::combinator::Map<combine::parser::range::Take<combine::stream::easy::Stream<combine::stream::MaybePartialStream<&[u8]>>>, redis::parser::value<combine::stream::easy::Stream<combine::stream::MaybePartialStream<&[u8]>>>::{closure#0}::{closure#1}::{closure#0}::{closure#0}>>>, redis::parser::value<combine::stream::easy::Stream<combine::stream::MaybePartialStream<&[u8]>>>::{closure#0}::{closure#1}::{closure#0}::{closure#1}>, redis::parser::value<combine::stream::easy::Stream<combine::stream::MaybePartialStream<&[u8]>>>::{closure#0}::{closure#1}::{closure#11}::{closure#0}>, combine::parser::combinator::Map<combine::parser::combinator::AndThen<combine::parser::combinator::AndThen<combine::parser::range::Recognize<combine::stream::easy::Stream<combine::stream::MaybePartialStream<&[u8]>>, combine::parser::sequence::With<combine::parser::byte::take_until_bytes<combine::stream::easy::Stream<combine::stream::MaybePartialStream<&[u8]>>>, combine::parser::combinator::Map<combine::parser::range::Take<combine::stream::easy::Stream<combine::stream::MaybePartialStream<&[u8]>>>, redis::parser::value<combine::stream::easy::Stream<combine::stream::MaybePartialStream<&[u8]>>>::{closure#0}::{closure#1}::{closure#0}::{closure#0}>>>, redis::parser::value<combine::stream::easy::Stream<combine::stream::MaybePartialStream<&[u8]>>>::{closure#0}::{closure#1}::{closure#0}::{closure#1}>, redis::parser::value<combine::stream::easy::Stream<combine::stream::MaybePartialStream<&[u8]>>>::{closure#0}::{closure#1}::{closure#12}::{closure#0}>, redis::types::Value::Double>, combine::parser::combinator::Map<combine::parser::combinator::AndThen<combine::parser::combinator::AndThen<combine::parser::range::Recognize<combine::stream::easy::Stream<combine::stream::MaybePartialStream<&[u8]>>, combine::parser::sequence::With<combine::parser::byte::take_until_bytes<combine::stream::easy::Stream<combine::stream::MaybePartialStream<&[u8]>>>, combine::parser::combinator::Map<combine::parser::range::Take<combine::stream::easy::Stream<combine::stream::MaybePartialStream<&[u8]>>>, redis::parser::value<combine::stream::easy::Stream<combine::stream::MaybePartialStream<&[u8]>>>::{closure#0}::{closure#1}::{closure#0}::{closure#0}>>>, redis::parser::value<combine::stream::easy::Stream<combine::stream::MaybePartialStream<&[u8]>>>::{closure#0}::{closure#1}::{closure#0}::{closure#1}>, redis::parser::value<combine::stream::easy::Stream<combine::stream::MaybePartialStream<&[u8]>>>::{closure#0}::{closure#1}::{closure#13}::{closure#0}>, redis::types::Value::Boolean>, combine::parser::combinator::Map<combine::parser::combinator::Map<combine::parser::sequence::ThenPartial<combine::parser::combinator::AndThen<combine::parser::combinator::AndThen<combine::parser::range::Recognize<combine::stream::easy::Stream<combine::stream::MaybePartialStream<&[u8]>>, combine::parser::sequence::With<combine::parser::byte::take_until_bytes<combine::stream::easy::Stream<combine::stream::MaybePartialStream<&[u8]>>>, combine::parser::combinator::Map<combine::parser::range::Take<combine::stream::easy::Stream<combine::stream::MaybePartialStream<&[u8]>>>, redis::parser::value<combine::stream::easy::Stream<combine::stream::MaybePartialStream<&[u8]>>>::{closure#0}::{closure#1}::{closure#0}::{closure#0}>>>, redis::parser::value<combine::stream::easy::Stream<combine::stream::MaybePartialStream<&[u8]>>>::{closure#0}::{closure#1}::{closure#0}::{closure#1}>, redis::parser::value<combine::stream::easy::Stream<combine::stream::MaybePartialStream<&[u8]>>>::{closure#0}::{closure#1}::{closure#2}::{closure#0}>, redis::parser::value<combine::stream::easy::Stream<combine::stream::MaybePartialStream<&[u8]>>>::{closure#0}::{closure#1}::{closure#4}::{closure#0}>, redis::parser::value<combine::stream::easy::Stream<combine::stream::MaybePartialStream<&[u8]>>>::{closure#0}::{closure#1}::{closure#14}::{closure#0}>, redis::types::Value::ServerError>, combine::parser::combinator::AndThen<combine::parser::sequence::ThenPartial<combine::parser::combinator::AndThen<combine::parser::combinator::AndThen<combine::parser::range::Recognize<combine::stream::easy::Stream<combine::stream::MaybePartialStream<&[u8]>>, combine::parser::sequence::With<combine::parser::byte::take_until_bytes<combine::stream::easy::Stream<combine::stream::MaybePartialStream<&[u8]>>>, combine::parser::combinator::Map<combine::parser::range::Take<combine::stream::easy::Stream<combine::stream::MaybePartialStream<&[u8]>>>, redis::parser::value<combine::stream::easy::Stream<combine::stream::MaybePartialStream<&[u8]>>>::{closure#0}::{closure#1}::{closure#0}::{closure#0}>>>, redis::parser::value<combine::stream::easy::Stream<combine::stream::MaybePartialStream<&[u8]>>>::{closure#0}::{closure#1}::{closure#0}::{closure#1}>, redis::parser::value<combine::stream::easy::Stream<combine::stream::MaybePartialStream<&[u8]>>>::{closure#0}::{closure#1}::{closure#2}::{closure#0}>, redis::parser::value<combine::stream::easy::Stream<combine::stream::MaybePartialStream<&[u8]>>>::{closure#0}::{closure#1}::{closure#4}::{closure#0}>, redis::parser::value<combine::stream::easy::Stream<combine::stream::MaybePartialStream<&[u8]>>>::{closure#0}::{closure#1}::{closure#15}::{closure#0}>, combine::parser::combinator::AndThen<combine::parser::combinator::AndThen<combine::parser::range::Recognize<combine::stream::easy::Stream<combine::stream::MaybePartialStream<&[u8]>>, combine::parser::sequence::With<combine::parser::byte::take_until_bytes<combine::stream::easy::Stream<combine::stream::MaybePartialStream<&[u8]>>>, combine::parser::combinator::Map<combine::parser::range::Take<combine::stream::easy::Stream<combine::stream::MaybePartialStream<&[u8]>>>, redis::parser::value<combine::stream::easy::Stream<combine::stream::MaybePartialStream<&[u8]>>>::{closure#0}::{closure#1}::{closure#0}::{closure#0}>>>, redis::parser::value<combine::stream::easy::Stream<combine::stream::MaybePartialStream<&[u8]>>>::{closure#0}::{closure#1}::{closure#0}::{closure#1}>, redis::parser::value<combine::stream::easy::Stream<combine::stream::MaybePartialStream<&[u8]>>>::{closure#0}::{closure#1}::{closure#16}::{closure#0}>, combine::parser::sequence::ThenPartial<combine::parser::combinator::AndThen<combine::parser::combinator::AndThen<combine::parser::range::Recognize<combine::stream::easy::Stream<combine::stream::MaybePartialStream<&[u8]>>, combine::parser::sequence::With<combine::parser::byte::take_until_bytes<combine::stream::easy::Stream<combine::stream::MaybePartialStream<&[u8]>>>, combine::parser::combinator::Map<combine::parser::range::Take<combine::stream::easy::Stream<combine::stream::MaybePartialStream<&[u8]>>>, redis::parser::value<combine::stream::easy::Stream<combine::stream::MaybePartialStream<&[u8]>>>::{closure#0}::{closure#1}::{closure#0}::{closure#0}>>>, redis::parser::value<combine::stream::easy::Stream<combine::stream::MaybePartialStream<&[u8]>>>::{closure#0}::{closure#1}::{closure#0}::{closure#1}>, redis::parser::value<combine::stream::easy::Stream<combine::stream::MaybePartialStream<&[u8]>>>::{closure#0}::{closure#1}::{closure#2}::{closure#0}>, redis::parser::value<combine::stream::easy::Stream<combine::stream::MaybePartialStream<&[u8]>>>::{closure#0}::{closure#1}::{closure#10}::{closure#0}>, combine::parser::error::Unexpected<combine::stream::easy::Stream<combine::stream::MaybePartialStream<&[u8]>>, redis::types::Value, combine::error::Token<u8>>> as combine::parser::Parser<combine::stream::easy::Stream<combine::stream::MaybePartialStream<&[u8]>>>>::parse_mode::<combine::parser::PartialMode>Line | Count | Source | 741 | 192k | fn parse_mode<Mode>( | 742 | 192k | &mut self, | 743 | 192k | mode: Mode, | 744 | 192k | input: &mut Input, | 745 | 192k | state: &mut Self::PartialState, | 746 | 192k | ) -> $crate::error::ParseResult<Self::Output, <Input as $crate::StreamOnce>::Error> | 747 | 192k | where | 748 | 192k | Mode: $crate::parser::ParseMode, | 749 | | { | 750 | 192k | match self { | 751 | | $( | 752 | 6.21k | $parser_name::$id($id) => { | 753 | 6.21k | let state = match state { | 754 | 6.21k | Some($parser_name::$id(s)) => s, | 755 | | _ => { | 756 | 0 | *state = Some($parser_name::$id(Default::default())); | 757 | 0 | match state { | 758 | 0 | Some($parser_name::$id(s)) => s, | 759 | 0 | _ => unreachable!(), | 760 | | } | 761 | | } | 762 | | }; | 763 | 6.21k | $id.parse_mode(mode, input, state) | 764 | | } | 765 | | )* | 766 | | } | 767 | 192k | } |
<redis::parser::value::{closure#0}::{closure#1}::Dispatch<combine::parser::combinator::Map<combine::parser::combinator::AndThen<combine::parser::range::Recognize<combine::stream::easy::Stream<combine::stream::MaybePartialStream<&[u8]>>, combine::parser::sequence::With<combine::parser::byte::take_until_bytes<combine::stream::easy::Stream<combine::stream::MaybePartialStream<&[u8]>>>, combine::parser::combinator::Map<combine::parser::range::Take<combine::stream::easy::Stream<combine::stream::MaybePartialStream<&[u8]>>>, redis::parser::value<combine::stream::easy::Stream<combine::stream::MaybePartialStream<&[u8]>>>::{closure#0}::{closure#1}::{closure#0}::{closure#0}>>>, redis::parser::value<combine::stream::easy::Stream<combine::stream::MaybePartialStream<&[u8]>>>::{closure#0}::{closure#1}::{closure#0}::{closure#1}>, redis::parser::value<combine::stream::easy::Stream<combine::stream::MaybePartialStream<&[u8]>>>::{closure#0}::{closure#1}::{closure#1}::{closure#0}>, combine::parser::combinator::Map<combine::parser::combinator::AndThen<combine::parser::combinator::AndThen<combine::parser::range::Recognize<combine::stream::easy::Stream<combine::stream::MaybePartialStream<&[u8]>>, combine::parser::sequence::With<combine::parser::byte::take_until_bytes<combine::stream::easy::Stream<combine::stream::MaybePartialStream<&[u8]>>>, combine::parser::combinator::Map<combine::parser::range::Take<combine::stream::easy::Stream<combine::stream::MaybePartialStream<&[u8]>>>, redis::parser::value<combine::stream::easy::Stream<combine::stream::MaybePartialStream<&[u8]>>>::{closure#0}::{closure#1}::{closure#0}::{closure#0}>>>, redis::parser::value<combine::stream::easy::Stream<combine::stream::MaybePartialStream<&[u8]>>>::{closure#0}::{closure#1}::{closure#0}::{closure#1}>, redis::parser::value<combine::stream::easy::Stream<combine::stream::MaybePartialStream<&[u8]>>>::{closure#0}::{closure#1}::{closure#2}::{closure#0}>, redis::types::Value::Int>, combine::parser::sequence::ThenPartial<combine::parser::combinator::AndThen<combine::parser::combinator::AndThen<combine::parser::range::Recognize<combine::stream::easy::Stream<combine::stream::MaybePartialStream<&[u8]>>, combine::parser::sequence::With<combine::parser::byte::take_until_bytes<combine::stream::easy::Stream<combine::stream::MaybePartialStream<&[u8]>>>, combine::parser::combinator::Map<combine::parser::range::Take<combine::stream::easy::Stream<combine::stream::MaybePartialStream<&[u8]>>>, redis::parser::value<combine::stream::easy::Stream<combine::stream::MaybePartialStream<&[u8]>>>::{closure#0}::{closure#1}::{closure#0}::{closure#0}>>>, redis::parser::value<combine::stream::easy::Stream<combine::stream::MaybePartialStream<&[u8]>>>::{closure#0}::{closure#1}::{closure#0}::{closure#1}>, redis::parser::value<combine::stream::easy::Stream<combine::stream::MaybePartialStream<&[u8]>>>::{closure#0}::{closure#1}::{closure#2}::{closure#0}>, redis::parser::value<combine::stream::easy::Stream<combine::stream::MaybePartialStream<&[u8]>>>::{closure#0}::{closure#1}::{closure#3}::{closure#0}>, combine::parser::sequence::ThenPartial<combine::parser::combinator::AndThen<combine::parser::combinator::AndThen<combine::parser::range::Recognize<combine::stream::easy::Stream<combine::stream::MaybePartialStream<&[u8]>>, combine::parser::sequence::With<combine::parser::byte::take_until_bytes<combine::stream::easy::Stream<combine::stream::MaybePartialStream<&[u8]>>>, combine::parser::combinator::Map<combine::parser::range::Take<combine::stream::easy::Stream<combine::stream::MaybePartialStream<&[u8]>>>, redis::parser::value<combine::stream::easy::Stream<combine::stream::MaybePartialStream<&[u8]>>>::{closure#0}::{closure#1}::{closure#0}::{closure#0}>>>, redis::parser::value<combine::stream::easy::Stream<combine::stream::MaybePartialStream<&[u8]>>>::{closure#0}::{closure#1}::{closure#0}::{closure#1}>, redis::parser::value<combine::stream::easy::Stream<combine::stream::MaybePartialStream<&[u8]>>>::{closure#0}::{closure#1}::{closure#2}::{closure#0}>, redis::parser::value<combine::stream::easy::Stream<combine::stream::MaybePartialStream<&[u8]>>>::{closure#0}::{closure#1}::{closure#5}::{closure#0}>, combine::parser::sequence::ThenPartial<combine::parser::combinator::AndThen<combine::parser::combinator::AndThen<combine::parser::range::Recognize<combine::stream::easy::Stream<combine::stream::MaybePartialStream<&[u8]>>, combine::parser::sequence::With<combine::parser::byte::take_until_bytes<combine::stream::easy::Stream<combine::stream::MaybePartialStream<&[u8]>>>, combine::parser::combinator::Map<combine::parser::range::Take<combine::stream::easy::Stream<combine::stream::MaybePartialStream<&[u8]>>>, redis::parser::value<combine::stream::easy::Stream<combine::stream::MaybePartialStream<&[u8]>>>::{closure#0}::{closure#1}::{closure#0}::{closure#0}>>>, redis::parser::value<combine::stream::easy::Stream<combine::stream::MaybePartialStream<&[u8]>>>::{closure#0}::{closure#1}::{closure#0}::{closure#1}>, redis::parser::value<combine::stream::easy::Stream<combine::stream::MaybePartialStream<&[u8]>>>::{closure#0}::{closure#1}::{closure#2}::{closure#0}>, redis::parser::value<combine::stream::easy::Stream<combine::stream::MaybePartialStream<&[u8]>>>::{closure#0}::{closure#1}::{closure#7}::{closure#0}>, combine::parser::sequence::ThenPartial<combine::parser::combinator::AndThen<combine::parser::combinator::AndThen<combine::parser::range::Recognize<combine::stream::easy::Stream<combine::stream::MaybePartialStream<&[u8]>>, combine::parser::sequence::With<combine::parser::byte::take_until_bytes<combine::stream::easy::Stream<combine::stream::MaybePartialStream<&[u8]>>>, combine::parser::combinator::Map<combine::parser::range::Take<combine::stream::easy::Stream<combine::stream::MaybePartialStream<&[u8]>>>, redis::parser::value<combine::stream::easy::Stream<combine::stream::MaybePartialStream<&[u8]>>>::{closure#0}::{closure#1}::{closure#0}::{closure#0}>>>, redis::parser::value<combine::stream::easy::Stream<combine::stream::MaybePartialStream<&[u8]>>>::{closure#0}::{closure#1}::{closure#0}::{closure#1}>, redis::parser::value<combine::stream::easy::Stream<combine::stream::MaybePartialStream<&[u8]>>>::{closure#0}::{closure#1}::{closure#2}::{closure#0}>, redis::parser::value<combine::stream::easy::Stream<combine::stream::MaybePartialStream<&[u8]>>>::{closure#0}::{closure#1}::{closure#8}::{closure#0}>, combine::parser::sequence::ThenPartial<combine::parser::combinator::AndThen<combine::parser::combinator::AndThen<combine::parser::range::Recognize<combine::stream::easy::Stream<combine::stream::MaybePartialStream<&[u8]>>, combine::parser::sequence::With<combine::parser::byte::take_until_bytes<combine::stream::easy::Stream<combine::stream::MaybePartialStream<&[u8]>>>, combine::parser::combinator::Map<combine::parser::range::Take<combine::stream::easy::Stream<combine::stream::MaybePartialStream<&[u8]>>>, redis::parser::value<combine::stream::easy::Stream<combine::stream::MaybePartialStream<&[u8]>>>::{closure#0}::{closure#1}::{closure#0}::{closure#0}>>>, redis::parser::value<combine::stream::easy::Stream<combine::stream::MaybePartialStream<&[u8]>>>::{closure#0}::{closure#1}::{closure#0}::{closure#1}>, redis::parser::value<combine::stream::easy::Stream<combine::stream::MaybePartialStream<&[u8]>>>::{closure#0}::{closure#1}::{closure#2}::{closure#0}>, redis::parser::value<combine::stream::easy::Stream<combine::stream::MaybePartialStream<&[u8]>>>::{closure#0}::{closure#1}::{closure#9}::{closure#0}>, combine::parser::combinator::Map<combine::parser::combinator::Map<combine::parser::combinator::AndThen<combine::parser::range::Recognize<combine::stream::easy::Stream<combine::stream::MaybePartialStream<&[u8]>>, combine::parser::sequence::With<combine::parser::byte::take_until_bytes<combine::stream::easy::Stream<combine::stream::MaybePartialStream<&[u8]>>>, combine::parser::combinator::Map<combine::parser::range::Take<combine::stream::easy::Stream<combine::stream::MaybePartialStream<&[u8]>>>, redis::parser::value<combine::stream::easy::Stream<combine::stream::MaybePartialStream<&[u8]>>>::{closure#0}::{closure#1}::{closure#0}::{closure#0}>>>, redis::parser::value<combine::stream::easy::Stream<combine::stream::MaybePartialStream<&[u8]>>>::{closure#0}::{closure#1}::{closure#0}::{closure#1}>, redis::parser::err_parser>, redis::types::Value::ServerError>, combine::parser::combinator::Map<combine::parser::combinator::AndThen<combine::parser::range::Recognize<combine::stream::easy::Stream<combine::stream::MaybePartialStream<&[u8]>>, combine::parser::sequence::With<combine::parser::byte::take_until_bytes<combine::stream::easy::Stream<combine::stream::MaybePartialStream<&[u8]>>>, combine::parser::combinator::Map<combine::parser::range::Take<combine::stream::easy::Stream<combine::stream::MaybePartialStream<&[u8]>>>, redis::parser::value<combine::stream::easy::Stream<combine::stream::MaybePartialStream<&[u8]>>>::{closure#0}::{closure#1}::{closure#0}::{closure#0}>>>, redis::parser::value<combine::stream::easy::Stream<combine::stream::MaybePartialStream<&[u8]>>>::{closure#0}::{closure#1}::{closure#0}::{closure#1}>, redis::parser::value<combine::stream::easy::Stream<combine::stream::MaybePartialStream<&[u8]>>>::{closure#0}::{closure#1}::{closure#11}::{closure#0}>, combine::parser::combinator::Map<combine::parser::combinator::AndThen<combine::parser::combinator::AndThen<combine::parser::range::Recognize<combine::stream::easy::Stream<combine::stream::MaybePartialStream<&[u8]>>, combine::parser::sequence::With<combine::parser::byte::take_until_bytes<combine::stream::easy::Stream<combine::stream::MaybePartialStream<&[u8]>>>, combine::parser::combinator::Map<combine::parser::range::Take<combine::stream::easy::Stream<combine::stream::MaybePartialStream<&[u8]>>>, redis::parser::value<combine::stream::easy::Stream<combine::stream::MaybePartialStream<&[u8]>>>::{closure#0}::{closure#1}::{closure#0}::{closure#0}>>>, redis::parser::value<combine::stream::easy::Stream<combine::stream::MaybePartialStream<&[u8]>>>::{closure#0}::{closure#1}::{closure#0}::{closure#1}>, redis::parser::value<combine::stream::easy::Stream<combine::stream::MaybePartialStream<&[u8]>>>::{closure#0}::{closure#1}::{closure#12}::{closure#0}>, redis::types::Value::Double>, combine::parser::combinator::Map<combine::parser::combinator::AndThen<combine::parser::combinator::AndThen<combine::parser::range::Recognize<combine::stream::easy::Stream<combine::stream::MaybePartialStream<&[u8]>>, combine::parser::sequence::With<combine::parser::byte::take_until_bytes<combine::stream::easy::Stream<combine::stream::MaybePartialStream<&[u8]>>>, combine::parser::combinator::Map<combine::parser::range::Take<combine::stream::easy::Stream<combine::stream::MaybePartialStream<&[u8]>>>, redis::parser::value<combine::stream::easy::Stream<combine::stream::MaybePartialStream<&[u8]>>>::{closure#0}::{closure#1}::{closure#0}::{closure#0}>>>, redis::parser::value<combine::stream::easy::Stream<combine::stream::MaybePartialStream<&[u8]>>>::{closure#0}::{closure#1}::{closure#0}::{closure#1}>, redis::parser::value<combine::stream::easy::Stream<combine::stream::MaybePartialStream<&[u8]>>>::{closure#0}::{closure#1}::{closure#13}::{closure#0}>, redis::types::Value::Boolean>, combine::parser::combinator::Map<combine::parser::combinator::Map<combine::parser::sequence::ThenPartial<combine::parser::combinator::AndThen<combine::parser::combinator::AndThen<combine::parser::range::Recognize<combine::stream::easy::Stream<combine::stream::MaybePartialStream<&[u8]>>, combine::parser::sequence::With<combine::parser::byte::take_until_bytes<combine::stream::easy::Stream<combine::stream::MaybePartialStream<&[u8]>>>, combine::parser::combinator::Map<combine::parser::range::Take<combine::stream::easy::Stream<combine::stream::MaybePartialStream<&[u8]>>>, redis::parser::value<combine::stream::easy::Stream<combine::stream::MaybePartialStream<&[u8]>>>::{closure#0}::{closure#1}::{closure#0}::{closure#0}>>>, redis::parser::value<combine::stream::easy::Stream<combine::stream::MaybePartialStream<&[u8]>>>::{closure#0}::{closure#1}::{closure#0}::{closure#1}>, redis::parser::value<combine::stream::easy::Stream<combine::stream::MaybePartialStream<&[u8]>>>::{closure#0}::{closure#1}::{closure#2}::{closure#0}>, redis::parser::value<combine::stream::easy::Stream<combine::stream::MaybePartialStream<&[u8]>>>::{closure#0}::{closure#1}::{closure#4}::{closure#0}>, redis::parser::value<combine::stream::easy::Stream<combine::stream::MaybePartialStream<&[u8]>>>::{closure#0}::{closure#1}::{closure#14}::{closure#0}>, redis::types::Value::ServerError>, combine::parser::combinator::AndThen<combine::parser::sequence::ThenPartial<combine::parser::combinator::AndThen<combine::parser::combinator::AndThen<combine::parser::range::Recognize<combine::stream::easy::Stream<combine::stream::MaybePartialStream<&[u8]>>, combine::parser::sequence::With<combine::parser::byte::take_until_bytes<combine::stream::easy::Stream<combine::stream::MaybePartialStream<&[u8]>>>, combine::parser::combinator::Map<combine::parser::range::Take<combine::stream::easy::Stream<combine::stream::MaybePartialStream<&[u8]>>>, redis::parser::value<combine::stream::easy::Stream<combine::stream::MaybePartialStream<&[u8]>>>::{closure#0}::{closure#1}::{closure#0}::{closure#0}>>>, redis::parser::value<combine::stream::easy::Stream<combine::stream::MaybePartialStream<&[u8]>>>::{closure#0}::{closure#1}::{closure#0}::{closure#1}>, redis::parser::value<combine::stream::easy::Stream<combine::stream::MaybePartialStream<&[u8]>>>::{closure#0}::{closure#1}::{closure#2}::{closure#0}>, redis::parser::value<combine::stream::easy::Stream<combine::stream::MaybePartialStream<&[u8]>>>::{closure#0}::{closure#1}::{closure#4}::{closure#0}>, redis::parser::value<combine::stream::easy::Stream<combine::stream::MaybePartialStream<&[u8]>>>::{closure#0}::{closure#1}::{closure#15}::{closure#0}>, combine::parser::combinator::AndThen<combine::parser::combinator::AndThen<combine::parser::range::Recognize<combine::stream::easy::Stream<combine::stream::MaybePartialStream<&[u8]>>, combine::parser::sequence::With<combine::parser::byte::take_until_bytes<combine::stream::easy::Stream<combine::stream::MaybePartialStream<&[u8]>>>, combine::parser::combinator::Map<combine::parser::range::Take<combine::stream::easy::Stream<combine::stream::MaybePartialStream<&[u8]>>>, redis::parser::value<combine::stream::easy::Stream<combine::stream::MaybePartialStream<&[u8]>>>::{closure#0}::{closure#1}::{closure#0}::{closure#0}>>>, redis::parser::value<combine::stream::easy::Stream<combine::stream::MaybePartialStream<&[u8]>>>::{closure#0}::{closure#1}::{closure#0}::{closure#1}>, redis::parser::value<combine::stream::easy::Stream<combine::stream::MaybePartialStream<&[u8]>>>::{closure#0}::{closure#1}::{closure#16}::{closure#0}>, combine::parser::sequence::ThenPartial<combine::parser::combinator::AndThen<combine::parser::combinator::AndThen<combine::parser::range::Recognize<combine::stream::easy::Stream<combine::stream::MaybePartialStream<&[u8]>>, combine::parser::sequence::With<combine::parser::byte::take_until_bytes<combine::stream::easy::Stream<combine::stream::MaybePartialStream<&[u8]>>>, combine::parser::combinator::Map<combine::parser::range::Take<combine::stream::easy::Stream<combine::stream::MaybePartialStream<&[u8]>>>, redis::parser::value<combine::stream::easy::Stream<combine::stream::MaybePartialStream<&[u8]>>>::{closure#0}::{closure#1}::{closure#0}::{closure#0}>>>, redis::parser::value<combine::stream::easy::Stream<combine::stream::MaybePartialStream<&[u8]>>>::{closure#0}::{closure#1}::{closure#0}::{closure#1}>, redis::parser::value<combine::stream::easy::Stream<combine::stream::MaybePartialStream<&[u8]>>>::{closure#0}::{closure#1}::{closure#2}::{closure#0}>, redis::parser::value<combine::stream::easy::Stream<combine::stream::MaybePartialStream<&[u8]>>>::{closure#0}::{closure#1}::{closure#10}::{closure#0}>, combine::parser::error::Unexpected<combine::stream::easy::Stream<combine::stream::MaybePartialStream<&[u8]>>, redis::types::Value, combine::error::Token<u8>>> as combine::parser::Parser<combine::stream::easy::Stream<combine::stream::MaybePartialStream<&[u8]>>>>::parse_mode::<combine::parser::FirstMode>Line | Count | Source | 741 | 7.68M | fn parse_mode<Mode>( | 742 | 7.68M | &mut self, | 743 | 7.68M | mode: Mode, | 744 | 7.68M | input: &mut Input, | 745 | 7.68M | state: &mut Self::PartialState, | 746 | 7.68M | ) -> $crate::error::ParseResult<Self::Output, <Input as $crate::StreamOnce>::Error> | 747 | 7.68M | where | 748 | 7.68M | Mode: $crate::parser::ParseMode, | 749 | | { | 750 | 7.68M | match self { | 751 | | $( | 752 | 6.60M | $parser_name::$id($id) => { | 753 | 6.60M | let state = match state { | 754 | 5.78M | Some($parser_name::$id(s)) => s, | 755 | | _ => { | 756 | 811k | *state = Some($parser_name::$id(Default::default())); | 757 | 811k | match state { | 758 | 811k | Some($parser_name::$id(s)) => s, | 759 | 0 | _ => unreachable!(), | 760 | | } | 761 | | } | 762 | | }; | 763 | 6.60M | $id.parse_mode(mode, input, state) | 764 | | } | 765 | | )* | 766 | | } | 767 | 7.68M | } |
|
768 | | |
769 | 1.23k | fn add_error(&mut self, error: &mut $crate::error::Tracked<<Input as $crate::StreamOnce>::Error>) { |
770 | 1.23k | match self { |
771 | | $( |
772 | 65 | $parser_name::$id($id) => $id.add_error(error), |
773 | | )* |
774 | | } |
775 | 1.23k | } |
776 | | } |
777 | | } |
778 | | } |
779 | | |
780 | | #[macro_export] |
781 | | #[doc(hidden)] |
782 | | macro_rules! dispatch_inner { |
783 | | ($expr_ident: ident [$first_ident: ident $($id: ident)*] [$($collected: tt)*] $($pat: pat)|+ $(if $pred:expr)? => $expr: expr, $($rest_alt: tt)*) => { |
784 | | $crate::dispatch_inner!{ $expr_ident [ $($id)* ] [$($collected)* $first_ident $($pat)|+ $(if $pred)? => $expr,] $($rest_alt)*} |
785 | | }; |
786 | | ($expr_ident: ident [$($id: ident)*] [$($collected: tt)*]) => { |
787 | | $crate::dispatch_inner!{ $expr_ident $($collected)* } |
788 | | }; |
789 | | ($expr_ident: ident [$($ident_tt: tt)*]) => { |
790 | | unreachable!() |
791 | | }; |
792 | | ($expr_ident: ident $( $ident: ident $($pat: pat)|+ $(if $pred:expr)? => $expr: expr,)+ ) => { |
793 | | match $expr_ident { |
794 | | $( |
795 | | $($pat)|+ $(if $pred)? => Dispatch::$ident(check_parser($expr)), |
796 | | )+ |
797 | | } |
798 | | } |
799 | | } |
800 | | |
801 | | /// `dispatch!` allows a parser to be constructed depending on earlier input, without forcing each |
802 | | /// branch to have the same type of parser |
803 | | /// |
804 | | /// ``` |
805 | | /// use combine::{dispatch, any, token, satisfy, EasyParser, Parser}; |
806 | | /// |
807 | | /// let mut parser = any().then(|e| { |
808 | | /// dispatch!(e; |
809 | | /// 'a' => token('a'), |
810 | | /// 'b' => satisfy(|b| b == 'b'), |
811 | | /// t if t == 'c' => any(), |
812 | | /// _ => token('d') |
813 | | /// ) |
814 | | /// }); |
815 | | /// assert_eq!(parser.easy_parse("aa"), Ok(('a', ""))); |
816 | | /// assert_eq!(parser.easy_parse("cc"), Ok(('c', ""))); |
817 | | /// assert_eq!(parser.easy_parse("cd"), Ok(('d', ""))); |
818 | | /// assert!(parser.easy_parse("ab").is_err()); |
819 | | /// ``` |
820 | | #[macro_export] |
821 | | macro_rules! dispatch { |
822 | | ($match_expr: expr; $( $($pat: pat)|+ $(if $pred:expr)? => $expr: expr ),+ $(,)? ) => { |
823 | | { |
824 | | $crate::dispatch_parser_impl!{ Dispatch [A B C D E F G H I J K L M N O P Q R S T U V X Y Z] [] $($expr,)+ } |
825 | | |
826 | 7.88M | fn check_parser<Input, P>(p: P) -> P where P: $crate::Parser<Input>, Input: $crate::Stream { p }redis::parser::value::{closure#0}::{closure#1}::check_parser::<combine::stream::easy::Stream<combine::stream::MaybePartialStream<&[u8]>>, combine::parser::combinator::Map<combine::parser::combinator::Map<combine::parser::combinator::AndThen<combine::parser::range::Recognize<combine::stream::easy::Stream<combine::stream::MaybePartialStream<&[u8]>>, combine::parser::sequence::With<combine::parser::byte::take_until_bytes<combine::stream::easy::Stream<combine::stream::MaybePartialStream<&[u8]>>>, combine::parser::combinator::Map<combine::parser::range::Take<combine::stream::easy::Stream<combine::stream::MaybePartialStream<&[u8]>>>, redis::parser::value<combine::stream::easy::Stream<combine::stream::MaybePartialStream<&[u8]>>>::{closure#0}::{closure#1}::{closure#0}::{closure#0}>>>, redis::parser::value<combine::stream::easy::Stream<combine::stream::MaybePartialStream<&[u8]>>>::{closure#0}::{closure#1}::{closure#0}::{closure#1}>, redis::parser::err_parser>, redis::types::Value::ServerError>>Line | Count | Source | 826 | 221k | fn check_parser<Input, P>(p: P) -> P where P: $crate::Parser<Input>, Input: $crate::Stream { p } |
redis::parser::value::{closure#0}::{closure#1}::check_parser::<combine::stream::easy::Stream<combine::stream::MaybePartialStream<&[u8]>>, combine::parser::combinator::Map<combine::parser::combinator::Map<combine::parser::sequence::ThenPartial<combine::parser::combinator::AndThen<combine::parser::combinator::AndThen<combine::parser::range::Recognize<combine::stream::easy::Stream<combine::stream::MaybePartialStream<&[u8]>>, combine::parser::sequence::With<combine::parser::byte::take_until_bytes<combine::stream::easy::Stream<combine::stream::MaybePartialStream<&[u8]>>>, combine::parser::combinator::Map<combine::parser::range::Take<combine::stream::easy::Stream<combine::stream::MaybePartialStream<&[u8]>>>, redis::parser::value<combine::stream::easy::Stream<combine::stream::MaybePartialStream<&[u8]>>>::{closure#0}::{closure#1}::{closure#0}::{closure#0}>>>, redis::parser::value<combine::stream::easy::Stream<combine::stream::MaybePartialStream<&[u8]>>>::{closure#0}::{closure#1}::{closure#0}::{closure#1}>, redis::parser::value<combine::stream::easy::Stream<combine::stream::MaybePartialStream<&[u8]>>>::{closure#0}::{closure#1}::{closure#2}::{closure#0}>, redis::parser::value<combine::stream::easy::Stream<combine::stream::MaybePartialStream<&[u8]>>>::{closure#0}::{closure#1}::{closure#4}::{closure#0}>, redis::parser::value<combine::stream::easy::Stream<combine::stream::MaybePartialStream<&[u8]>>>::{closure#0}::{closure#1}::{closure#14}::{closure#0}>, redis::types::Value::ServerError>>Line | Count | Source | 826 | 33.7k | fn check_parser<Input, P>(p: P) -> P where P: $crate::Parser<Input>, Input: $crate::Stream { p } |
redis::parser::value::{closure#0}::{closure#1}::check_parser::<combine::stream::easy::Stream<combine::stream::MaybePartialStream<&[u8]>>, combine::parser::combinator::Map<combine::parser::combinator::AndThen<combine::parser::combinator::AndThen<combine::parser::range::Recognize<combine::stream::easy::Stream<combine::stream::MaybePartialStream<&[u8]>>, combine::parser::sequence::With<combine::parser::byte::take_until_bytes<combine::stream::easy::Stream<combine::stream::MaybePartialStream<&[u8]>>>, combine::parser::combinator::Map<combine::parser::range::Take<combine::stream::easy::Stream<combine::stream::MaybePartialStream<&[u8]>>>, redis::parser::value<combine::stream::easy::Stream<combine::stream::MaybePartialStream<&[u8]>>>::{closure#0}::{closure#1}::{closure#0}::{closure#0}>>>, redis::parser::value<combine::stream::easy::Stream<combine::stream::MaybePartialStream<&[u8]>>>::{closure#0}::{closure#1}::{closure#0}::{closure#1}>, redis::parser::value<combine::stream::easy::Stream<combine::stream::MaybePartialStream<&[u8]>>>::{closure#0}::{closure#1}::{closure#2}::{closure#0}>, redis::types::Value::Int>>Line | Count | Source | 826 | 298k | fn check_parser<Input, P>(p: P) -> P where P: $crate::Parser<Input>, Input: $crate::Stream { p } |
redis::parser::value::{closure#0}::{closure#1}::check_parser::<combine::stream::easy::Stream<combine::stream::MaybePartialStream<&[u8]>>, combine::parser::combinator::Map<combine::parser::combinator::AndThen<combine::parser::combinator::AndThen<combine::parser::range::Recognize<combine::stream::easy::Stream<combine::stream::MaybePartialStream<&[u8]>>, combine::parser::sequence::With<combine::parser::byte::take_until_bytes<combine::stream::easy::Stream<combine::stream::MaybePartialStream<&[u8]>>>, combine::parser::combinator::Map<combine::parser::range::Take<combine::stream::easy::Stream<combine::stream::MaybePartialStream<&[u8]>>>, redis::parser::value<combine::stream::easy::Stream<combine::stream::MaybePartialStream<&[u8]>>>::{closure#0}::{closure#1}::{closure#0}::{closure#0}>>>, redis::parser::value<combine::stream::easy::Stream<combine::stream::MaybePartialStream<&[u8]>>>::{closure#0}::{closure#1}::{closure#0}::{closure#1}>, redis::parser::value<combine::stream::easy::Stream<combine::stream::MaybePartialStream<&[u8]>>>::{closure#0}::{closure#1}::{closure#12}::{closure#0}>, redis::types::Value::Double>>Line | Count | Source | 826 | 11.7k | fn check_parser<Input, P>(p: P) -> P where P: $crate::Parser<Input>, Input: $crate::Stream { p } |
redis::parser::value::{closure#0}::{closure#1}::check_parser::<combine::stream::easy::Stream<combine::stream::MaybePartialStream<&[u8]>>, combine::parser::combinator::Map<combine::parser::combinator::AndThen<combine::parser::combinator::AndThen<combine::parser::range::Recognize<combine::stream::easy::Stream<combine::stream::MaybePartialStream<&[u8]>>, combine::parser::sequence::With<combine::parser::byte::take_until_bytes<combine::stream::easy::Stream<combine::stream::MaybePartialStream<&[u8]>>>, combine::parser::combinator::Map<combine::parser::range::Take<combine::stream::easy::Stream<combine::stream::MaybePartialStream<&[u8]>>>, redis::parser::value<combine::stream::easy::Stream<combine::stream::MaybePartialStream<&[u8]>>>::{closure#0}::{closure#1}::{closure#0}::{closure#0}>>>, redis::parser::value<combine::stream::easy::Stream<combine::stream::MaybePartialStream<&[u8]>>>::{closure#0}::{closure#1}::{closure#0}::{closure#1}>, redis::parser::value<combine::stream::easy::Stream<combine::stream::MaybePartialStream<&[u8]>>>::{closure#0}::{closure#1}::{closure#13}::{closure#0}>, redis::types::Value::Boolean>>Line | Count | Source | 826 | 91.9k | fn check_parser<Input, P>(p: P) -> P where P: $crate::Parser<Input>, Input: $crate::Stream { p } |
redis::parser::value::{closure#0}::{closure#1}::check_parser::<combine::stream::easy::Stream<combine::stream::MaybePartialStream<&[u8]>>, combine::parser::combinator::Map<combine::parser::combinator::AndThen<combine::parser::range::Recognize<combine::stream::easy::Stream<combine::stream::MaybePartialStream<&[u8]>>, combine::parser::sequence::With<combine::parser::byte::take_until_bytes<combine::stream::easy::Stream<combine::stream::MaybePartialStream<&[u8]>>>, combine::parser::combinator::Map<combine::parser::range::Take<combine::stream::easy::Stream<combine::stream::MaybePartialStream<&[u8]>>>, redis::parser::value<combine::stream::easy::Stream<combine::stream::MaybePartialStream<&[u8]>>>::{closure#0}::{closure#1}::{closure#0}::{closure#0}>>>, redis::parser::value<combine::stream::easy::Stream<combine::stream::MaybePartialStream<&[u8]>>>::{closure#0}::{closure#1}::{closure#0}::{closure#1}>, redis::parser::value<combine::stream::easy::Stream<combine::stream::MaybePartialStream<&[u8]>>>::{closure#0}::{closure#1}::{closure#11}::{closure#0}>>Line | Count | Source | 826 | 26.6k | fn check_parser<Input, P>(p: P) -> P where P: $crate::Parser<Input>, Input: $crate::Stream { p } |
redis::parser::value::{closure#0}::{closure#1}::check_parser::<combine::stream::easy::Stream<combine::stream::MaybePartialStream<&[u8]>>, combine::parser::combinator::Map<combine::parser::combinator::AndThen<combine::parser::range::Recognize<combine::stream::easy::Stream<combine::stream::MaybePartialStream<&[u8]>>, combine::parser::sequence::With<combine::parser::byte::take_until_bytes<combine::stream::easy::Stream<combine::stream::MaybePartialStream<&[u8]>>>, combine::parser::combinator::Map<combine::parser::range::Take<combine::stream::easy::Stream<combine::stream::MaybePartialStream<&[u8]>>>, redis::parser::value<combine::stream::easy::Stream<combine::stream::MaybePartialStream<&[u8]>>>::{closure#0}::{closure#1}::{closure#0}::{closure#0}>>>, redis::parser::value<combine::stream::easy::Stream<combine::stream::MaybePartialStream<&[u8]>>>::{closure#0}::{closure#1}::{closure#0}::{closure#1}>, redis::parser::value<combine::stream::easy::Stream<combine::stream::MaybePartialStream<&[u8]>>>::{closure#0}::{closure#1}::{closure#1}::{closure#0}>>Line | Count | Source | 826 | 6.60M | fn check_parser<Input, P>(p: P) -> P where P: $crate::Parser<Input>, Input: $crate::Stream { p } |
redis::parser::value::{closure#0}::{closure#1}::check_parser::<combine::stream::easy::Stream<combine::stream::MaybePartialStream<&[u8]>>, combine::parser::combinator::AndThen<combine::parser::combinator::AndThen<combine::parser::range::Recognize<combine::stream::easy::Stream<combine::stream::MaybePartialStream<&[u8]>>, combine::parser::sequence::With<combine::parser::byte::take_until_bytes<combine::stream::easy::Stream<combine::stream::MaybePartialStream<&[u8]>>>, combine::parser::combinator::Map<combine::parser::range::Take<combine::stream::easy::Stream<combine::stream::MaybePartialStream<&[u8]>>>, redis::parser::value<combine::stream::easy::Stream<combine::stream::MaybePartialStream<&[u8]>>>::{closure#0}::{closure#1}::{closure#0}::{closure#0}>>>, redis::parser::value<combine::stream::easy::Stream<combine::stream::MaybePartialStream<&[u8]>>>::{closure#0}::{closure#1}::{closure#0}::{closure#1}>, redis::parser::value<combine::stream::easy::Stream<combine::stream::MaybePartialStream<&[u8]>>>::{closure#0}::{closure#1}::{closure#16}::{closure#0}>>Line | Count | Source | 826 | 24.0k | fn check_parser<Input, P>(p: P) -> P where P: $crate::Parser<Input>, Input: $crate::Stream { p } |
redis::parser::value::{closure#0}::{closure#1}::check_parser::<combine::stream::easy::Stream<combine::stream::MaybePartialStream<&[u8]>>, combine::parser::combinator::AndThen<combine::parser::sequence::ThenPartial<combine::parser::combinator::AndThen<combine::parser::combinator::AndThen<combine::parser::range::Recognize<combine::stream::easy::Stream<combine::stream::MaybePartialStream<&[u8]>>, combine::parser::sequence::With<combine::parser::byte::take_until_bytes<combine::stream::easy::Stream<combine::stream::MaybePartialStream<&[u8]>>>, combine::parser::combinator::Map<combine::parser::range::Take<combine::stream::easy::Stream<combine::stream::MaybePartialStream<&[u8]>>>, redis::parser::value<combine::stream::easy::Stream<combine::stream::MaybePartialStream<&[u8]>>>::{closure#0}::{closure#1}::{closure#0}::{closure#0}>>>, redis::parser::value<combine::stream::easy::Stream<combine::stream::MaybePartialStream<&[u8]>>>::{closure#0}::{closure#1}::{closure#0}::{closure#1}>, redis::parser::value<combine::stream::easy::Stream<combine::stream::MaybePartialStream<&[u8]>>>::{closure#0}::{closure#1}::{closure#2}::{closure#0}>, redis::parser::value<combine::stream::easy::Stream<combine::stream::MaybePartialStream<&[u8]>>>::{closure#0}::{closure#1}::{closure#4}::{closure#0}>, redis::parser::value<combine::stream::easy::Stream<combine::stream::MaybePartialStream<&[u8]>>>::{closure#0}::{closure#1}::{closure#15}::{closure#0}>>Line | Count | Source | 826 | 43.9k | fn check_parser<Input, P>(p: P) -> P where P: $crate::Parser<Input>, Input: $crate::Stream { p } |
redis::parser::value::{closure#0}::{closure#1}::check_parser::<combine::stream::easy::Stream<combine::stream::MaybePartialStream<&[u8]>>, combine::parser::error::Unexpected<combine::stream::easy::Stream<combine::stream::MaybePartialStream<&[u8]>>, redis::types::Value, combine::error::Token<u8>>>Line | Count | Source | 826 | 548 | fn check_parser<Input, P>(p: P) -> P where P: $crate::Parser<Input>, Input: $crate::Stream { p } |
redis::parser::value::{closure#0}::{closure#1}::check_parser::<combine::stream::easy::Stream<combine::stream::MaybePartialStream<&[u8]>>, combine::parser::sequence::ThenPartial<combine::parser::combinator::AndThen<combine::parser::combinator::AndThen<combine::parser::range::Recognize<combine::stream::easy::Stream<combine::stream::MaybePartialStream<&[u8]>>, combine::parser::sequence::With<combine::parser::byte::take_until_bytes<combine::stream::easy::Stream<combine::stream::MaybePartialStream<&[u8]>>>, combine::parser::combinator::Map<combine::parser::range::Take<combine::stream::easy::Stream<combine::stream::MaybePartialStream<&[u8]>>>, redis::parser::value<combine::stream::easy::Stream<combine::stream::MaybePartialStream<&[u8]>>>::{closure#0}::{closure#1}::{closure#0}::{closure#0}>>>, redis::parser::value<combine::stream::easy::Stream<combine::stream::MaybePartialStream<&[u8]>>>::{closure#0}::{closure#1}::{closure#0}::{closure#1}>, redis::parser::value<combine::stream::easy::Stream<combine::stream::MaybePartialStream<&[u8]>>>::{closure#0}::{closure#1}::{closure#2}::{closure#0}>, redis::parser::value<combine::stream::easy::Stream<combine::stream::MaybePartialStream<&[u8]>>>::{closure#0}::{closure#1}::{closure#3}::{closure#0}>>Line | Count | Source | 826 | 85.7k | fn check_parser<Input, P>(p: P) -> P where P: $crate::Parser<Input>, Input: $crate::Stream { p } |
redis::parser::value::{closure#0}::{closure#1}::check_parser::<combine::stream::easy::Stream<combine::stream::MaybePartialStream<&[u8]>>, combine::parser::sequence::ThenPartial<combine::parser::combinator::AndThen<combine::parser::combinator::AndThen<combine::parser::range::Recognize<combine::stream::easy::Stream<combine::stream::MaybePartialStream<&[u8]>>, combine::parser::sequence::With<combine::parser::byte::take_until_bytes<combine::stream::easy::Stream<combine::stream::MaybePartialStream<&[u8]>>>, combine::parser::combinator::Map<combine::parser::range::Take<combine::stream::easy::Stream<combine::stream::MaybePartialStream<&[u8]>>>, redis::parser::value<combine::stream::easy::Stream<combine::stream::MaybePartialStream<&[u8]>>>::{closure#0}::{closure#1}::{closure#0}::{closure#0}>>>, redis::parser::value<combine::stream::easy::Stream<combine::stream::MaybePartialStream<&[u8]>>>::{closure#0}::{closure#1}::{closure#0}::{closure#1}>, redis::parser::value<combine::stream::easy::Stream<combine::stream::MaybePartialStream<&[u8]>>>::{closure#0}::{closure#1}::{closure#2}::{closure#0}>, redis::parser::value<combine::stream::easy::Stream<combine::stream::MaybePartialStream<&[u8]>>>::{closure#0}::{closure#1}::{closure#5}::{closure#0}>>Line | Count | Source | 826 | 88.7k | fn check_parser<Input, P>(p: P) -> P where P: $crate::Parser<Input>, Input: $crate::Stream { p } |
redis::parser::value::{closure#0}::{closure#1}::check_parser::<combine::stream::easy::Stream<combine::stream::MaybePartialStream<&[u8]>>, combine::parser::sequence::ThenPartial<combine::parser::combinator::AndThen<combine::parser::combinator::AndThen<combine::parser::range::Recognize<combine::stream::easy::Stream<combine::stream::MaybePartialStream<&[u8]>>, combine::parser::sequence::With<combine::parser::byte::take_until_bytes<combine::stream::easy::Stream<combine::stream::MaybePartialStream<&[u8]>>>, combine::parser::combinator::Map<combine::parser::range::Take<combine::stream::easy::Stream<combine::stream::MaybePartialStream<&[u8]>>>, redis::parser::value<combine::stream::easy::Stream<combine::stream::MaybePartialStream<&[u8]>>>::{closure#0}::{closure#1}::{closure#0}::{closure#0}>>>, redis::parser::value<combine::stream::easy::Stream<combine::stream::MaybePartialStream<&[u8]>>>::{closure#0}::{closure#1}::{closure#0}::{closure#1}>, redis::parser::value<combine::stream::easy::Stream<combine::stream::MaybePartialStream<&[u8]>>>::{closure#0}::{closure#1}::{closure#2}::{closure#0}>, redis::parser::value<combine::stream::easy::Stream<combine::stream::MaybePartialStream<&[u8]>>>::{closure#0}::{closure#1}::{closure#7}::{closure#0}>>Line | Count | Source | 826 | 94.8k | fn check_parser<Input, P>(p: P) -> P where P: $crate::Parser<Input>, Input: $crate::Stream { p } |
redis::parser::value::{closure#0}::{closure#1}::check_parser::<combine::stream::easy::Stream<combine::stream::MaybePartialStream<&[u8]>>, combine::parser::sequence::ThenPartial<combine::parser::combinator::AndThen<combine::parser::combinator::AndThen<combine::parser::range::Recognize<combine::stream::easy::Stream<combine::stream::MaybePartialStream<&[u8]>>, combine::parser::sequence::With<combine::parser::byte::take_until_bytes<combine::stream::easy::Stream<combine::stream::MaybePartialStream<&[u8]>>>, combine::parser::combinator::Map<combine::parser::range::Take<combine::stream::easy::Stream<combine::stream::MaybePartialStream<&[u8]>>>, redis::parser::value<combine::stream::easy::Stream<combine::stream::MaybePartialStream<&[u8]>>>::{closure#0}::{closure#1}::{closure#0}::{closure#0}>>>, redis::parser::value<combine::stream::easy::Stream<combine::stream::MaybePartialStream<&[u8]>>>::{closure#0}::{closure#1}::{closure#0}::{closure#1}>, redis::parser::value<combine::stream::easy::Stream<combine::stream::MaybePartialStream<&[u8]>>>::{closure#0}::{closure#1}::{closure#2}::{closure#0}>, redis::parser::value<combine::stream::easy::Stream<combine::stream::MaybePartialStream<&[u8]>>>::{closure#0}::{closure#1}::{closure#8}::{closure#0}>>Line | Count | Source | 826 | 62.0k | fn check_parser<Input, P>(p: P) -> P where P: $crate::Parser<Input>, Input: $crate::Stream { p } |
redis::parser::value::{closure#0}::{closure#1}::check_parser::<combine::stream::easy::Stream<combine::stream::MaybePartialStream<&[u8]>>, combine::parser::sequence::ThenPartial<combine::parser::combinator::AndThen<combine::parser::combinator::AndThen<combine::parser::range::Recognize<combine::stream::easy::Stream<combine::stream::MaybePartialStream<&[u8]>>, combine::parser::sequence::With<combine::parser::byte::take_until_bytes<combine::stream::easy::Stream<combine::stream::MaybePartialStream<&[u8]>>>, combine::parser::combinator::Map<combine::parser::range::Take<combine::stream::easy::Stream<combine::stream::MaybePartialStream<&[u8]>>>, redis::parser::value<combine::stream::easy::Stream<combine::stream::MaybePartialStream<&[u8]>>>::{closure#0}::{closure#1}::{closure#0}::{closure#0}>>>, redis::parser::value<combine::stream::easy::Stream<combine::stream::MaybePartialStream<&[u8]>>>::{closure#0}::{closure#1}::{closure#0}::{closure#1}>, redis::parser::value<combine::stream::easy::Stream<combine::stream::MaybePartialStream<&[u8]>>>::{closure#0}::{closure#1}::{closure#2}::{closure#0}>, redis::parser::value<combine::stream::easy::Stream<combine::stream::MaybePartialStream<&[u8]>>>::{closure#0}::{closure#1}::{closure#9}::{closure#0}>>Line | Count | Source | 826 | 52.0k | fn check_parser<Input, P>(p: P) -> P where P: $crate::Parser<Input>, Input: $crate::Stream { p } |
redis::parser::value::{closure#0}::{closure#1}::check_parser::<combine::stream::easy::Stream<combine::stream::MaybePartialStream<&[u8]>>, combine::parser::sequence::ThenPartial<combine::parser::combinator::AndThen<combine::parser::combinator::AndThen<combine::parser::range::Recognize<combine::stream::easy::Stream<combine::stream::MaybePartialStream<&[u8]>>, combine::parser::sequence::With<combine::parser::byte::take_until_bytes<combine::stream::easy::Stream<combine::stream::MaybePartialStream<&[u8]>>>, combine::parser::combinator::Map<combine::parser::range::Take<combine::stream::easy::Stream<combine::stream::MaybePartialStream<&[u8]>>>, redis::parser::value<combine::stream::easy::Stream<combine::stream::MaybePartialStream<&[u8]>>>::{closure#0}::{closure#1}::{closure#0}::{closure#0}>>>, redis::parser::value<combine::stream::easy::Stream<combine::stream::MaybePartialStream<&[u8]>>>::{closure#0}::{closure#1}::{closure#0}::{closure#1}>, redis::parser::value<combine::stream::easy::Stream<combine::stream::MaybePartialStream<&[u8]>>>::{closure#0}::{closure#1}::{closure#2}::{closure#0}>, redis::parser::value<combine::stream::easy::Stream<combine::stream::MaybePartialStream<&[u8]>>>::{closure#0}::{closure#1}::{closure#10}::{closure#0}>>Line | Count | Source | 826 | 137k | fn check_parser<Input, P>(p: P) -> P where P: $crate::Parser<Input>, Input: $crate::Stream { p } |
|
827 | | |
828 | | let e = $match_expr; |
829 | | let parser = $crate::dispatch_inner!(e [A B C D E F G H I J K L M N O P Q R S T U V X Y Z] [] |
830 | | $( |
831 | | $($pat)|+ $(if $pred)? => $expr, |
832 | | )* |
833 | | ); |
834 | | parser |
835 | | } |
836 | | } |
837 | | } |
838 | | |
839 | | #[cfg(all(feature = "std", test))] |
840 | | mod tests { |
841 | | |
842 | | use crate::parser::{token::any, EasyParser}; |
843 | | |
844 | | use super::*; |
845 | | |
846 | | #[test] |
847 | | fn choice_single_parser() { |
848 | | assert!(choice((any(),),).easy_parse("a").is_ok()); |
849 | | } |
850 | | } |