Skip to main content

ParserExt

Trait ParserExt 

Source
pub trait ParserExt<I: Positioned + ?Sized>: Parser<I> {
Show 34 methods // Provided methods fn parse<'a, 'b>( &'a mut self, input: &'b mut I, ) -> ParseFuture<'a, 'b, Self, I, Self::State> where I: Unpin { ... } fn boxed<'a>( self, ) -> Box<dyn Parser<I, Output = Self::Output, State = Self::State> + 'a> where Self: Sized + 'a { ... } fn no_state(self) -> NoState<Self, Self::State> where Self: Sized { ... } fn left<R>(self) -> Either<Self, R> where Self: Sized, R: Parser<I, Output = Self::Output> { ... } fn right<L>(self) -> Either<L, Self> where Self: Sized, L: Parser<I, Output = Self::Output> { ... } fn complete(self) -> Skip<Self, Eof<I>> where Self: Sized { ... } fn with_position(self) -> WithPosition<Self> where Self: Sized { ... } fn peek(self) -> Peek<Self> where Self: Sized, I: Input { ... } fn fail(self) -> Fail<Self> where Self: Sized, I: Input { ... } fn and<P>(self, p: P) -> (Self, P) where Self: Sized, P: Parser<I> { ... } fn skip<P>(self, p: P) -> Skip<Self, P> where Self: Sized, P: Parser<I> { ... } fn prefix<P>(self, p: P) -> Prefix<Self, P> where Self: Sized { ... } fn between<L, R>(self, left: L, right: R) -> Skip<Prefix<L, Self>, R> where Self: Sized, L: Parser<I>, R: Parser<I> { ... } fn or<P>(self, other: P) -> Or<Self, P> where Self: Sized, I: Input, P: Parser<I, Output = Self::Output> { ... } fn opt(self) -> Opt<Self> where Self: Sized, I: Input { ... } fn once(self) -> Times<Self> where Self: Sized, I: Positioned { ... } fn times(self, n: usize) -> Times<Self> where Self: Sized, I: Positioned { ... } fn sep_by_times<P, R>(self, sep: P, count: usize) -> SepByTimes<Self, P> where Self: Sized, P: Parser<I> { ... } fn sep_by_end_times<P, R>( self, sep: P, count: usize, ) -> SepByEndTimes<Self, P> where Self: Sized, I: Input, P: Parser<I> { ... } fn repeat<R>(self, range: R) -> Repeat<Self, R> where Self: Sized, R: RangeBounds<usize>, I: Input { ... } fn sep_by<P, R>(self, sep: P, range: R) -> SepBy<Self, P, R> where Self: Sized, P: Parser<I>, R: RangeBounds<usize>, I: Input { ... } fn sep_by_end<P, R>(self, sep: P, range: R) -> SepByEnd<Self, P, R> where Self: Sized, P: Parser<I>, R: RangeBounds<usize>, I: Input { ... } fn then<F, Q>(self, f: F) -> Then<Self, F> where Self: Sized, F: FnMut(Self::Output) -> Q { ... } fn try_then<F, Q, E>(self, f: F) -> TryThen<Self, F> where Self: Sized, F: FnMut(Self::Output) -> Result<Q, E>, E: Into<Expects> { ... } fn until<P>(self, end: P) -> Until<Self, P> where Self: Sized, P: Parser<I>, I: Input { ... } fn discard(self) -> Discard<Self> where Self: Sized { ... } fn map<F, O>(self, f: F) -> Map<Self, F> where Self: Sized, F: FnMut(Self::Output) -> O { ... } fn try_map<F, O, E>(self, f: F) -> TryMap<Self, F> where Self: Sized, F: FnMut(Self::Output) -> Result<O, E>, E: Into<Expects> { ... } fn satisfy<F, O>(self, f: F) -> Satisfy<Self, F> where Self: Sized, F: FnMut(&Self::Output) -> bool { ... } fn map_err<F, E>(self, f: F) -> MapErr<Self, F> where Self: Sized, F: FnMut(Expects) -> Expects, E: Into<Expects> { ... } fn expect<E: Into<Expects>>(self, expected: E) -> Expect<Self> where Self: Sized, I::Ok: Clone { ... } fn spanned(self) -> Spanned<Self> where Self: Sized { ... } fn exclusive<E: Into<Expects>>(self, expected: E) -> Exclusive<Self> where Self: Sized, I::Ok: Clone { ... } fn rewindable(self) -> Rewindable<Self> where Self: Sized { ... }
}
Expand description

An extension trait for Parser.

Provided Methods§

Source

fn parse<'a, 'b>( &'a mut self, input: &'b mut I, ) -> ParseFuture<'a, 'b, Self, I, Self::State>
where I: Unpin,

An asynchronous version of poll_parse, which returns a Future.

Source

fn boxed<'a>( self, ) -> Box<dyn Parser<I, Output = Self::Output, State = Self::State> + 'a>
where Self: Sized + 'a,

Available on crate feature alloc only.

Wraps the parser into a Box.

Source

fn no_state(self) -> NoState<Self, Self::State>
where Self: Sized,

Merges State into parser itself.

Source

fn left<R>(self) -> Either<Self, R>
where Self: Sized, R: Parser<I, Output = Self::Output>,

Wraps the parser into a Either to merge multiple types of parsers.

Source

fn right<L>(self) -> Either<L, Self>
where Self: Sized, L: Parser<I, Output = Self::Output>,

Wraps the parser into a Either to merge multiple types of parsers.

Source

fn complete(self) -> Skip<Self, Eof<I>>
where Self: Sized,

Parses the input completedly.

This method is a conventional method, and equivalent to self.skip(eof()).

Source

fn with_position(self) -> WithPosition<Self>
where Self: Sized,

Returns the position of parsed tokens with an output.

Source

fn peek(self) -> Peek<Self>
where Self: Sized, I: Input,

Returns a parse result without consuming input.

Source

fn fail(self) -> Fail<Self>
where Self: Sized, I: Input,

Succeeds if the parser failed parsing. Never consumes input.

Source

fn and<P>(self, p: P) -> (Self, P)
where Self: Sized, P: Parser<I>,

Parses with self, and then with p.

Source

fn skip<P>(self, p: P) -> Skip<Self, P>
where Self: Sized, P: Parser<I>,

Parses with self, then skips p.

Source

fn prefix<P>(self, p: P) -> Prefix<Self, P>
where Self: Sized,

Parses with p prefixed by self.

Source

fn between<L, R>(self, left: L, right: R) -> Skip<Prefix<L, Self>, R>
where Self: Sized, L: Parser<I>, R: Parser<I>,

Parses with self between left and right.

Source

fn or<P>(self, other: P) -> Or<Self, P>
where Self: Sized, I: Input, P: Parser<I, Output = Self::Output>,

Tries another parser if the parser failed parsing.

Source

fn opt(self) -> Opt<Self>
where Self: Sized, I: Input,

Returns Some if parsing is succeeded.

Source

fn once(self) -> Times<Self>
where Self: Sized, I: Positioned,

Returns a IterableParser by wrapping the parser to return output exactly once.

This method is equivalent to self.times(1).

Source

fn times(self, n: usize) -> Times<Self>
where Self: Sized, I: Positioned,

Returns a IterableParser by repeating the parser exactly n times.

Source

fn sep_by_times<P, R>(self, sep: P, count: usize) -> SepByTimes<Self, P>
where Self: Sized, P: Parser<I>,

Returns a fixed-size IterableParser of the parser separated by sep.

Source

fn sep_by_end_times<P, R>(self, sep: P, count: usize) -> SepByEndTimes<Self, P>
where Self: Sized, I: Input, P: Parser<I>,

Returns a fixed-size IterableParser of the parser separated by sep (trailing separater is allowed).

Source

fn repeat<R>(self, range: R) -> Repeat<Self, R>
where Self: Sized, R: RangeBounds<usize>, I: Input,

Returns a IterableParser by repeating the parser while succeeding.

Source

fn sep_by<P, R>(self, sep: P, range: R) -> SepBy<Self, P, R>
where Self: Sized, P: Parser<I>, R: RangeBounds<usize>, I: Input,

Returns a IterableParser of the parser separated by sep.

Source

fn sep_by_end<P, R>(self, sep: P, range: R) -> SepByEnd<Self, P, R>
where Self: Sized, P: Parser<I>, R: RangeBounds<usize>, I: Input,

Returns a IterableParser of the parser separated by sep (trailing separater is allowed).

Source

fn then<F, Q>(self, f: F) -> Then<Self, F>
where Self: Sized, F: FnMut(Self::Output) -> Q,

Parses with self, passes output to the function f and parses with a returned Parser or IterableParser.

Source

fn try_then<F, Q, E>(self, f: F) -> TryThen<Self, F>
where Self: Sized, F: FnMut(Self::Output) -> Result<Q, E>, E: Into<Expects>,

Parses with self, passes output to the failable function f and parses with a returned Parser or IterableParser.

Source

fn until<P>(self, end: P) -> Until<Self, P>
where Self: Sized, P: Parser<I>, I: Input,

Returns a IterableParser by repeating the parser until the parser end succeeds.

Source

fn discard(self) -> Discard<Self>
where Self: Sized,

Discards the parse results.

Source

fn map<F, O>(self, f: F) -> Map<Self, F>
where Self: Sized, F: FnMut(Self::Output) -> O,

Converts an output value into another type.

Source

fn try_map<F, O, E>(self, f: F) -> TryMap<Self, F>
where Self: Sized, F: FnMut(Self::Output) -> Result<O, E>, E: Into<Expects>,

Converts an output value into another type with a failable function.

Source

fn satisfy<F, O>(self, f: F) -> Satisfy<Self, F>
where Self: Sized, F: FnMut(&Self::Output) -> bool,

Checks an output value with the function.

Source

fn map_err<F, E>(self, f: F) -> MapErr<Self, F>
where Self: Sized, F: FnMut(Expects) -> Expects, E: Into<Expects>,

Modifies expected values.

Source

fn expect<E: Into<Expects>>(self, expected: E) -> Expect<Self>
where Self: Sized, I::Ok: Clone,

Overrides expected values.

Source

fn spanned(self) -> Spanned<Self>
where Self: Sized,

Overrides the error position by the span of the parse.

Source

fn exclusive<E: Into<Expects>>(self, expected: E) -> Exclusive<Self>
where Self: Sized, I::Ok: Clone,

Overrides parsing errors as “exclusive”.

Source

fn rewindable(self) -> Rewindable<Self>
where Self: Sized,

Modifies “exclusive” errors as rewindable.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§

Source§

impl<P: Parser<I>, I: Positioned + ?Sized> ParserExt<I> for P