Struct nom_supreme::parser_ext::Delimited
source · [−]pub struct Delimited<P, D, O2> { /* private fields */ }
Expand description
Parser which gets and discards a delimiting value both before and after the main subparser. Returns the output from the main subparser if all were successful.
Trait Implementations
sourceimpl<P, D, I, O, E, O2> Parser<I, O, E> for Delimited<P, D, O2> where
P: Parser<I, O, E>,
D: Parser<I, O2, E>,
impl<P, D, I, O, E, O2> Parser<I, O, E> for Delimited<P, D, O2> where
P: Parser<I, O, E>,
D: Parser<I, O2, E>,
sourcefn parse(&mut self, input: I) -> IResult<I, O, E>
fn parse(&mut self, input: I) -> IResult<I, O, E>
A parser takes in input type, and returns a Result
containing
either the remaining input and the output value, or an error Read more
sourcefn map<G, O2>(self, g: G) -> Map<Self, G, O> where
G: Fn(O) -> O2,
fn map<G, O2>(self, g: G) -> Map<Self, G, O> where
G: Fn(O) -> O2,
Maps a function over the result of a parser
sourcefn flat_map<G, H, O2>(self, g: G) -> FlatMap<Self, G, O> where
G: FnMut(O) -> H,
H: Parser<I, O2, E>,
fn flat_map<G, H, O2>(self, g: G) -> FlatMap<Self, G, O> where
G: FnMut(O) -> H,
H: Parser<I, O2, E>,
Creates a second parser from the output of the first one, then apply over the rest of the input
sourcefn and_then<G, O2>(self, g: G) -> AndThen<Self, G, O> where
G: Parser<O, O2, E>,
fn and_then<G, O2>(self, g: G) -> AndThen<Self, G, O> where
G: Parser<O, O2, E>,
Applies a second parser over the output of the first one
sourcefn and<G, O2>(self, g: G) -> And<Self, G> where
G: Parser<I, O2, E>,
fn and<G, O2>(self, g: G) -> And<Self, G> where
G: Parser<I, O2, E>,
Applies a second parser after the first one, return their results as a tuple
impl<P: Copy, D: Copy, O2: Copy> Copy for Delimited<P, D, O2>
Auto Trait Implementations
impl<P, D, O2> RefUnwindSafe for Delimited<P, D, O2> where
D: RefUnwindSafe,
O2: RefUnwindSafe,
P: RefUnwindSafe,
impl<P, D, O2> Send for Delimited<P, D, O2> where
D: Send,
O2: Send,
P: Send,
impl<P, D, O2> Sync for Delimited<P, D, O2> where
D: Sync,
O2: Sync,
P: Sync,
impl<P, D, O2> Unpin for Delimited<P, D, O2> where
D: Unpin,
O2: Unpin,
P: Unpin,
impl<P, D, O2> UnwindSafe for Delimited<P, D, O2> where
D: UnwindSafe,
O2: UnwindSafe,
P: UnwindSafe,
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
sourceimpl<I, T> ExtractContext<I, ()> for T
impl<I, T> ExtractContext<I, ()> for T
sourcefn extract_context(self, _original_input: I)
fn extract_context(self, _original_input: I)
Given the context attached to a nom error, and given the original input to the nom parser, extract more the useful context information. Read more
sourceimpl<I, O, E, P> ParserExt<I, O, E> for P where
P: Parser<I, O, E>,
impl<I, O, E, P> ParserExt<I, O, E> for P where
P: Parser<I, O, E>,
sourcefn by_ref(&mut self) -> RefParser<'_, Self>
fn by_ref(&mut self) -> RefParser<'_, Self>
Borrow a parser. This allows building parser combinators while still
retaining ownership of the original parser. This is necessary because
impl<T: Parser> Parser for &mut T
is impossible due to conflicts
with impl<T: FnMut> Parser for T
. Read more
sourcefn all_consuming(self) -> AllConsuming<Self> where
I: InputLength,
E: ParseError<I>,
fn all_consuming(self) -> AllConsuming<Self> where
I: InputLength,
E: ParseError<I>,
Create a parser that must consume all of the input, or else return an error. Read more
sourcefn complete(self) -> Complete<Self> where
I: Clone,
E: ParseError<I>,
fn complete(self) -> Complete<Self> where
I: Clone,
E: ParseError<I>,
Create a parser that transforms Incomplete
into Error
. Read more
sourcefn cut(self) -> Cut<Self>
fn cut(self) -> Cut<Self>
Create a parser that transforms Error
into Failure
. This will
end the parse immediately, even if there are other branches that
could occur. Read more
sourcefn map_res<F, O2, E2>(self, func: F) -> MapRes<Self, F, O, E2> where
F: FnMut(O) -> Result<O2, E2>,
E: FromExternalError<I, E2>,
I: Clone,
fn map_res<F, O2, E2>(self, func: F) -> MapRes<Self, F, O, E2> where
F: FnMut(O) -> Result<O2, E2>,
E: FromExternalError<I, E2>,
I: Clone,
Create a parser that applies a mapping function func
to the output
of the subparser. Any errors from func
will be transformed into
parse errors via FromExternalError
. Read more
sourcefn map_res_cut<F, O2, E2>(self, func: F) -> MapResCut<Self, F, O, E2> where
F: FnMut(O) -> Result<O2, E2>,
E: FromExternalError<I, E2>,
I: Clone,
fn map_res_cut<F, O2, E2>(self, func: F) -> MapResCut<Self, F, O, E2> where
F: FnMut(O) -> Result<O2, E2>,
E: FromExternalError<I, E2>,
I: Clone,
Create a parser that applies a mapping function func
to the output
of the subparser. Any errors from func
will be transformed into
parse failures via FromExternalError
. This will
end the parse immediately, even if there are other branches that
could occur. Read more
sourcefn opt(self) -> Optional<Self> where
I: Clone,
fn opt(self) -> Optional<Self> where
I: Clone,
Make this parser optional; if it fails to parse, instead it returns
None
with the input in the original position. Read more
sourcefn recognize(self) -> Recognize<Self, O> where
I: Clone + Slice<RangeTo<usize>> + Offset,
fn recognize(self) -> Recognize<Self, O> where
I: Clone + Slice<RangeTo<usize>> + Offset,
Replace this parser’s output with the entire input that was consumed by the parser. Read more
sourcefn with_recognized(self) -> WithRecognized<Self> where
I: Clone + Slice<RangeTo<usize>> + Offset,
fn with_recognized(self) -> WithRecognized<Self> where
I: Clone + Slice<RangeTo<usize>> + Offset,
Return the parsed value, but also return the entire input that was consumed by the parse Read more
sourcefn value<T: Clone>(self, value: T) -> Value<T, Self, O>
fn value<T: Clone>(self, value: T) -> Value<T, Self, O>
Replace this parser’s output with a clone of value
every time it
finishes successfully. Read more
sourcefn verify<F>(self, verifier: F) -> Verify<Self, F> where
F: Fn(&O) -> bool,
I: Clone,
E: ParseError<I>,
fn verify<F>(self, verifier: F) -> Verify<Self, F> where
F: Fn(&O) -> bool,
I: Clone,
E: ParseError<I>,
Require the output of this parser to pass a verifier function, or else return a parse error. Read more
sourcefn context<C>(self, context: C) -> Context<Self, C> where
E: ContextError<I, C>,
I: Clone,
C: Clone,
fn context<C>(self, context: C) -> Context<Self, C> where
E: ContextError<I, C>,
I: Clone,
C: Clone,
Add some context to the parser. This context will be added to any
errors that are returned from the parser via ContextError
. Read more
sourcefn terminated<F, O2>(self, terminator: F) -> Terminated<Self, F, O2> where
F: Parser<I, O2, E>,
fn terminated<F, O2>(self, terminator: F) -> Terminated<Self, F, O2> where
F: Parser<I, O2, E>,
Add a terminator parser. The terminator will run after this parser, returning any errors, but its output will otherwise be discarded. Read more
sourcefn precedes<F, O2>(self, successor: F) -> Preceded<F, Self, O> where
F: Parser<I, O2, E>,
fn precedes<F, O2>(self, successor: F) -> Preceded<F, Self, O> where
F: Parser<I, O2, E>,
Make this parser precede another one. The successor parser will run after this one succeeds, and the successor’s output will be returned. Read more
sourcefn preceded_by<F, O2>(self, prefix: F) -> Preceded<Self, F, O2> where
F: Parser<I, O2, E>,
fn preceded_by<F, O2>(self, prefix: F) -> Preceded<Self, F, O2> where
F: Parser<I, O2, E>,
Make this parser preceded by another one. The prefix
will run first,
and if it succeeds, its output will be discard and this parser will
be run. Read more
sourcefn opt_precedes<F, O2>(self, successor: F) -> OptionalPreceded<Self, F> where
E: ParseError<I>,
I: Clone,
F: Parser<I, O2, E>,
fn opt_precedes<F, O2>(self, successor: F) -> OptionalPreceded<Self, F> where
E: ParseError<I>,
I: Clone,
F: Parser<I, O2, E>,
Make this parser optionally precede by another one. self
will
run first, and then the successor
will run even if self
returns an
error. Both outputs will be returned. This is functionally equivalent
to self.opt().and(successor)
, but it has the added benefit that if
both parsers return an error, the error from the prefix
will be
retained, rather than discarded. Read more
sourcefn opt_preceded_by<F, O2>(self, prefix: F) -> OptionalPreceded<F, Self> where
E: ParseError<I>,
I: Clone,
F: Parser<I, O2, E>,
fn opt_preceded_by<F, O2>(self, prefix: F) -> OptionalPreceded<F, Self> where
E: ParseError<I>,
I: Clone,
F: Parser<I, O2, E>,
Make this parser optionally preceded by another one. The prefix
will
run first, and then this parser will run even if the prefix
returned
an error. Both outputs will be returned. This is functionally equivalent
to prefix.opt().and(self)
, but it has the added benefit that if both
parsers return an error, the error from the prefix
will be retained,
rather than discarded. Read more
sourcefn delimited_by<D, O2>(self, delimiter: D) -> Delimited<Self, D, O2> where
D: Parser<I, O2, E>,
fn delimited_by<D, O2>(self, delimiter: D) -> Delimited<Self, D, O2> where
D: Parser<I, O2, E>,
Make this parser delimited, requiring a delimiter
as both a prefix and
a suffix. The output of the delimiters is discarded. Read more
sourcefn peek(self) -> Peek<Self> where
I: Clone,
fn peek(self) -> Peek<Self> where
I: Clone,
Make this parser peeking: it runs normally but consumes no input. Read more
sourcefn not(self) -> Not<Self, O> where
I: Clone,
E: ParseError<I>,
fn not(self) -> Not<Self, O> where
I: Clone,
E: ParseError<I>,
Make this parser a negative lookahead: it will succeed if the subparser fails, and fail if the subparser succeeds. Read more
sourcefn parse_from_str<'a, T>(self) -> FromStrParser<Self, T> where
Self: Parser<I, &'a str, E>,
I: Clone,
T: FromStr,
E: FromExternalError<I, T::Err>,
fn parse_from_str<'a, T>(self) -> FromStrParser<Self, T> where
Self: Parser<I, &'a str, E>,
I: Clone,
T: FromStr,
E: FromExternalError<I, T::Err>,
sourcefn parse_from_str_cut<'a, T>(self) -> FromStrCutParser<Self, T> where
Self: Parser<I, &'a str, E>,
I: Clone,
T: FromStr,
E: FromExternalError<I, T::Err>,
fn parse_from_str_cut<'a, T>(self) -> FromStrCutParser<Self, T> where
Self: Parser<I, &'a str, E>,
I: Clone,
T: FromStr,
E: FromExternalError<I, T::Err>,
Create a parser that parses something via FromStr
, using this
parser as a recognizer for the string to pass to
from_str
. This parser transforms any errors
from FromStr
into Err::Failure
, which will
end the overall parse immediately, even if there are other branches
that could be tried. Read more
sourcefn array(self) -> ArrayParser<Self>
fn array(self) -> ArrayParser<Self>
Create a parser that parses a fixed-size array by running this parser in a loop. Read more
sourcefn separated_array<F, O2>(
self,
separator: F
) -> SeparatedArrayParser<Self, F, O2> where
F: Parser<I, O2, E>,
fn separated_array<F, O2>(
self,
separator: F
) -> SeparatedArrayParser<Self, F, O2> where
F: Parser<I, O2, E>,
Create a parser that parses a fixed-size array by running this parser in a loop, parsing a separator in between each element. Read more
sourceimpl<I> RecreateContext<I> for I
impl<I> RecreateContext<I> for I
sourcefn recreate_context(_original_input: I, tail: I) -> I
fn recreate_context(_original_input: I, tail: I) -> I
Given the original input, as well as the context reported by nom, recreate a context in the original string where the error occurred. Read more
sourceimpl<T> ToOwned for T where
T: Clone,
impl<T> ToOwned for T where
T: Clone,
type Owned = T
type Owned = T
The resulting type after obtaining ownership.
sourcefn clone_into(&self, target: &mut T)
fn clone_into(&self, target: &mut T)
toowned_clone_into
)Uses borrowed data to replace owned data, usually by cloning. Read more