Trait kalosm_sample::ParserExt
source · pub trait ParserExt: Parser {
// Provided methods
fn otherwise<V: Parser>(self, other: V) -> ChoiceParser<Self, V>
where Self: Sized { ... }
fn or<V: Parser<Output = Self::Output>>(
self,
other: V,
) -> MapOutputParser<ChoiceParser<Self, V>, Self::Output>
where Self: Sized { ... }
fn then<V: Parser>(self, other: V) -> SequenceParser<Self, V>
where Self: Sized { ... }
fn then_lazy<V, F>(self, other: F) -> ThenLazy<Self, F>
where Self: Sized,
V: CreateParserState,
F: Fn(&Self::Output) -> V { ... }
fn ignore_output_then<V: CreateParserState>(
self,
other: V,
) -> MapOutputParser<SequenceParser<Self, V>, <V as Parser>::Output>
where Self: Sized { ... }
fn then_ignore_output<V: CreateParserState>(
self,
other: V,
) -> MapOutputParser<SequenceParser<Self, V>, <Self as Parser>::Output>
where Self: Sized { ... }
fn then_literal(
self,
literal: impl Into<Cow<'static, str>>,
) -> MapOutputParser<SequenceParser<Self, LiteralParser>, <Self as Parser>::Output>
where Self: Sized { ... }
fn repeat(self, length_range: RangeInclusive<usize>) -> RepeatParser<Self>
where Self: Sized { ... }
fn map_output<F, O>(self, f: F) -> MapOutputParser<Self, O, F>
where Self: Sized,
F: Fn(Self::Output) -> O { ... }
fn boxed(self) -> ArcParser<Self::Output>
where Self: CreateParserState + Sized + Send + Sync + 'static,
Self::Output: Send + Sync + 'static,
Self::PartialState: Send + Sync + 'static { ... }
fn with_initial_state<F: Fn() -> Self::PartialState + Clone>(
self,
initial_state: F,
) -> WithInitialState<Self, F>
where Self: Sized { ... }
}
Expand description
An extension trait for parsers.
Provided Methods§
sourcefn otherwise<V: Parser>(self, other: V) -> ChoiceParser<Self, V>where
Self: Sized,
fn otherwise<V: Parser>(self, other: V) -> ChoiceParser<Self, V>where
Self: Sized,
Parse this parser, or another other parser.
sourcefn or<V: Parser<Output = Self::Output>>(
self,
other: V,
) -> MapOutputParser<ChoiceParser<Self, V>, Self::Output>where
Self: Sized,
fn or<V: Parser<Output = Self::Output>>(
self,
other: V,
) -> MapOutputParser<ChoiceParser<Self, V>, Self::Output>where
Self: Sized,
Parse this parser, or another other parser with the same type
sourcefn then<V: Parser>(self, other: V) -> SequenceParser<Self, V>where
Self: Sized,
fn then<V: Parser>(self, other: V) -> SequenceParser<Self, V>where
Self: Sized,
Parse this parser, then the other parser.
sourcefn then_lazy<V, F>(self, other: F) -> ThenLazy<Self, F>
fn then_lazy<V, F>(self, other: F) -> ThenLazy<Self, F>
Parse this parser, then the other parser that is created base on the output of this parser.
sourcefn ignore_output_then<V: CreateParserState>(
self,
other: V,
) -> MapOutputParser<SequenceParser<Self, V>, <V as Parser>::Output>where
Self: Sized,
fn ignore_output_then<V: CreateParserState>(
self,
other: V,
) -> MapOutputParser<SequenceParser<Self, V>, <V as Parser>::Output>where
Self: Sized,
Parse this parser, then the other parser while ignoring the current parser’s output.
sourcefn then_ignore_output<V: CreateParserState>(
self,
other: V,
) -> MapOutputParser<SequenceParser<Self, V>, <Self as Parser>::Output>where
Self: Sized,
fn then_ignore_output<V: CreateParserState>(
self,
other: V,
) -> MapOutputParser<SequenceParser<Self, V>, <Self as Parser>::Output>where
Self: Sized,
Parse this parser, then the other parser while ignoring the output of the other parser.
sourcefn then_literal(
self,
literal: impl Into<Cow<'static, str>>,
) -> MapOutputParser<SequenceParser<Self, LiteralParser>, <Self as Parser>::Output>where
Self: Sized,
fn then_literal(
self,
literal: impl Into<Cow<'static, str>>,
) -> MapOutputParser<SequenceParser<Self, LiteralParser>, <Self as Parser>::Output>where
Self: Sized,
Parse this parser, then a literal. This is equivalent to .then_ignore_output(LiteralParser::new(literal))
.
sourcefn repeat(self, length_range: RangeInclusive<usize>) -> RepeatParser<Self>where
Self: Sized,
fn repeat(self, length_range: RangeInclusive<usize>) -> RepeatParser<Self>where
Self: Sized,
Repeat this parser a number of times.
sourcefn map_output<F, O>(self, f: F) -> MapOutputParser<Self, O, F>
fn map_output<F, O>(self, f: F) -> MapOutputParser<Self, O, F>
Map the output of this parser.
sourcefn boxed(self) -> ArcParser<Self::Output>where
Self: CreateParserState + Sized + Send + Sync + 'static,
Self::Output: Send + Sync + 'static,
Self::PartialState: Send + Sync + 'static,
fn boxed(self) -> ArcParser<Self::Output>where
Self: CreateParserState + Sized + Send + Sync + 'static,
Self::Output: Send + Sync + 'static,
Self::PartialState: Send + Sync + 'static,
Get a boxed version of this parser.
sourcefn with_initial_state<F: Fn() -> Self::PartialState + Clone>(
self,
initial_state: F,
) -> WithInitialState<Self, F>where
Self: Sized,
fn with_initial_state<F: Fn() -> Self::PartialState + Clone>(
self,
initial_state: F,
) -> WithInitialState<Self, F>where
Self: Sized,
Create a new parser with a different initial state