• 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.
89 pub fn recognize[Input, P](parser: P)(Input) -> <Input as StreamOnce>::Range
91 P: Parser<Input>,
92 Input: RangeStream,
93 <Input as StreamOnce>::Range: crate::stream::Range,
101 fn parse_partial_range<M, F, G, S, Input>( in parse_partial_range()
103 input: &mut Input, in parse_partial_range() argument
108 ) -> ParseResult<Input::Range, Input::Error> in parse_partial_range()
111 F: FnOnce(&mut Input, S) -> ParseResult<Input::Range, <Input as StreamOnce>::Error>, in parse_partial_range() argument
112 G: FnOnce(&mut Input, S) -> ParseResult<Input::Range, <Input as StreamOnce>::Error>, in parse_partial_range() argument
113 Input: RangeStream, in parse_partial_range()
115 let before = input.checkpoint(); in parse_partial_range()
117 if !input.is_partial() { in parse_partial_range()
118 first(input, state) in parse_partial_range()
120 let result = first(input, state); in parse_partial_range()
122 *distance_state = input.distance(&before); in parse_partial_range()
123 ctry!(input.reset(before).committed()); in parse_partial_range()
127 if input.uncons_range(*distance_state).is_err() { in parse_partial_range()
128 panic!("recognize errored when restoring the input stream to its expected state"); in parse_partial_range()
131 match resume(input, state) { in parse_partial_range()
135 *distance_state = input.distance(&before); in parse_partial_range()
136 ctry!(input.reset(before).committed()); in parse_partial_range()
141 let distance = input.distance(&before); in parse_partial_range()
142 ctry!(input.reset(before).committed()); in parse_partial_range()
143 take(distance).parse_lazy(input).map(|range| { in parse_partial_range()
153 impl<Input, P> Parser<Input> for RecognizeWithValue<P>
155 P: Parser<Input>,
156 Input: RangeStream,
157 <Input as StreamOnce>::Range: crate::stream::Range,
159 type Output = (<Input as StreamOnce>::Range, P::Output);
162 parse_mode!(Input);
167 input: &mut Input, in parse_mode() argument
169 ) -> ParseResult<Self::Output, <Input as StreamOnce>::Error> in parse_mode()
175 let before = input.checkpoint(); in parse_mode()
176 if !mode.is_first() && input.uncons_range(*distance_state).is_err() { in parse_mode()
177 panic!("recognize errored when restoring the input stream to its expected state"); in parse_mode()
180 let value = match self.0.parse_mode(mode, input, child_state) { in parse_mode()
184 *distance_state = input.distance(&before); in parse_mode()
185 ctry!(input.reset(before).committed()); in parse_mode()
190 let distance = input.distance(&before); in parse_mode()
191 ctry!(input.reset(before).committed()); in parse_mode()
192 take(distance).parse_lazy(input).map(|range| { in parse_mode()
197 fn add_error(&mut self, errors: &mut Tracked<<Input as StreamOnce>::Error>) { in add_error()
202 /// Zero-copy parser which returns a pair: (committed input range, parsed value).
225 pub fn recognize_with_value<Input, P>(parser: P) -> RecognizeWithValue<P> in recognize_with_value() argument
227 P: Parser<Input>, in recognize_with_value()
228 Input: RangeStream, in recognize_with_value()
229 <Input as StreamOnce>::Range: crate::stream::Range, in recognize_with_value()
252 pub fn range<Input>(i: Input::Range) -> Range<Input> in range()
254 Input: RangeStream, in range()
255 Input::Range: PartialEq, in range()
260 pub struct Take<Input>(usize, PhantomData<fn(Input)>);
261 impl<Input> Parser<Input> for Take<Input>
263 Input: RangeStream,
265 type Output = Input::Range;
271 input: &mut Input, in parse_lazy() argument
272 ) -> ParseResult<Self::Output, <Input as StreamOnce>::Error> { in parse_lazy()
273 uncons_range(input, self.0) in parse_lazy()
297 pub fn take<Input>(n: usize) -> Take<Input> in take()
299 Input: RangeStream, in take()
304 pub struct TakeWhile<Input, F>(F, PhantomData<fn(Input) -> Input>);
305 impl<Input, F> Parser<Input> for TakeWhile<Input, F>
307 Input: RangeStream,
308 Input::Range: crate::stream::Range,
309 F: FnMut(Input::Token) -> bool,
311 type Output = Input::Range;
314 parse_mode!(Input);
319 input: &mut Input, in parse_mode_impl() argument
321 ) -> ParseResult<Self::Output, <Input as StreamOnce>::Error> in parse_mode_impl()
327 input, in parse_mode_impl()
330 |input, predicate| uncons_while(input, predicate), in parse_mode_impl()
331 |input, predicate| uncons_while(input, predicate), in parse_mode_impl()
353 pub fn take_while<Input, F>(f: F) -> TakeWhile<Input, F> in take_while() argument
355 Input: RangeStream, in take_while()
356 Input::Range: crate::stream::Range, in take_while()
357 F: FnMut(Input::Token) -> bool, in take_while()
362 pub struct TakeWhile1<Input, F>(F, PhantomData<fn(Input) -> Input>);
363 impl<Input, F> Parser<Input> for TakeWhile1<Input, F>
365 Input: RangeStream,
366 Input::Range: crate::stream::Range,
367 F: FnMut(Input::Token) -> bool,
369 type Output = Input::Range;
372 parse_mode!(Input);
377 input: &mut Input, in parse_mode_impl() argument
379 ) -> ParseResult<Self::Output, <Input as StreamOnce>::Error> in parse_mode_impl()
385 input, in parse_mode_impl()
388 |input, predicate| uncons_while1(input, predicate), in parse_mode_impl()
389 |input, predicate| uncons_while(input, predicate), in parse_mode_impl()
411 pub fn take_while1<Input, F>(f: F) -> TakeWhile1<Input, F> in take_while1() argument
413 Input: RangeStream, in take_while1()
414 Input::Range: crate::stream::Range, in take_while1()
415 F: FnMut(Input::Token) -> bool, in take_while1()
420 pub struct TakeUntilRange<Input>(Input::Range)
422 Input: RangeStream;
423 impl<Input> Parser<Input> for TakeUntilRange<Input>
425 Input: RangeStream,
426 Input::Range: PartialEq + crate::stream::Range,
428 type Output = Input::Range;
434 input: &mut Input, in parse_partial() argument
436 ) -> ParseResult<Self::Output, <Input as StreamOnce>::Error> { in parse_partial()
440 let before = input.checkpoint(); in parse_partial()
444 ctry!(uncons_range(input, *to_consume)); in parse_partial()
447 let look_ahead_input = input.checkpoint(); in parse_partial()
449 match input.uncons_range(len) { in parse_partial()
452 let distance = input.distance(&before) - len; in parse_partial()
453 ctry!(input.reset(before).committed()); in parse_partial()
455 if let Ok(committed) = input.uncons_range(distance) { in parse_partial()
469 ctry!(input.reset(look_ahead_input).committed()); in parse_partial()
472 if input.uncons().is_err() { in parse_partial()
482 … // with more input we must start parsing again at the first time we errored so we in parse_partial()
485 first_stream_error = Some((first_error, input.distance(&before))); in parse_partial()
489 ctry!(input.reset(look_ahead_input).committed()); in parse_partial()
492 if input.uncons().is_err() { in parse_partial()
496 ctry!(input.reset(before).committed()); in parse_partial()
500 return wrap_stream_error(input, first_error); in parse_partial()
528 pub fn take_until_range<Input>(r: Input::Range) -> TakeUntilRange<Input> in take_until_range()
530 Input: RangeStream, in take_until_range()
552 pub struct TakeFn<F, Input> {
554 _marker: PhantomData<fn(Input)>,
557 impl<Input, F, R> Parser<Input> for TakeFn<F, Input>
559 F: FnMut(Input::Range) -> R,
561 Input: RangeStream,
562 Input::Range: crate::stream::Range,
564 type Output = Input::Range;
567 parse_mode!(Input);
572 input: &mut Input, in parse_mode() argument
574 ) -> ParseResult<Self::Output, <Input as StreamOnce>::Error> in parse_mode()
578 let checkpoint = input.checkpoint(); in parse_mode()
583 let _ = input.uncons_range(*offset); in parse_mode()
586 match (self.searcher)(input.range()).into() { in parse_mode()
588 ctry!(input.reset(checkpoint).committed()); in parse_mode()
589 let result = uncons_range(input, *offset + i); in parse_mode()
598 let range = input.range(); in parse_mode()
599 let _ = input.uncons_range(range.len()); in parse_mode()
600 let position = input.position(); in parse_mode()
601 ctry!(input.reset(checkpoint).committed()); in parse_mode()
603 let err = Input::Error::from_error(position, StreamError::end_of_input()); in parse_mode()
604 if !input.is_partial() && range.is_empty() { in parse_mode()
615 …ot find anything in the range it must return `None/NotFound` which indicates an end of input error.
618 /// returning `TakeRange::NotFound(n)` it indicates that the input can skip ahead until `n`
622 pub fn take_fn<F, R, Input>(searcher: F) -> TakeFn<F, Input> in take_fn()
624 F: FnMut(Input::Range) -> R, in take_fn()
626 Input: RangeStream, in take_fn()
627 Input::Range: crate::stream::Range, in take_fn()
644 /// let mut input = Vec::new();
645 /// input.extend_from_slice(&3u16.to_be_bytes());
646 /// input.extend_from_slice(b"1234");
649 /// let result = parser.parse(&input[..]);
653 pub fn length_prefix[Input, P](len: P)(Input) -> Input::Range
655 Input: RangeStream,
656 P: Parser<Input>,
664 .map_err(StreamErrorFor::<Input>::other)
679 /// let mut input = Vec::new();
680 /// input.extend_from_slice(&3u16.to_be_bytes());
681 /// input.extend_from_slice(b"1234");
684 /// let result = parser.parse(&input[..]);
688 pub fn length_prefix[Input, P](len: P)(Input) -> Input::Range
690 Input: RangeStream,
691 P: Parser<Input>,
699 .map_err(StreamErrorFor::<Input>::message_format)