[−][src]Struct parze::Parser
A type that represents a rule that may be used to parse a list of symbols.
Parsers may be combined and manipulated in various ways to create new parsers.
Methods
impl<'a, T: Clone + 'a, O: 'a, E: ParseError<'a, T> + 'a> Parser<'a, T, O, E>
[src]
pub fn link(&self) -> Self
[src]
pub fn map<U: 'a>(self, f: impl Fn(O) -> U + 'a) -> Parser<'a, T, U, E>
[src]
Map the output of this parser to another value with the given function.
pub fn map_err<G: ParseError<'a, T> + 'a>(
self,
f: impl Fn(E) -> G + 'a
) -> Parser<'a, T, O, G>
[src]
self,
f: impl Fn(E) -> G + 'a
) -> Parser<'a, T, O, G>
Map the error of this parser to another with the given function.
This may be used to annotate an error with contextual information at some stage of parsing.
pub fn discard(self) -> Parser<'a, T, (), E>
[src]
Discard the output of this parser (i.e: create a parser that outputs ()
instead).
pub fn to<U: Clone + 'a>(self, to: U) -> Parser<'a, T, U, E>
[src]
Map all outputs of this parser to the given value.
pub fn or_not(self) -> Parser<'a, T, Option<O>, E>
[src]
Create a parser that optionally parses symbols that match this parser.
pub fn then<U: 'a>(self, other: Parser<'a, T, U, E>) -> Parser<'a, T, (O, U), E>
[src]
Create a parser that parses symbols that match this parser and then another parser.
pub fn also<U: 'a>(
self,
other: Parser<'a, T, U, E>
) -> Parser<'a, T, O::Alsoed, E> where
O: Also<U>,
[src]
self,
other: Parser<'a, T, U, E>
) -> Parser<'a, T, O::Alsoed, E> where
O: Also<U>,
Create a parser that parses symbols that match this parser and then another parser.
Whereas .then
turns outputs of (T, U)
and V
into ((T, U), V)
, this method turns them into (T, U, V)
.
Due to current limitations in Rust's type system, this method is significantly less useful than it could be.
pub fn chain<U: 'a>(
self,
other: Parser<'a, T, U, E>
) -> Parser<'a, T, O::Chained, E> where
O: Chain<U>,
[src]
self,
other: Parser<'a, T, U, E>
) -> Parser<'a, T, O::Chained, E> where
O: Chain<U>,
Create a parser that parses symbols that match this parser and then another parser.
Unlike .then
, this method will chain the two parser outputs together as a vector.
pub fn delimiter_for<U: 'a>(
self,
other: Parser<'a, T, U, E>
) -> Parser<'a, T, U, E>
[src]
self,
other: Parser<'a, T, U, E>
) -> Parser<'a, T, U, E>
Create a parser that parses symbols that match this parser and then another parser, discarding the output of this parser.
pub fn delimited_by<U: 'a>(self, other: Parser<'a, T, U, E>) -> Self
[src]
Create a parser that parses symbols that match this parser and then another parser, discarding the output of the other parser.
pub fn padded_by(self, padding: impl Borrow<T> + 'a) -> Self where
T: PartialEq,
[src]
T: PartialEq,
Create a parser that parses symbols that match this parser followed by any number of the given symbol.
pub fn padded(self) -> Self where
T: Borrow<char>,
[src]
T: Borrow<char>,
Create a parser that parses character-like symbols that match this parser followed by any number of whitespace symbols.
pub fn or(self, other: Parser<'a, T, O, E>) -> Self
[src]
Create a parser that parses symbols that match this parser or another parser.
pub fn or_fallback(self, other: Parser<'a, T, O, E>) -> Self
[src]
Create a parser that parses symbols that match this parser or another fallback parser, prioritising errors from this parser.
This method is 'short-circuiting': if this parser succeeds, the fallback parser won't even be invoked. This means that emitted errors may not include information from the fallback parser.
pub fn repeat(self, repeat: impl Into<Repeat>) -> Parser<'a, T, Vec<O>, E>
[src]
Create a parser that parses symbols that match this parser multiple times, according to the given repetition rule.
pub fn collect<U: FromIterator<O::Item>>(self) -> Parser<'a, T, U, E> where
O: IntoIterator,
[src]
O: IntoIterator,
Create a parser that parses symbols that match this parser and then another parser.
pub fn reduce_left<A, B>(
self,
f: impl Fn(B, A) -> A + 'a
) -> Parser<'a, T, A, E> where
O: ReduceLeft<A, B>,
[src]
self,
f: impl Fn(B, A) -> A + 'a
) -> Parser<'a, T, A, E> where
O: ReduceLeft<A, B>,
Create a parser that left-reduces this parser down into another type according to the given reduction function.
pub fn reduce_right<A, B>(
self,
f: impl Fn(A, B) -> A + 'a
) -> Parser<'a, T, A, E> where
O: ReduceRight<A, B>,
[src]
self,
f: impl Fn(A, B) -> A + 'a
) -> Parser<'a, T, A, E> where
O: ReduceRight<A, B>,
Create a parser that right-reduces this parser down into another type according to the given reduction function.
pub fn parse(&self, tokens: impl AsRef<[T]>) -> Result<O, E>
[src]
Attempt to parse an array-like list of symbols using this parser.
Trait Implementations
impl<'a, T: Clone + 'a, O: 'a, E: ParseError<'a, T> + 'a> Clone for Parser<'a, T, O, E>
[src]
fn clone(&self) -> Self
[src]
fn clone_from(&mut self, source: &Self)
1.0.0[src]
Auto Trait Implementations
impl<'a, T, O = T, E = DefaultParseError<T>> !Send for Parser<'a, T, O, E>
impl<'a, T, O = T, E = DefaultParseError<T>> !Sync for Parser<'a, T, O, E>
impl<'a, T, O, E> Unpin for Parser<'a, T, O, E>
impl<'a, T, O = T, E = DefaultParseError<T>> !UnwindSafe for Parser<'a, T, O, E>
impl<'a, T, O = T, E = DefaultParseError<T>> !RefUnwindSafe for Parser<'a, T, O, E>
Blanket Implementations
impl<T> Chain<Vec<T>> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> From<T> for T
[src]
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
fn to_owned(&self) -> T
[src]
fn clone_into(&self, target: &mut T)
[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,