Struct chumsky::BoxedParser
source · [−]#[repr(transparent)]pub struct BoxedParser<'a, I, O, E: Error<I>>(_);
Expand description
See Parser::boxed
.
This type is a repr(transparent)
wrapper
around its inner value.
Due to current implementation details, the inner value is not, in fact, a Box
, but is an Rc
to facilitate
efficient cloning. This is likely to change in the future. Unlike Box
, Rc
has no size guarantees: although
it is currently the same size as a raw pointer.
Trait Implementations
sourceimpl<'a, I, O, E: Error<I>> Clone for BoxedParser<'a, I, O, E>
impl<'a, I, O, E: Error<I>> Clone for BoxedParser<'a, I, O, E>
sourceimpl<'a, I: Clone, O, E: Error<I>> Parser<I, O> for BoxedParser<'a, I, O, E>
impl<'a, I: Clone, O, E: Error<I>> Parser<I, O> for BoxedParser<'a, I, O, E>
type Error = E
type Error = E
The type of errors emitted by this parser.
sourcefn parse_recovery<'a, Iter, S>(
&self,
stream: S
) -> (Option<O>, Vec<Self::Error>) where
Self: Sized,
Iter: Iterator<Item = (I, <Self::Error as Error<I>>::Span)> + 'a,
S: Into<Stream<'a, I, <Self::Error as Error<I>>::Span, Iter>>,
fn parse_recovery<'a, Iter, S>(
&self,
stream: S
) -> (Option<O>, Vec<Self::Error>) where
Self: Sized,
Iter: Iterator<Item = (I, <Self::Error as Error<I>>::Span)> + 'a,
S: Into<Stream<'a, I, <Self::Error as Error<I>>::Span, Iter>>,
Parse a stream of tokens, yielding an output if possible, and any errors encountered along the way. Read more
sourcefn parse_recovery_verbose<'a, Iter, S>(
&self,
stream: S
) -> (Option<O>, Vec<Self::Error>) where
Self: Sized,
Iter: Iterator<Item = (I, <Self::Error as Error<I>>::Span)> + 'a,
S: Into<Stream<'a, I, <Self::Error as Error<I>>::Span, Iter>>,
fn parse_recovery_verbose<'a, Iter, S>(
&self,
stream: S
) -> (Option<O>, Vec<Self::Error>) where
Self: Sized,
Iter: Iterator<Item = (I, <Self::Error as Error<I>>::Span)> + 'a,
S: Into<Stream<'a, I, <Self::Error as Error<I>>::Span, Iter>>,
Parse a stream of tokens, yielding an output if possible, and any errors encountered along the way. Unlike
Parser::parse_recovery
, this function will produce verbose debugging output as it executes. Read more
sourcefn parse<'a, Iter, S>(&self, stream: S) -> Result<O, Vec<Self::Error>> where
Self: Sized,
Iter: Iterator<Item = (I, <Self::Error as Error<I>>::Span)> + 'a,
S: Into<Stream<'a, I, <Self::Error as Error<I>>::Span, Iter>>,
fn parse<'a, Iter, S>(&self, stream: S) -> Result<O, Vec<Self::Error>> where
Self: Sized,
Iter: Iterator<Item = (I, <Self::Error as Error<I>>::Span)> + 'a,
S: Into<Stream<'a, I, <Self::Error as Error<I>>::Span, Iter>>,
Parse a stream of tokens, yielding an output or any errors that were encountered along the way. Read more
sourcefn debug<T>(self, x: T) -> Debug<Self> where
Self: Sized,
T: Display + 'static,
fn debug<T>(self, x: T) -> Debug<Self> where
Self: Sized,
T: Display + 'static,
Include this parser in the debugging output produced by Parser::parse_recovery_verbose
. Read more
sourcefn map<U, F>(self, f: F) -> Map<Self, F, O> where
Self: Sized,
F: Fn(O) -> U,
fn map<U, F>(self, f: F) -> Map<Self, F, O> where
Self: Sized,
F: Fn(O) -> U,
Map the output of this parser to another value. Read more
sourcefn map_with_span<U, F>(self, f: F) -> MapWithSpan<Self, F, O> where
Self: Sized,
F: Fn(O, <Self::Error as Error<I>>::Span) -> U,
fn map_with_span<U, F>(self, f: F) -> MapWithSpan<Self, F, O> where
Self: Sized,
F: Fn(O, <Self::Error as Error<I>>::Span) -> U,
Map the output of this parser to another value, making use of the pattern’s span when doing so. Read more
sourcefn map_err<F>(self, f: F) -> MapErr<Self, F> where
Self: Sized,
F: Fn(Self::Error) -> Self::Error,
fn map_err<F>(self, f: F) -> MapErr<Self, F> where
Self: Sized,
F: Fn(Self::Error) -> Self::Error,
Map the primary error of this parser to another value. Read more
sourcefn or_else<F>(self, f: F) -> OrElse<Self, F> where
Self: Sized,
F: Fn(Self::Error) -> Result<O, Self::Error>,
fn or_else<F>(self, f: F) -> OrElse<Self, F> where
Self: Sized,
F: Fn(Self::Error) -> Result<O, Self::Error>,
sourcefn map_err_with_span<F>(self, f: F) -> MapErrWithSpan<Self, F> where
Self: Sized,
F: Fn(Self::Error, <Self::Error as Error<I>>::Span) -> Self::Error,
fn map_err_with_span<F>(self, f: F) -> MapErrWithSpan<Self, F> where
Self: Sized,
F: Fn(Self::Error, <Self::Error as Error<I>>::Span) -> Self::Error,
Map the primary error of this parser to another value, making use of the span from the start of the attempted to the point at which the error was encountered. Read more
sourcefn try_map<U, F>(self, f: F) -> TryMap<Self, F, O> where
Self: Sized,
F: Fn(O, <Self::Error as Error<I>>::Span) -> Result<U, Self::Error>,
fn try_map<U, F>(self, f: F) -> TryMap<Self, F, O> where
Self: Sized,
F: Fn(O, <Self::Error as Error<I>>::Span) -> Result<U, Self::Error>,
After a successful parse, apply a fallible function to the output. If the function produces an error, treat it as a parsing error. Read more
sourcefn validate<F, U>(self, f: F) -> Validate<Self, O, F> where
Self: Sized,
F: Fn(O, <Self::Error as Error<I>>::Span, &mut dyn FnMut(Self::Error)) -> U,
fn validate<F, U>(self, f: F) -> Validate<Self, O, F> where
Self: Sized,
F: Fn(O, <Self::Error as Error<I>>::Span, &mut dyn FnMut(Self::Error)) -> U,
Validate an output, producing non-terminal errors if it does not fulfil certain criteria. Read more
sourcefn labelled<L>(self, label: L) -> Label<Self, L> where
Self: Sized,
L: Into<<Self::Error as Error<I>>::Label> + Clone,
fn labelled<L>(self, label: L) -> Label<Self, L> where
Self: Sized,
L: Into<<Self::Error as Error<I>>::Label> + Clone,
Label the pattern parsed by this parser for more useful error messages. Read more
sourcefn to<U>(self, x: U) -> To<Self, O, U> where
Self: Sized,
U: Clone,
fn to<U>(self, x: U) -> To<Self, O, U> where
Self: Sized,
U: Clone,
Transform all outputs of this parser to a pretermined value. Read more
sourcefn foldl<A, B, F>(self, f: F) -> Foldl<Self, F, A, B> where
Self: Parser<I, (A, B)> + Sized,
B: IntoIterator,
F: Fn(A, B::Item) -> A,
fn foldl<A, B, F>(self, f: F) -> Foldl<Self, F, A, B> where
Self: Parser<I, (A, B)> + Sized,
B: IntoIterator,
F: Fn(A, B::Item) -> A,
Left-fold the output of the parser into a single value. Read more
sourcefn foldr<'a, A, B, F>(self, f: F) -> Foldr<Self, F, A, B> where
Self: Parser<I, (A, B)> + Sized,
A: IntoIterator,
A::IntoIter: DoubleEndedIterator,
F: Fn(A::Item, B) -> B + 'a,
fn foldr<'a, A, B, F>(self, f: F) -> Foldr<Self, F, A, B> where
Self: Parser<I, (A, B)> + Sized,
A: IntoIterator,
A::IntoIter: DoubleEndedIterator,
F: Fn(A::Item, B) -> B + 'a,
Right-fold the output of the parser into a single value. Read more
sourcefn ignored(self) -> Ignored<Self, O> where
Self: Sized,
fn ignored(self) -> Ignored<Self, O> where
Self: Sized,
Ignore the output of this parser, yielding ()
as an output instead. Read more
sourcefn collect<C>(self) -> Map<Self, fn(_: O) -> C, O> where
Self: Sized,
O: IntoIterator,
C: FromIterator<O::Item>,
fn collect<C>(self) -> Map<Self, fn(_: O) -> C, O> where
Self: Sized,
O: IntoIterator,
C: FromIterator<O::Item>,
Collect the output of this parser into a type implementing FromIterator
. Read more
sourcefn then<U, P>(self, other: P) -> Then<Self, P> where
Self: Sized,
P: Parser<I, U, Error = Self::Error>,
fn then<U, P>(self, other: P) -> Then<Self, P> where
Self: Sized,
P: Parser<I, U, Error = Self::Error>,
Parse one thing and then another thing, yielding a tuple of the two outputs. Read more
sourcefn then_with<U, P, F: Fn(O) -> P>(
self,
other: F
) -> ThenWith<I, O, U, Self, P, F> where
Self: Sized,
P: Parser<I, U, Error = Self::Error>,
fn then_with<U, P, F: Fn(O) -> P>(
self,
other: F
) -> ThenWith<I, O, U, Self, P, F> where
Self: Sized,
P: Parser<I, U, Error = Self::Error>,
Parse one thing and then another thing, creating the second parser from the result of
the first. If you only have a couple cases to handle, prefer Parser::or
. Read more
sourcefn chain<T, U, P>(
self,
other: P
) -> Map<Then<Self, P>, fn(_: (O, U)) -> Vec<T>, (O, U)> where
Self: Sized,
U: Chain<T>,
O: Chain<T>,
P: Parser<I, U, Error = Self::Error>,
fn chain<T, U, P>(
self,
other: P
) -> Map<Then<Self, P>, fn(_: (O, U)) -> Vec<T>, (O, U)> where
Self: Sized,
U: Chain<T>,
O: Chain<T>,
P: Parser<I, U, Error = Self::Error>,
sourcefn flatten<T, Inner>(self) -> Map<Self, fn(_: O) -> Vec<T>, O> where
Self: Sized,
O: IntoIterator<Item = Inner>,
Inner: IntoIterator<Item = T>,
fn flatten<T, Inner>(self) -> Map<Self, fn(_: O) -> Vec<T>, O> where
Self: Sized,
O: IntoIterator<Item = Inner>,
Inner: IntoIterator<Item = T>,
Flatten a nested collection. Read more
sourcefn ignore_then<U, P>(self, other: P) -> IgnoreThen<Self, P, O, U> where
Self: Sized,
P: Parser<I, U, Error = Self::Error>,
fn ignore_then<U, P>(self, other: P) -> IgnoreThen<Self, P, O, U> where
Self: Sized,
P: Parser<I, U, Error = Self::Error>,
Parse one thing and then another thing, yielding only the output of the latter. Read more
sourcefn then_ignore<U, P>(self, other: P) -> ThenIgnore<Self, P, O, U> where
Self: Sized,
P: Parser<I, U, Error = Self::Error>,
fn then_ignore<U, P>(self, other: P) -> ThenIgnore<Self, P, O, U> where
Self: Sized,
P: Parser<I, U, Error = Self::Error>,
Parse one thing and then another thing, yielding only the output of the former. Read more
sourcefn padded_by<U, P>(
self,
other: P
) -> ThenIgnore<IgnoreThen<P, Self, U, O>, P, O, U> where
Self: Sized,
P: Parser<I, U, Error = Self::Error> + Clone,
fn padded_by<U, P>(
self,
other: P
) -> ThenIgnore<IgnoreThen<P, Self, U, O>, P, O, U> where
Self: Sized,
P: Parser<I, U, Error = Self::Error> + Clone,
Parse a pattern, but with an instance of another pattern on either end, yielding the output of the inner. Read more
sourcefn delimited_by<U, V, L, R>(
self,
start: L,
end: R
) -> DelimitedBy<Self, L, R, U, V> where
Self: Sized,
L: Parser<I, U, Error = Self::Error>,
R: Parser<I, V, Error = Self::Error>,
fn delimited_by<U, V, L, R>(
self,
start: L,
end: R
) -> DelimitedBy<Self, L, R, U, V> where
Self: Sized,
L: Parser<I, U, Error = Self::Error>,
R: Parser<I, V, Error = Self::Error>,
Parse the pattern surrounded by the given delimiters. Read more
sourcefn or<P>(self, other: P) -> Or<Self, P> where
Self: Sized,
P: Parser<I, O, Error = Self::Error>,
fn or<P>(self, other: P) -> Or<Self, P> where
Self: Sized,
P: Parser<I, O, Error = Self::Error>,
Parse one thing or, on failure, another thing. Read more
sourcefn recover_with<S>(self, strategy: S) -> Recovery<Self, S> where
Self: Sized,
S: Strategy<I, O, Self::Error>,
fn recover_with<S>(self, strategy: S) -> Recovery<Self, S> where
Self: Sized,
S: Strategy<I, O, Self::Error>,
Apply a fallback recovery strategy to this parser should it fail. Read more
sourcefn or_not(self) -> OrNot<Self> where
Self: Sized,
fn or_not(self) -> OrNot<Self> where
Self: Sized,
Attempt to parse something, but only if it exists. Read more
sourcefn repeated(self) -> Repeated<Self> where
Self: Sized,
fn repeated(self) -> Repeated<Self> where
Self: Sized,
Parse a pattern any number of times (including zero times). Read more
sourcefn separated_by<U, P>(self, other: P) -> SeparatedBy<Self, P, U> where
Self: Sized,
P: Parser<I, U, Error = Self::Error>,
fn separated_by<U, P>(self, other: P) -> SeparatedBy<Self, P, U> where
Self: Sized,
P: Parser<I, U, Error = Self::Error>,
Parse a pattern, separated by another, any number of times. Read more
sourcefn rewind(self) -> Rewind<Self> where
Self: Sized,
fn rewind(self) -> Rewind<Self> where
Self: Sized,
Parse a pattern. Afterwards, the input stream will be rewound to its original state, as if parsing had not occurred. Read more
sourcefn boxed<'a>(self) -> BoxedParser<'a, I, O, Self::Error> where
Self: Sized + 'a,
fn boxed<'a>(self) -> BoxedParser<'a, I, O, Self::Error> where
Self: Sized + 'a,
Box the parser, yielding a parser that performs parsing through dynamic dispatch. Read more
Auto Trait Implementations
impl<'a, I, O, E> !RefUnwindSafe for BoxedParser<'a, I, O, E>
impl<'a, I, O, E> !Send for BoxedParser<'a, I, O, E>
impl<'a, I, O, E> !Sync for BoxedParser<'a, I, O, E>
impl<'a, I, O, E> Unpin for BoxedParser<'a, I, O, E>
impl<'a, I, O, E> !UnwindSafe for BoxedParser<'a, I, O, E>
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more