Lines Matching full:input
15 pub struct Any<Input>(PhantomData<fn(Input) -> Input>);
17 impl<Input> Parser<Input> for Any<Input>
19 Input: Stream,
21 type Output = Input::Token;
25 fn parse_lazy(&mut self, input: &mut Input) -> ParseResult<Input::Token, Input::Error> { in parse_lazy()
26 uncons(input) in parse_lazy()
44 pub fn any<Input>() -> Any<Input> in any()
46 Input: Stream, in any()
52 pub struct Satisfy<Input, P> {
54 _marker: PhantomData<Input>,
57 fn satisfy_impl<Input, P, R>(input: &mut Input, mut predicate: P) -> ParseResult<R, Input::Error> in satisfy_impl() argument
59 Input: Stream, in satisfy_impl()
60 P: FnMut(Input::Token) -> Option<R>, in satisfy_impl()
62 let position = input.position(); in satisfy_impl()
63 match uncons(input) { in satisfy_impl()
66 None => PeekErr(Input::Error::empty(position).into()), in satisfy_impl()
73 impl<Input, P> Parser<Input> for Satisfy<Input, P>
75 Input: Stream,
76 P: FnMut(Input::Token) -> bool,
78 type Output = Input::Token;
82 fn parse_lazy(&mut self, input: &mut Input) -> ParseResult<Self::Output, Input::Error> { in parse_lazy()
83 satisfy_impl(input, |c| { in parse_lazy()
104 pub fn satisfy<Input, P>(predicate: P) -> Satisfy<Input, P> in satisfy() argument
106 Input: Stream, in satisfy()
107 P: FnMut(Input::Token) -> bool, in satisfy()
116 pub struct SatisfyMap<Input, P> {
118 _marker: PhantomData<Input>,
121 impl<Input, P, R> Parser<Input> for SatisfyMap<Input, P>
123 Input: Stream,
124 P: FnMut(Input::Token) -> Option<R>,
129 fn parse_lazy(&mut self, input: &mut Input) -> ParseResult<Self::Output, Input::Error> { in parse_lazy()
130 satisfy_impl(input, &mut self.predicate) in parse_lazy()
136 /// without consuming any input.
158 pub fn satisfy_map<Input, P, R>(predicate: P) -> SatisfyMap<Input, P> in satisfy_map() argument
160 Input: Stream, in satisfy_map()
161 P: FnMut(Input::Token) -> Option<R>, in satisfy_map()
170 pub struct Token<Input>
172 Input: Stream,
173 Input::Token: PartialEq,
175 c: Input::Token,
176 _marker: PhantomData<Input>,
179 impl<Input> Parser<Input> for Token<Input>
181 Input: Stream,
182 Input::Token: PartialEq + Clone,
184 type Output = Input::Token;
188 fn parse_lazy(&mut self, input: &mut Input) -> ParseResult<Input::Token, Input::Error> { in parse_lazy()
189 satisfy_impl(input, |c| if c == self.c { Some(c) } else { None }) in parse_lazy()
191 fn add_error(&mut self, errors: &mut Tracked<<Input as StreamOnce>::Error>) { in add_error()
208 pub fn token<Input>(c: Input::Token) -> Token<Input> in token()
210 Input: Stream, in token()
211 Input::Token: PartialEq, in token()
220 pub struct Tokens<C, E, T, Input>
222 Input: Stream,
227 _marker: PhantomData<Input>,
230 impl<Input, C, E, T> Parser<Input> for Tokens<C, E, T, Input>
232 C: FnMut(T::Item, Input::Token) -> bool,
233 E: for<'s> ErrorInfo<'s, Input::Token, Input::Range>,
235 Input: Stream,
240 fn parse_lazy(&mut self, input: &mut Input) -> ParseResult<T, Input::Error> { in parse_lazy()
241 let start = input.position(); in parse_lazy()
244 match crate::stream::uncons(input) { in parse_lazy()
248 let mut errors = <Input as StreamOnce>::Error::from_error( in parse_lazy()
255 PeekErr(<Input as StreamOnce>::Error::empty(start).into()) in parse_lazy()
280 fn add_error(&mut self, errors: &mut Tracked<<Input as StreamOnce>::Error>) { in add_error()
287 /// Consumes items from the input and compares them to the values from `tokens` using the
288 /// comparison function `cmp`. Succeeds if all the items from `tokens` are matched in the input
310 pub fn tokens<C, E, T, Input>(cmp: C, expected: E, tokens: T) -> Tokens<C, E, T, Input> in tokens()
312 C: FnMut(T::Item, Input::Token) -> bool, in tokens()
314 Input: Stream, in tokens()
325 pub struct TokensCmp<C, T, Input>
327 Input: Stream,
331 _marker: PhantomData<Input>,
334 impl<Input, C, T> Parser<Input> for TokensCmp<C, T, Input>
336 C: FnMut(T::Item, Input::Token) -> bool,
338 Input: Stream,
344 fn parse_lazy(&mut self, input: &mut Input) -> ParseResult<T, Input::Error> { in parse_lazy()
345 let start = input.position(); in parse_lazy()
348 match crate::stream::uncons(input) { in parse_lazy()
352 let errors = <Input as StreamOnce>::Error::from_error( in parse_lazy()
358 PeekErr(<Input as StreamOnce>::Error::empty(start).into()) in parse_lazy()
387 /// Consumes items from the input and compares them to the values from `tokens` using the
388 /// comparison function `cmp`. Succeeds if all the items from `tokens` are matched in the input
424 pub struct Position<Input>
426 Input: Stream,
428 _marker: PhantomData<Input>,
431 impl<Input> Parser<Input> for Position<Input>
433 Input: Stream,
435 type Output = Input::Position;
439 fn parse_lazy(&mut self, input: &mut Input) -> ParseResult<Input::Position, Input::Error> { in parse_lazy()
440 PeekOk(input.position()) in parse_lazy()
459 pub fn position<Input>() -> Position<Input> in position()
461 Input: Stream, in position()
469 pub struct OneOf<T, Input>
471 Input: Stream,
474 _marker: PhantomData<Input>,
477 impl<Input, T> Parser<Input> for OneOf<T, Input>
479 T: Clone + IntoIterator<Item = Input::Token>,
480 Input: Stream,
481 Input::Token: PartialEq,
483 type Output = Input::Token;
487 fn parse_lazy(&mut self, input: &mut Input) -> ParseResult<Input::Token, Input::Error> { in parse_lazy()
488 satisfy(|c| self.tokens.clone().into_iter().any(|t| t == c)).parse_lazy(input) in parse_lazy()
491 fn add_error(&mut self, errors: &mut Tracked<<Input as StreamOnce>::Error>) { in add_error()
509 pub fn one_of<T, Input>(tokens: T) -> OneOf<T, Input> in one_of()
512 Input: Stream, in one_of()
513 Input::Token: PartialEq<T::Item>, in one_of()
522 pub struct NoneOf<T, Input>
524 Input: Stream,
527 _marker: PhantomData<Input>,
530 impl<Input, T> Parser<Input> for NoneOf<T, Input>
532 T: Clone + IntoIterator<Item = Input::Token>,
533 Input: Stream,
534 Input::Token: PartialEq,
536 type Output = Input::Token;
540 fn parse_lazy(&mut self, input: &mut Input) -> ParseResult<Input::Token, Input::Error> { in parse_lazy()
541 satisfy(|c| self.tokens.clone().into_iter().all(|t| t != c)).parse_lazy(input) in parse_lazy()
555 /// .map(|(output, input)| (output, input.input));
567 pub fn none_of<T, Input>(tokens: T) -> NoneOf<T, Input> in none_of()
570 Input: Stream, in none_of()
571 Input::Token: PartialEq<T::Item>, in none_of()
580 pub struct Value<Input, T>(T, PhantomData<fn(Input) -> Input>);
581 impl<Input, T> Parser<Input> for Value<Input, T>
583 Input: Stream,
589 fn parse_lazy(&mut self, _: &mut Input) -> ParseResult<T, Input::Error> { in parse_lazy()
594 /// Always returns the value `v` without consuming any input.
606 pub fn value<Input, T>(v: T) -> Value<Input, T> in value() argument
608 Input: Stream, in value()
615 pub struct Produce<Input, F>(F, PhantomData<fn(Input) -> Input>);
616 impl<Input, F, R> Parser<Input> for Produce<Input, F>
618 Input: Stream,
624 fn parse_lazy(&mut self, _: &mut Input) -> ParseResult<R, Input::Error> { in parse_lazy()
642 pub fn produce<Input, F, R>(f: F) -> Produce<Input, F> in produce() argument
644 Input: Stream, in produce()
651 pub struct Eof<Input>(PhantomData<Input>);
652 impl<Input> Parser<Input> for Eof<Input>
654 Input: Stream,
660 fn parse_lazy(&mut self, input: &mut Input) -> ParseResult<(), Input::Error> { in parse_lazy()
661 let before = input.checkpoint(); in parse_lazy()
662 match input.uncons() { in parse_lazy()
665 ctry!(input.reset(before).committed()); in parse_lazy()
666 PeekErr(<Input as StreamOnce>::Error::empty(input.position()).into()) in parse_lazy()
671 fn add_error(&mut self, errors: &mut Tracked<<Input as StreamOnce>::Error>) { in add_error()
672 errors.error.add_expected("end of input"); in add_error()
676 /// Succeeds only if the stream is at end of input, fails otherwise.
690 /// easy::Error::Expected("end of input".into())
695 pub fn eof<Input>() -> Eof<Input> in eof()
697 Input: Stream, in eof()