• Home
  • Raw
  • Download

Lines Matching full:input

31 pub struct Range<Input>(Input::Range)
33 Input: RangeStream;
35 impl<Input> Parser<Input> for Range<Input>
37 Input: RangeStream,
38 Input::Range: PartialEq + crate::stream::Range,
40 type Output = Input::Range;
46 input: &mut Input, in parse_lazy() argument
47 ) -> ParseResult<Self::Output, <Input as StreamOnce>::Error> { in parse_lazy()
50 let position = input.position(); in parse_lazy()
51 match input.uncons_range(self.0.len()) { in parse_lazy()
56 PeekErr(Input::Error::empty(position).into()) in parse_lazy()
59 Err(err) => wrap_stream_error(input, err), in parse_lazy()
62 fn add_error(&mut self, errors: &mut Tracked<<Input as StreamOnce>::Error>) { in add_error()
71 type PartialState = <RecognizeWithValue<P> as Parser<Input>>::PartialState;
72 /// Zero-copy parser which returns committed input range.
88 pub fn recognize[Input, P](parser: P)(Input) -> <Input as StreamOnce>::Range
90 P: Parser<Input>,
91 Input: RangeStream,
92 <Input as StreamOnce>::Range: crate::stream::Range,
100 fn parse_partial_range<M, F, G, S, Input>( in parse_partial_range()
102 input: &mut Input, in parse_partial_range() argument
107 ) -> ParseResult<Input::Range, Input::Error> in parse_partial_range()
110 F: FnOnce(&mut Input, S) -> ParseResult<Input::Range, <Input as StreamOnce>::Error>, in parse_partial_range() argument
111 G: FnOnce(&mut Input, S) -> ParseResult<Input::Range, <Input as StreamOnce>::Error>, in parse_partial_range() argument
112 Input: RangeStream, in parse_partial_range()
114 let before = input.checkpoint(); in parse_partial_range()
116 if !input.is_partial() { in parse_partial_range()
117 first(input, state) in parse_partial_range()
119 let result = first(input, state); in parse_partial_range()
121 *distance_state = input.distance(&before); in parse_partial_range()
122 ctry!(input.reset(before).committed()); in parse_partial_range()
126 if input.uncons_range(*distance_state).is_err() { in parse_partial_range()
127 panic!("recognize errored when restoring the input stream to its expected state"); in parse_partial_range()
130 match resume(input, state) { in parse_partial_range()
134 *distance_state = input.distance(&before); in parse_partial_range()
135 ctry!(input.reset(before).committed()); in parse_partial_range()
140 let distance = input.distance(&before); in parse_partial_range()
141 ctry!(input.reset(before).committed()); in parse_partial_range()
142 take(distance).parse_lazy(input).map(|range| { in parse_partial_range()
152 impl<Input, P> Parser<Input> for RecognizeWithValue<P>
154 P: Parser<Input>,
155 Input: RangeStream,
156 <Input as StreamOnce>::Range: crate::stream::Range,
158 type Output = (<Input as StreamOnce>::Range, P::Output);
161 parse_mode!(Input);
166 input: &mut Input, in parse_mode() argument
168 ) -> ParseResult<Self::Output, <Input as StreamOnce>::Error> in parse_mode()
174 let before = input.checkpoint(); in parse_mode()
175 if !mode.is_first() && input.uncons_range(*distance_state).is_err() { in parse_mode()
176 panic!("recognize errored when restoring the input stream to its expected state"); in parse_mode()
179 let value = match self.0.parse_mode(mode, input, child_state) { in parse_mode()
183 *distance_state = input.distance(&before); in parse_mode()
184 ctry!(input.reset(before).committed()); in parse_mode()
189 let distance = input.distance(&before); in parse_mode()
190 ctry!(input.reset(before).committed()); in parse_mode()
191 take(distance).parse_lazy(input).map(|range| { in parse_mode()
196 fn add_error(&mut self, errors: &mut Tracked<<Input as StreamOnce>::Error>) { in add_error()
201 /// Zero-copy parser which returns a pair: (committed input range, parsed value).
224 pub fn recognize_with_value<Input, P>(parser: P) -> RecognizeWithValue<P> in recognize_with_value() argument
226 P: Parser<Input>, in recognize_with_value()
227 Input: RangeStream, in recognize_with_value()
228 <Input as StreamOnce>::Range: crate::stream::Range, in recognize_with_value()
251 pub fn range<Input>(i: Input::Range) -> Range<Input> in range()
253 Input: RangeStream, in range()
254 Input::Range: PartialEq, in range()
259 pub struct Take<Input>(usize, PhantomData<fn(Input)>);
260 impl<Input> Parser<Input> for Take<Input>
262 Input: RangeStream,
264 type Output = Input::Range;
270 input: &mut Input, in parse_lazy() argument
271 ) -> ParseResult<Self::Output, <Input as StreamOnce>::Error> { in parse_lazy()
272 uncons_range(input, self.0) in parse_lazy()
296 pub fn take<Input>(n: usize) -> Take<Input> in take()
298 Input: RangeStream, in take()
303 pub struct TakeWhile<Input, F>(F, PhantomData<fn(Input) -> Input>);
304 impl<Input, F> Parser<Input> for TakeWhile<Input, F>
306 Input: RangeStream,
307 Input::Range: crate::stream::Range,
308 F: FnMut(Input::Token) -> bool,
310 type Output = Input::Range;
313 parse_mode!(Input);
318 input: &mut Input, in parse_mode_impl() argument
320 ) -> ParseResult<Self::Output, <Input as StreamOnce>::Error> in parse_mode_impl()
326 input, in parse_mode_impl()
329 |input, predicate| uncons_while(input, predicate), in parse_mode_impl()
330 |input, predicate| uncons_while(input, predicate), in parse_mode_impl()
352 pub fn take_while<Input, F>(f: F) -> TakeWhile<Input, F> in take_while() argument
354 Input: RangeStream, in take_while()
355 Input::Range: crate::stream::Range, in take_while()
356 F: FnMut(Input::Token) -> bool, in take_while()
361 pub struct TakeWhile1<Input, F>(F, PhantomData<fn(Input) -> Input>);
362 impl<Input, F> Parser<Input> for TakeWhile1<Input, F>
364 Input: RangeStream,
365 Input::Range: crate::stream::Range,
366 F: FnMut(Input::Token) -> bool,
368 type Output = Input::Range;
371 parse_mode!(Input);
376 input: &mut Input, in parse_mode_impl() argument
378 ) -> ParseResult<Self::Output, <Input as StreamOnce>::Error> in parse_mode_impl()
384 input, in parse_mode_impl()
387 |input, predicate| uncons_while1(input, predicate), in parse_mode_impl()
388 |input, predicate| uncons_while(input, predicate), in parse_mode_impl()
410 pub fn take_while1<Input, F>(f: F) -> TakeWhile1<Input, F> in take_while1() argument
412 Input: RangeStream, in take_while1()
413 Input::Range: crate::stream::Range, in take_while1()
414 F: FnMut(Input::Token) -> bool, in take_while1()
419 pub struct TakeUntilRange<Input>(Input::Range)
421 Input: RangeStream;
422 impl<Input> Parser<Input> for TakeUntilRange<Input>
424 Input: RangeStream,
425 Input::Range: PartialEq + crate::stream::Range,
427 type Output = Input::Range;
433 input: &mut Input, in parse_partial() argument
435 ) -> ParseResult<Self::Output, <Input as StreamOnce>::Error> { in parse_partial()
439 let before = input.checkpoint(); in parse_partial()
443 ctry!(uncons_range(input, *to_consume)); in parse_partial()
446 let look_ahead_input = input.checkpoint(); in parse_partial()
448 match input.uncons_range(len) { in parse_partial()
451 let distance = input.distance(&before) - len; in parse_partial()
452 ctry!(input.reset(before).committed()); in parse_partial()
454 if let Ok(committed) = input.uncons_range(distance) { in parse_partial()
468 ctry!(input.reset(look_ahead_input).committed()); in parse_partial()
471 if input.uncons().is_err() { in parse_partial()
481 … // with more input we must start parsing again at the first time we errored so we in parse_partial()
484 first_stream_error = Some((first_error, input.distance(&before))); in parse_partial()
488 ctry!(input.reset(look_ahead_input).committed()); in parse_partial()
491 if input.uncons().is_err() { in parse_partial()
495 ctry!(input.reset(before).committed()); in parse_partial()
499 return wrap_stream_error(input, first_error); in parse_partial()
527 pub fn take_until_range<Input>(r: Input::Range) -> TakeUntilRange<Input> in take_until_range()
529 Input: RangeStream, in take_until_range()
551 pub struct TakeFn<F, Input> {
553 _marker: PhantomData<fn(Input)>,
556 impl<Input, F, R> Parser<Input> for TakeFn<F, Input>
558 F: FnMut(Input::Range) -> R,
560 Input: RangeStream,
561 Input::Range: crate::stream::Range,
563 type Output = Input::Range;
566 parse_mode!(Input);
571 input: &mut Input, in parse_mode() argument
573 ) -> ParseResult<Self::Output, <Input as StreamOnce>::Error> in parse_mode()
577 let checkpoint = input.checkpoint(); in parse_mode()
582 let _ = input.uncons_range(*offset); in parse_mode()
585 match (self.searcher)(input.range()).into() { in parse_mode()
587 ctry!(input.reset(checkpoint).committed()); in parse_mode()
588 let result = uncons_range(input, *offset + i); in parse_mode()
597 let range = input.range(); in parse_mode()
598 let _ = input.uncons_range(range.len()); in parse_mode()
599 let position = input.position(); in parse_mode()
600 ctry!(input.reset(checkpoint).committed()); in parse_mode()
602 let err = Input::Error::from_error(position, StreamError::end_of_input()); in parse_mode()
603 if !input.is_partial() && range.is_empty() { in parse_mode()
614 …ot find anything in the range it must return `None/NotFound` which indicates an end of input error.
617 /// returning `TakeRange::NotFound(n)` it indicates that the input can skip ahead until `n`
621 pub fn take_fn<F, R, Input>(searcher: F) -> TakeFn<F, Input> in take_fn()
623 F: FnMut(Input::Range) -> R, in take_fn()
625 Input: RangeStream, in take_fn()
626 Input::Range: crate::stream::Range, in take_fn()
643 /// let mut input = Vec::new();
644 /// input.extend_from_slice(&3u16.to_be_bytes());
645 /// input.extend_from_slice(b"1234");
648 /// let result = parser.parse(&input[..]);
652 pub fn length_prefix[Input, P](len: P)(Input) -> Input::Range
654 Input: RangeStream,
655 P: Parser<Input>,
663 .map_err(StreamErrorFor::<Input>::other)
678 /// let mut input = Vec::new();
679 /// input.extend_from_slice(&3u16.to_be_bytes());
680 /// input.extend_from_slice(b"1234");
683 /// let result = parser.parse(&input[..]);
687 pub fn length_prefix[Input, P](len: P)(Input) -> Input::Range
689 Input: RangeStream,
690 P: Parser<Input>,
698 .map_err(StreamErrorFor::<Input>::message_format)