pub struct PFoldLeft<P, TP, F, I, O2> { /* private fields */ }Expand description
A parser combinator that applies left-associative folding.
PFoldLeft takes three parsers:
head: a parser that produces the initial value (O)tail: a parser that produces an iterable of additional values (O2)f: Fn(O, O2) -> O.
This is useful for building left-associative constructs such as arithmetic expressions
like 1 - 2 - 3 which should parse as ((1 - 2) - 3).
§Type Parameters
P: Parser for the head element (left-most value).TP: Parser for the tail elements (right-side iterable).F: The folding function applied from left to right.I: The iterable type returned by the tail parser.O2: The item type inside the tail iterable.
Trait Implementations§
Source§impl<P: Clone, TP: Clone, F: Clone, I: Clone, O2: Clone> Clone for PFoldLeft<P, TP, F, I, O2>
impl<P: Clone, TP: Clone, F: Clone, I: Clone, O2: Clone> Clone for PFoldLeft<P, TP, F, I, O2>
Source§impl<'a, K, O, P, TP, F, I, O2> Parser<'a, K, O> for PFoldLeft<P, TP, F, I, O2>
impl<'a, K, O, P, TP, F, I, O2> Parser<'a, K, O> for PFoldLeft<P, TP, F, I, O2>
Source§fn then<P2, O2>(self, p2: P2) -> PSeq<Self, P2>
fn then<P2, O2>(self, p2: P2) -> PSeq<Self, P2>
Sequence two parsers and return a tuple of their results.
Source§fn or<P2>(self, p2: P2) -> POr<Self, P2>where
P2: Parser<'a, K, O>,
fn or<P2>(self, p2: P2) -> POr<Self, P2>where
P2: Parser<'a, K, O>,
Try this parser or an alternative parser if this one fails.
Source§fn map<O2, F>(self, f: F) -> PBind<Self, O, O2>
fn map<O2, F>(self, f: F) -> PBind<Self, O, O2>
Apply a function to transform the output of the parser.
Source§fn between<A, P1, P2>(self, l: P1, r: P2) -> PBetween<P1, Self, P2, A>
fn between<A, P1, P2>(self, l: P1, r: P2) -> PBetween<P1, Self, P2, A>
Apply this parser between two delimiters, discarding the delimiters’ results.
Source§fn many(self) -> PMany<Self>
fn many(self) -> PMany<Self>
Match this parser zero or more times and collect the results. This is the by
default behavior of
crate::parser::many::PMany yet one can specialize behavior
with crate::parser::many::PMany::at_least and crate::parser::many::PMany::at_mostSource§fn delimited_by<PD, A>(self, delim: PD) -> PDelim<Self, PD, A>
fn delimited_by<PD, A>(self, delim: PD) -> PDelim<Self, PD, A>
Parse this parser zero or more times separated by a delimiter (but keep only the content values).
By defualt allow trailing delimiters use
crate::parser::delim::PDelim::no_trailing,
crate::parser::delim::PDelim::at_least and crate::parser::delim::PDelim::at_most to specialize this parser.Source§fn delimited_by1<PD, A>(self, delim: PD) -> PDelim<Self, PD, A>
fn delimited_by1<PD, A>(self, delim: PD) -> PDelim<Self, PD, A>
Parse this parser one or more times separated by a delimiter (but keep only the content values).
Source§fn not(self) -> PNot<Self, O>
fn not(self) -> PNot<Self, O>
Succeeds only if this parser fails, and vice versa. Produces no value.
Source§fn padded_by<PD, A>(self, pad: PD) -> PPaddedBy<Self, PD, A>
fn padded_by<PD, A>(self, pad: PD) -> PPaddedBy<Self, PD, A>
Surround this parser with padding (like whitespace) and return the result.
Source§fn into_<Out>(self, out: Out) -> PInto<Self, O, Out, K>
fn into_<Out>(self, out: Out) -> PInto<Self, O, Out, K>
Ignores the actual parsed value and replaces it with a given one.
Source§fn debug(self, label: &'static str) -> PDebug<Self>where
K: ErrorDisplay,
fn debug(self, label: &'static str) -> PDebug<Self>where
K: ErrorDisplay,
Debug tracing combinator to help inspect parsing behavior.
Source§fn and<P2, A>(self, second: P2) -> PAnd<Self, P2, A>
fn and<P2, A>(self, second: P2) -> PAnd<Self, P2, A>
Apply another parser after this one, but return only the result of the first as well as the location after parsing.
Source§fn until_end(self) -> PUntilEnd<Self, K>
fn until_end(self) -> PUntilEnd<Self, K>
Succeeds if and only if the inner parser succeeds and consumes all input
Source§fn foldl<TP, F, I, O2>(self, tail: TP, f: F) -> PFoldLeft<Self, TP, F, I, O2>
fn foldl<TP, F, I, O2>(self, tail: TP, f: F) -> PFoldLeft<Self, TP, F, I, O2>
Use
self as init while folding left on tail using fSource§fn ignore_then<P2, OO>(self, then: P2) -> PIgnoreThen<Self, P2, O>
fn ignore_then<P2, OO>(self, then: P2) -> PIgnoreThen<Self, P2, O>
Parsers two parsers in sequence ignores the result of the first and returns the result of the second
Source§fn then_ignore<P2, OI>(self, ignore: P2) -> PThenIgnore<Self, P2, OI>
fn then_ignore<P2, OI>(self, ignore: P2) -> PThenIgnore<Self, P2, OI>
Parsers two parsers in sequence returns the result of the first and ignores the result of the second
Source§fn map_with_span<F, O2>(self, f: F) -> PMapWithSpan<Self, O, O2>
fn map_with_span<F, O2>(self, f: F) -> PMapWithSpan<Self, O, O2>
Map the result of the parser through a function with the span which the parser was successful parsing
Source§impl<'a, K, O, P, TP, F, I, O2> ParserCore<'a, K, O> for PFoldLeft<P, TP, F, I, O2>
impl<'a, K, O, P, TP, F, I, O2> ParserCore<'a, K, O> for PFoldLeft<P, TP, F, I, O2>
Auto Trait Implementations§
impl<P, TP, F, I, O2> Freeze for PFoldLeft<P, TP, F, I, O2>
impl<P, TP, F, I, O2> RefUnwindSafe for PFoldLeft<P, TP, F, I, O2>
impl<P, TP, F, I, O2> Send for PFoldLeft<P, TP, F, I, O2>
impl<P, TP, F, I, O2> Sync for PFoldLeft<P, TP, F, I, O2>
impl<P, TP, F, I, O2> Unpin for PFoldLeft<P, TP, F, I, O2>
impl<P, TP, F, I, O2> UnwindSafe for PFoldLeft<P, TP, F, I, O2>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<K> IntoToken<K> for K
impl<K> IntoToken<K> for K
Source§fn into_token(self) -> K
fn into_token(self) -> K
Converts
self into a token of type K.