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§
sourcefn err_into<E2>(self) -> IntoErr<Self, O, E, E2>where
E: Into<E2>,
fn err_into<E2>(self) -> IntoErr<Self, O, E, E2>where E: Into<E2>,
Converts the error to the target error.
sourcefn with_code<C>(self, code: C) -> WithCode<Self, C>where
C: Code,
E: KParseError<C, I>,
fn with_code<C>(self, code: C) -> WithCode<Self, C>where C: Code, E: KParseError<C, I>,
Changes the error code.
sourcefn 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 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.
sourcefn map_res<TR, O2>(self, map: TR) -> MapRes<Self, O, TR, O2>where
TR: Fn(O) -> Result<O2, Err<E>>,
fn map_res<TR, O2>(self, map: TR) -> MapRes<Self, O, TR, O2>where TR: Fn(O) -> Result<O2, Err<E>>,
Map the output.
sourcefn 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 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.
sourcefn value<O2>(self, value: O2) -> Value<Self, O, O2>where
O2: Clone,
fn value<O2>(self, value: O2) -> Value<Self, O, O2>where O2: Clone,
Replace the output with the value.
sourcefn all_consuming<C>(self, code: C) -> AllConsuming<Self, C>where
C: Code,
I: InputLength,
E: KParseError<C, I>,
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.
sourcefn complete<C>(self, code: C) -> Complete<Self, C>where
C: Code,
I: Clone,
E: KParseError<C, I>,
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.
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,
Run the parser and return the parsed input.
sourcefn consumed(self) -> Consumed<Self>where
I: Clone + Slice<RangeTo<usize>> + Offset,
fn consumed(self) -> Consumed<Self>where I: Clone + Slice<RangeTo<usize>> + Offset,
Run the parser and return the parser output and the parsed input.
sourcefn terminated<PA, O2>(self, terminator: PA) -> Terminated<Self, PA, O2>where
PA: Parser<I, O2, E>,
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.
sourcefn precedes<PA, O2>(self, successor: PA) -> Precedes<Self, PA, O>where
PA: Parser<I, O2, E>,
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.
sourcefn opt_precedes<PA, O2>(self, successor: PA) -> OptPrecedes<Self, PA, O>where
PA: Parser<I, O2, E>,
I: Clone,
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.
sourcefn delimited_by<PA, O2>(self, delimiter: PA) -> DelimitedBy<Self, PA, O2>where
PA: Parser<I, O2, E>,
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.
sourcefn not<C>(self, code: C) -> PNot<Self, C, O>where
C: Code,
E: KParseError<C, I>,
I: Clone,
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.