Trait KParser

Source
pub trait KParser<I, O, E>
where Self: Sized,
{
Show 20 methods // Required methods fn err_into<E2>(self) -> IntoErr<Self, O, E, E2> where E: Into<E2>; fn with_code<C>(self, code: C) -> WithCode<Self, C> where C: Code, E: KParseError<C, I>; fn with_context<C, Y>(self, context: Y) -> WithContext<Self, C, E, Y> where C: Code, I: Clone, E: Into<ParserError<C, I>>, Y: Clone + 'static; fn map_res<TR, O2>(self, map: TR) -> MapRes<Self, O, TR, O2> where TR: Fn(O) -> Result<O2, Err<E>>; fn parse_from_str<C, O2>(self, code: C) -> FromStrParser<Self, C, O, O2> where C: Code, O: InputIter<Item = char>, O2: FromStr, E: KParseError<C, I>; fn value<O2>(self, value: O2) -> Value<Self, O, O2> where O2: Clone; fn all_consuming<C>(self, code: C) -> AllConsuming<Self, C> where C: Code, I: InputLength, E: KParseError<C, I>; fn complete<C>(self, code: C) -> Complete<Self, C> where C: Code, I: Clone, E: KParseError<C, I>; fn cut(self) -> Cut<Self>; fn opt(self) -> Optional<Self>; fn recognize(self) -> Recognize<Self, O> where I: Clone + Slice<RangeTo<usize>> + Offset; fn consumed(self) -> Consumed<Self> where I: Clone + Slice<RangeTo<usize>> + Offset; fn terminated<PA, O2>(self, terminator: PA) -> Terminated<Self, PA, O2> where PA: Parser<I, O2, E>; fn precedes<PA, O2>(self, successor: PA) -> Precedes<Self, PA, O> where PA: Parser<I, O2, E>; fn opt_precedes<PA, O2>(self, successor: PA) -> OptPrecedes<Self, PA, O> where PA: Parser<I, O2, E>, I: Clone; fn delimited_by<PA, O2>(self, delimiter: PA) -> DelimitedBy<Self, PA, O2> where PA: Parser<I, O2, E>; fn peek(self) -> Peek<Self> where I: Clone; fn not<C>(self, code: C) -> PNot<Self, C, O> where C: Code, E: KParseError<C, I>, I: Clone; fn or_else<PE, OE>(self, other: PE) -> OrElse<Self, PE, OE> where PE: Parser<I, OE, E>; fn verify<V, C, O2>(self, verify: V, code: C) -> Verify<Self, V, C, O2> where C: Code, V: Fn(&O2) -> bool, O: Borrow<O2>, O2: ?Sized, E: KParseError<C, I>;
}
Expand description

Adds some common parser combinators as postfix operators to parser.

Required Methods§

Source

fn err_into<E2>(self) -> IntoErr<Self, O, E, E2>
where E: Into<E2>,

Converts the error to the target error.

Source

fn with_code<C>(self, code: C) -> WithCode<Self, C>
where C: Code, E: KParseError<C, I>,

Changes the error code.

Source

fn with_context<C, Y>(self, context: Y) -> WithContext<Self, C, E, Y>
where C: Code, I: Clone, E: Into<ParserError<C, I>>, Y: Clone + 'static,

Adds some context.

Source

fn map_res<TR, O2>(self, map: TR) -> MapRes<Self, O, TR, O2>
where TR: Fn(O) -> Result<O2, Err<E>>,

Map the output.

Source

fn parse_from_str<C, O2>(self, code: C) -> FromStrParser<Self, C, O, O2>
where C: Code, O: InputIter<Item = char>, O2: FromStr, E: KParseError<C, I>,

Convert the output with the FromStr trait.

Source

fn value<O2>(self, value: O2) -> Value<Self, O, O2>
where O2: Clone,

Replace the output with the value.

Source

fn all_consuming<C>(self, code: C) -> AllConsuming<Self, C>
where C: Code, I: InputLength, E: KParseError<C, I>,

Fails if not everything has been processed.

Source

fn complete<C>(self, code: C) -> Complete<Self, C>
where C: Code, I: Clone, E: KParseError<C, I>,

Converts nom::Err::Incomplete to a error code.

Source

fn cut(self) -> Cut<Self>

Convert from nom::Err::Error to nom::Err::Failure

Source

fn opt(self) -> Optional<Self>

Optional parser.

Source

fn recognize(self) -> Recognize<Self, O>
where I: Clone + Slice<RangeTo<usize>> + Offset,

Run the parser and return the parsed input.

Source

fn consumed(self) -> Consumed<Self>
where I: Clone + Slice<RangeTo<usize>> + Offset,

Run the parser and return the parser output and the parsed input.

Source

fn terminated<PA, O2>(self, terminator: PA) -> Terminated<Self, PA, O2>
where PA: Parser<I, O2, E>,

Runs the parser and the terminator and just returns the result of the parser.

Source

fn precedes<PA, O2>(self, successor: PA) -> Precedes<Self, PA, O>
where PA: Parser<I, O2, E>,

Runs the parser and the successor and only returns the result of the successor.

Source

fn opt_precedes<PA, O2>(self, successor: PA) -> OptPrecedes<Self, PA, O>
where PA: Parser<I, O2, E>, I: Clone,

Runs the parser and the successor and returns the result of the successor. The parser itself may fail too.

Source

fn delimited_by<PA, O2>(self, delimiter: PA) -> DelimitedBy<Self, PA, O2>
where PA: Parser<I, O2, E>,

Runs the delimiter before and after the main parser, and returns just the result of the main parser.

Source

fn peek(self) -> Peek<Self>
where I: Clone,

Runs the parser but doesn’t change the input.

Source

fn not<C>(self, code: C) -> PNot<Self, C, O>
where C: Code, E: KParseError<C, I>, I: Clone,

Fails if the parser succeeds and vice versa.

Source

fn or_else<PE, OE>(self, other: PE) -> OrElse<Self, PE, OE>
where PE: Parser<I, OE, E>,

Or. Returns a (Option<A>, Option<B>)

Source

fn verify<V, C, O2>(self, verify: V, code: C) -> Verify<Self, V, C, O2>
where C: Code, V: Fn(&O2) -> bool, O: Borrow<O2>, O2: ?Sized, E: KParseError<C, I>,

Runs a verify function on the parser result.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§

Source§

impl<T, I, O, E> KParser<I, O, E> for T
where T: Parser<I, O, E>,