Trait kparse::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.

Object Safety§

This trait is not object safe.

Implementors§

source§

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