pub struct Label<P>(/* private fields */);Expand description
Wrapper that attaches a label to errors.
Trait Implementations§
Source§impl<P, I, E, N, L> Parser<I, E, N, L> for Label<P>
impl<P, I, E, N, L> Parser<I, E, N, L> for Label<P>
fn run(&self, i: In<'_, I, E, N, L>) -> Self::Out
Source§fn by_ref<'a>(&'a self) -> RefParser<'a, Self>
fn by_ref<'a>(&'a self) -> RefParser<'a, Self>
Borrow a parser immutably as
ParserOnce. Read moreSource§fn flow_many_map<F, O, T1, T2>(self, f: F) -> FlowManyMap<Self, F>where
Self: Sized + ParserMut<I, E, N, L, Out = ControlFlow<T2, T1>>,
F: for<'a, 'b> Fn(&mut FlowManyIterator<'a, 'b, Self, I, E, N, L, T1, T2>) -> O,
fn flow_many_map<F, O, T1, T2>(self, f: F) -> FlowManyMap<Self, F>where
Self: Sized + ParserMut<I, E, N, L, Out = ControlFlow<T2, T1>>,
F: for<'a, 'b> Fn(&mut FlowManyIterator<'a, 'b, Self, I, E, N, L, T1, T2>) -> O,
Source§fn many_map<F, O>(self, f: F) -> ManyMap<Self, F>where
Self: Sized + ParserMut<I, E, N, L, Out: OutOf<I, E>>,
F: for<'a, 'b> Fn(ManyMapIterator<'a, 'b, Self, I, E, N, L>) -> O,
fn many_map<F, O>(self, f: F) -> ManyMap<Self, F>where
Self: Sized + ParserMut<I, E, N, L, Out: OutOf<I, E>>,
F: for<'a, 'b> Fn(ManyMapIterator<'a, 'b, Self, I, E, N, L>) -> O,
Like
ParserMut::many, but lets you fold via a streaming iterator. Read moreSource§fn many1_map<F, O>(self, f: F) -> Many1Map<Self, F>where
Self: Sized + ParserMut<I, E, N, L, Out: OutOf<I, E>>,
F: for<'a, 'b> Fn(Many1MapIterator<'a, 'b, Self, I, E, N, L>) -> O,
fn many1_map<F, O>(self, f: F) -> Many1Map<Self, F>where
Self: Sized + ParserMut<I, E, N, L, Out: OutOf<I, E>>,
F: for<'a, 'b> Fn(Many1MapIterator<'a, 'b, Self, I, E, N, L>) -> O,
Like
Parser::many_map, but requires at least one element.Source§fn sep_map<Q, F, T, S, O>(
self,
sep_p: Q,
f: F,
) -> SepMap<Zero, Allow, Self, Q, F, T>
fn sep_map<Q, F, T, S, O>( self, sep_p: Q, f: F, ) -> SepMap<Zero, Allow, Self, Q, F, T>
Like
ParserMut::sep, but lets you fold via a streaming iterator. Read moreSource§impl<P, I, E, N, L> ParserMut<I, E, N, L> for Label<P>
impl<P, I, E, N, L> ParserMut<I, E, N, L> for Label<P>
fn run_mut(&mut self, i: In<'_, I, E, N, L>) -> Self::Out
Source§fn by_mut<'a>(&'a mut self) -> MutParser<'a, Self>
fn by_mut<'a>(&'a mut self) -> MutParser<'a, Self>
Borrow a parser mutably as
ParserOnce. Read moreSource§fn map_mut<O, F>(self, f: F) -> Map<Self, F>
fn map_mut<O, F>(self, f: F) -> Map<Self, F>
Like
Parser::map, but intended for mutable/repeatable mappers (FnMut).Source§fn bind_mut<P2, F>(self, f: F) -> Bind<Self, F>
fn bind_mut<P2, F>(self, f: F) -> Bind<Self, F>
Like
Parser::bind, but intended for mutable/repeatable binders (FnMut).Source§fn flow<C, S, Step, T>(self, state: S, step: Step) -> Flow<Self, S, Step>where
Self: Sized + ParserMut<I, E, N, L, Out: OutOf<I, E, Value = T>>,
Step: FnMut(S, T) -> ControlFlow<C, S>,
fn flow<C, S, Step, T>(self, state: S, step: Step) -> Flow<Self, S, Step>where
Self: Sized + ParserMut<I, E, N, L, Out: OutOf<I, E, Value = T>>,
Step: FnMut(S, T) -> ControlFlow<C, S>,
Source§fn flow_many_map_once<F, O, T1, T2>(self, f: F) -> FlowManyMap<Self, F>where
Self: Sized + ParserMut<I, E, N, L, Out = ControlFlow<T2, T1>>,
F: for<'a, 'b> FnOnce(&mut FlowManyIterator<'a, 'b, Self, I, E, N, L, T1, T2>) -> O,
fn flow_many_map_once<F, O, T1, T2>(self, f: F) -> FlowManyMap<Self, F>where
Self: Sized + ParserMut<I, E, N, L, Out = ControlFlow<T2, T1>>,
F: for<'a, 'b> FnOnce(&mut FlowManyIterator<'a, 'b, Self, I, E, N, L, T1, T2>) -> O,
Like
Parser::flow_many_map, but intended for single-shot mappers (FnOnce).Source§fn flow_many_map_mut<F, O, T1, T2>(self, f: F) -> FlowManyMap<Self, F>where
Self: Sized + ParserMut<I, E, N, L, Out = ControlFlow<T2, T1>>,
F: for<'a, 'b> FnMut(&mut FlowManyIterator<'a, 'b, Self, I, E, N, L, T1, T2>) -> O,
fn flow_many_map_mut<F, O, T1, T2>(self, f: F) -> FlowManyMap<Self, F>where
Self: Sized + ParserMut<I, E, N, L, Out = ControlFlow<T2, T1>>,
F: for<'a, 'b> FnMut(&mut FlowManyIterator<'a, 'b, Self, I, E, N, L, T1, T2>) -> O,
Like
Parser::flow_many_map, but intended for mutable/repeatable mappers (FnMut).Source§fn many<O>(self) -> Many<Self, O>where
Self: Sized + ParserMut<I, E, N, L, Out: OutOf<I, E>>,
O: FromIterator<ValueOf<Self, I, E, N, L>>,
fn many<O>(self) -> Many<Self, O>where
Self: Sized + ParserMut<I, E, N, L, Out: OutOf<I, E>>,
O: FromIterator<ValueOf<Self, I, E, N, L>>,
Repeat a parser until soft failure, collecting outputs. Read more
Source§fn many1<O>(self) -> Many1<Self, O>where
Self: Sized + ParserMut<I, E, N, L, Out: OutOf<I, E>>,
O: FromIterator<ValueOf<Self, I, E, N, L>>,
fn many1<O>(self) -> Many1<Self, O>where
Self: Sized + ParserMut<I, E, N, L, Out: OutOf<I, E>>,
O: FromIterator<ValueOf<Self, I, E, N, L>>,
Repeat a parser one or more times, collecting outputs. Read more
Source§fn many_map_once<F, O>(self, f: F) -> ManyMap<Self, F>where
Self: Sized + ParserMut<I, E, N, L, Out: OutOf<I, E>>,
F: for<'a, 'b> FnOnce(ManyMapIterator<'a, 'b, Self, I, E, N, L>) -> O,
fn many_map_once<F, O>(self, f: F) -> ManyMap<Self, F>where
Self: Sized + ParserMut<I, E, N, L, Out: OutOf<I, E>>,
F: for<'a, 'b> FnOnce(ManyMapIterator<'a, 'b, Self, I, E, N, L>) -> O,
Like
Parser::many_map, but intended for single-shot mappers (FnOnce).Source§fn many_map_mut<F, O>(self, f: F) -> ManyMap<Self, F>where
Self: Sized + ParserMut<I, E, N, L, Out: OutOf<I, E>>,
F: for<'a, 'b> FnMut(ManyMapIterator<'a, 'b, Self, I, E, N, L>) -> O,
fn many_map_mut<F, O>(self, f: F) -> ManyMap<Self, F>where
Self: Sized + ParserMut<I, E, N, L, Out: OutOf<I, E>>,
F: for<'a, 'b> FnMut(ManyMapIterator<'a, 'b, Self, I, E, N, L>) -> O,
Source§fn many1_map_once<F, O>(self, f: F) -> Many1Map<Self, F>where
Self: Sized + ParserMut<I, E, N, L, Out: OutOf<I, E>>,
F: for<'a, 'b> FnOnce(Many1MapIterator<'a, 'b, Self, I, E, N, L>) -> O,
fn many1_map_once<F, O>(self, f: F) -> Many1Map<Self, F>where
Self: Sized + ParserMut<I, E, N, L, Out: OutOf<I, E>>,
F: for<'a, 'b> FnOnce(Many1MapIterator<'a, 'b, Self, I, E, N, L>) -> O,
Like
Parser::many1_map, but intended for single-shot mappers (FnOnce).Source§fn many1_map_mut<F, O>(self, f: F) -> Many1Map<Self, F>where
Self: Sized + ParserMut<I, E, N, L, Out: OutOf<I, E>>,
F: for<'a, 'b> FnMut(Many1MapIterator<'a, 'b, Self, I, E, N, L>) -> O,
fn many1_map_mut<F, O>(self, f: F) -> Many1Map<Self, F>where
Self: Sized + ParserMut<I, E, N, L, Out: OutOf<I, E>>,
F: for<'a, 'b> FnMut(Many1MapIterator<'a, 'b, Self, I, E, N, L>) -> O,
Like
Parser::many1_map, but intended for mutable/repeatable mappers (FnMut).Source§fn many_skip(self) -> SkipMany<Self>
fn many_skip(self) -> SkipMany<Self>
Repeat a parser until soft failure, discarding outputs. Read more
Source§fn many1_skip(self) -> SkipMany1<Self>
fn many1_skip(self) -> SkipMany1<Self>
Repeat a parser one or more times, discarding outputs. Read more
Source§fn count<R, O>(self, range: R) -> Count<Self, O>where
Self: Sized + ParserMut<I, E, N, L, Out: OutOf<I, E>>,
R: CountRange,
O: FromIterator<ValueOf<Self, I, E, N, L>>,
fn count<R, O>(self, range: R) -> Count<Self, O>where
Self: Sized + ParserMut<I, E, N, L, Out: OutOf<I, E>>,
R: CountRange,
O: FromIterator<ValueOf<Self, I, E, N, L>>,
Repeat a parser a specified number of times. Read more
Source§fn sep<O, Q, T>(self, sep_p: Q) -> Sep<O, Zero, Allow, Self, Q, T>
fn sep<O, Q, T>(self, sep_p: Q) -> Sep<O, Zero, Allow, Self, Q, T>
Parse a separated list:
item (sep item)*. Read moreSource§fn sep_map_once<Q, F, T, S, O>(
self,
sep_p: Q,
f: F,
) -> SepMap<Zero, Allow, Self, Q, F, T>
fn sep_map_once<Q, F, T, S, O>( self, sep_p: Q, f: F, ) -> SepMap<Zero, Allow, Self, Q, F, T>
Like
Parser::sep_map, but intended for single-shot mappers (FnOnce).Source§fn sep_map_mut<Q, F, T, S, O>(
self,
sep_p: Q,
f: F,
) -> SepMap<Zero, Allow, Self, Q, F, T>
fn sep_map_mut<Q, F, T, S, O>( self, sep_p: Q, f: F, ) -> SepMap<Zero, Allow, Self, Q, F, T>
Like
Parser::sep_map, but intended for mutable/repeatable mappers (FnMut).Source§fn sep_reduce<Q, F>(self, op: Q, f: F) -> SepReduce<Self, Q, F>
fn sep_reduce<Q, F>(self, op: Q, f: F) -> SepReduce<Self, Q, F>
Left-associative separator reduction:
term (op term)*.
let mut input = “a+a+a”;
let term = item(‘a’).to(1);
let plus = item(‘+’).to(());
let out = parse_ok_once(&mut input, term.sep_reduce(plus, |a, _, b| a + b)).unwrap();
assert_eq!(out, 3);
assert_eq!(input, “”); Read moreSource§impl<P, I, E, N, L> ParserOnce<I, E, N, L> for Label<P>
impl<P, I, E, N, L> ParserOnce<I, E, N, L> for Label<P>
type Out = <E as ErrMode<I>>::Out<<<P as ParserOnce<I, E, N, L>>::Out as OutOf<I, E>>::Value, Expected<<<P as ParserOnce<I, E, N, L>>::Out as OutOf<I, E>>::Error>>
fn run_once(self, i: In<'_, I, E, N, L>) -> Self::Out
Source§fn with_range(self) -> WithRange<Self>
fn with_range(self) -> WithRange<Self>
Attach the consumed range (start and end positions) to a parser output. Read more
Source§fn with_seq<S>(self) -> WithSeq<Self, S>
fn with_seq<S>(self) -> WithSeq<Self, S>
Attach the consumed sequence to a parser output. Read more
Source§fn no_cut(self) -> NoCut<Self>
fn no_cut(self) -> NoCut<Self>
Run this parser in a non-root cut scope (cut does not trigger commits). Read more
Source§fn label(self, label: impl Into<Cow<'static, str>>) -> Label<Self>
fn label(self, label: impl Into<Cow<'static, str>>) -> Label<Self>
Attach a label to a parser failure (Parsec-like
<?>). Read moreSource§fn label_with<F, S>(self, f: F) -> LabelWith<Self, F>
fn label_with<F, S>(self, f: F) -> LabelWith<Self, F>
Attach a lazily-evaluated label to a parser failure. Read more
Source§fn label_with_once<F, S>(self, f: F) -> LabelWith<Self, F>
fn label_with_once<F, S>(self, f: F) -> LabelWith<Self, F>
Like
ParserOnce::label_with, but intended for single-shot label builders (FnOnce).Source§fn label_with_mut<F, S>(self, f: F) -> LabelWith<Self, F>
fn label_with_mut<F, S>(self, f: F) -> LabelWith<Self, F>
Like
ParserOnce::label_with, but intended for mutable/repeatable label builders (FnMut).Source§fn align_errors<T, E2>(self) -> AlignErrors<Self, (T, E2)>where
I: SeqInput<T>,
E2: MergeErrors,
Self: ParserOnce<I, Merger<I, E2>, N, L, Out: OutOf<I, Merger<I, E2>>>,
fn align_errors<T, E2>(self) -> AlignErrors<Self, (T, E2)>where
I: SeqInput<T>,
E2: MergeErrors,
Self: ParserOnce<I, Merger<I, E2>, N, L, Out: OutOf<I, Merger<I, E2>>>,
Align and merge errors, returning the consumed sequence on failure.
Source§fn align_ranged_errors<T, E2>(self) -> AlignRangedErrors<Self, (T, E2)>where
I: SeqInput<T>,
E2: MergeErrors,
Self: ParserOnce<I, Merger<I, E2>, N, L, Out: OutOf<I, Merger<I, E2>>>,
fn align_ranged_errors<T, E2>(self) -> AlignRangedErrors<Self, (T, E2)>where
I: SeqInput<T>,
E2: MergeErrors,
Self: ParserOnce<I, Merger<I, E2>, N, L, Out: OutOf<I, Merger<I, E2>>>,
Align and merge errors, returning the consumed sequence and range on failure.
Source§fn map_once<O, F>(self, f: F) -> Map<Self, F>
fn map_once<O, F>(self, f: F) -> Map<Self, F>
Like
Parser::map, but intended for single-shot mappers (FnOnce).Source§fn lift_result<O, E1>(self) -> LiftResult<Self>
fn lift_result<O, E1>(self) -> LiftResult<Self>
Lift a direct
Result output into a merger-based parser with ranged errors.Source§fn lift_ranged_result<O1, O2, E1>(self) -> LiftRangedResult<Self>
fn lift_ranged_result<O1, O2, E1>(self) -> LiftRangedResult<Self>
Lift a direct
(A, Result<B, (range, err)>) output into a merger-based parser.Source§fn to<O>(self, value: O) -> To<Self, O>
fn to<O>(self, value: O) -> To<Self, O>
Replace the output of a parser with a constant value. Read more
Source§fn bind_once<P2, F>(self, f: F) -> Bind<Self, F>
fn bind_once<P2, F>(self, f: F) -> Bind<Self, F>
Like
Parser::bind, but intended for single-shot binders (FnOnce).fn map_err<E1, E2, E3, F, O>(self, f: F) -> MapErr<Self, F, (O, E1)>
Auto Trait Implementations§
impl<P> Freeze for Label<P>where
P: Freeze,
impl<P> RefUnwindSafe for Label<P>where
P: RefUnwindSafe,
impl<P> Send for Label<P>where
P: Send,
impl<P> Sync for Label<P>where
P: Sync,
impl<P> Unpin for Label<P>where
P: Unpin,
impl<P> UnwindSafe for Label<P>where
P: UnwindSafe,
Blanket Implementations§
Source§impl<T> Back for Twhere
T: Clone,
impl<T> Back for Twhere
T: Clone,
Source§type Checkpoint = T
type Checkpoint = T
A clonable checkpoint that can restore the input to an earlier state.
Source§fn checkpoint(&mut self) -> <T as Back>::Checkpoint
fn checkpoint(&mut self) -> <T as Back>::Checkpoint
Create a rollback checkpoint.
Source§fn rollback(&mut self, checkpoint: <T as Back>::Checkpoint)
fn rollback(&mut self, checkpoint: <T as Back>::Checkpoint)
Roll back the input to a previously created checkpoint.
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