[][src]Struct parze::Parser

pub struct Parser<'a, T, O = T, E = DefaultParseError<T>, F = RcParseFn<'a, T, O, E>> where
    T: Clone + 'a,
    O: 'a,
    E: ParseError<T> + 'a,
    F: ParseFn<T, O, E> + 'a, 
{ /* fields omitted */ }

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<T> + 'a, F: ParseFn<T, O, E> + 'a> Parser<'a, T, O, E, F>[src]

pub fn to_object(&self) -> Parser<'a, T, O, E>[src]

Convert this parser into one with a standard payload that may be accepted by more functions

Undocumented

pub fn map<'b, U: 'a>(
    self,
    f: impl Fn(O) -> U + Clone + 'a
) -> Parser<'a, T, U, E, impl ParseFn<T, U, E> + Captures<'b> + 'a> where
    'a: 'b,
    'b: 'a, 
[src]

Map the output of this parser to another value with the given function.

pub fn map_err<'b, G: ParseError<T> + 'a>(
    self,
    f: impl Fn(E) -> G + Clone + 'a
) -> Parser<'a, T, O, G, impl ParseFn<T, O, G> + Captures<'b> + 'a> where
    'a: 'b,
    'b: 'a, 
[src]

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<'b>(
    self
) -> Parser<'a, T, (), E, impl ParseFn<T, (), E> + Captures<'b> + 'a> where
    'a: 'b,
    'b: 'a, 
[src]

Discard the output of this parser (i.e: create a parser that outputs () instead).

pub fn to<'b, U: Clone + 'a>(
    self,
    to: U
) -> Parser<'a, T, U, E, impl ParseFn<T, U, E> + Captures<'b> + 'a> where
    'a: 'b,
    'b: 'a, 
[src]

Map all outputs of this parser to the given value.

pub fn or_not<'b>(
    self
) -> Parser<'a, T, Option<O>, E, impl ParseFn<T, Option<O>, E> + Captures<'b> + 'a> where
    'a: 'b,
    'b: 'a, 
[src]

Create a parser that optionally parses symbols that match this parser.

pub fn then<'b, U: 'b, G: ParseFn<T, U, E> + 'b>(
    self,
    other: Parser<'a, T, U, E, G>
) -> Parser<'a, T, (O, U), E, impl ParseFn<T, (O, U), E> + Captures<'b> + 'a> where
    'a: 'b,
    'b: 'a, 
[src]

Create a parser that parses symbols that match this parser and then another parser.

pub fn chained<'b>(
    self
) -> Parser<'a, T, Single<O>, E, impl ParseFn<T, Single<O>, E> + Captures<'b> + 'a> where
    'a: 'b,
    'b: 'a, 
[src]

Create a parser that parsers the same symbols as this parser, but emits its output as a vector

This is most useful when you wish to use singular outputs as part of a chain.

pub fn chain<'b, U: 'a, V: 'a, G: ParseFn<T, U, E> + 'a>(
    self,
    other: Parser<'a, T, U, E, G>
) -> Parser<'a, T, Vec<V>, E, impl ParseFn<T, Vec<V>, E> + Captures<'b> + 'a> where
    O: IntoChain<Item = V>,
    U: IntoChain<Item = V>,
    'a: 'b,
    'b: 'a, 
[src]

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 flatten<'b, U: 'a, V: 'a>(
    self
) -> Parser<'a, T, Vec<V>, E, impl ParseFn<T, Vec<V>, E> + Captures<'b> + 'a> where
    O: IntoChain<Item = U>,
    U: IntoChain<Item = V>,
    'a: 'b,
    'b: 'a, 
[src]

Create a parser that with a flatter output than this parser.

pub fn delimiter_for<'b, U: 'a>(
    self,
    other: Parser<'a, T, U, E, impl ParseFn<T, U, E>>
) -> Parser<'a, T, U, E, impl ParseFn<T, U, E> + Captures<'b> + 'a> where
    'a: 'b,
    'b: 'a, 
[src]

Create a parser that parses symbols that match this parser and then another parser, discarding the output of this parser.

pub fn delimited_by<'b, U: 'a>(
    self,
    other: Parser<'a, T, U, E, impl ParseFn<T, U, E>>
) -> Parser<'a, T, O, E, impl ParseFn<T, O, E> + Captures<'b> + 'a> where
    'a: 'b,
    'b: 'a, 
[src]

Create a parser that parses symbols that match this parser and then another parser, discarding the output of the other parser.

pub fn separated_by<'b, U: 'a>(
    self,
    other: Parser<'a, T, U, E, impl ParseFn<T, U, E>>
) -> Parser<'a, T, Vec<O>, E, impl ParseFn<T, Vec<O>, E> + Captures<'b> + 'a> where
    'a: 'b,
    'b: 'a, 
[src]

Create a parser that accepts the valid input of this parser separated by the valid input of another.

pub fn padded<'b, U: Padded>(
    self
) -> Parser<'a, T, O, E, impl ParseFn<T, O, E> + Captures<'b> + 'a> where
    T: Borrow<U>,
    'a: 'b,
    'b: 'a, 
[src]

Create a parser that parses character-like symbols that match this parser followed or preceded by any number of 'padding' (usually taken to mean whitespace) symbols.

You can implement the Padded trait for your own symbol types to use this method with them.

pub fn before_padding<'b, U: Padded>(
    self
) -> Parser<'a, T, O, E, impl ParseFn<T, O, E> + Captures<'b> + 'a> where
    T: Borrow<U>,
    'a: 'b,
    'b: 'a, 
[src]

Create a parser that parses any symbols that match this parser followed by any number of 'padding' (usually taken to mean whitespace) symbols.

You can implement the Padded trait for your own symbol types to use this method with them.

pub fn after_padding<'b, U: Padded>(
    self
) -> Parser<'a, T, O, E, impl ParseFn<T, O, E> + Captures<'b> + 'a> where
    T: Borrow<U>,
    'a: 'b,
    'b: 'a, 
[src]

Create a parser that parses any number of 'padding' (usually taken to mean whitespace) symbols followed by any symbols that match this parser.

You can implement the Padded trait for your own symbol types to use this method with them.

pub fn or<'b>(
    self,
    other: Parser<'b, T, O, E, impl ParseFn<T, O, E>>
) -> Parser<'b, T, O, E, impl ParseFn<T, O, E> + Captures<'b> + 'a> where
    'a: 'b,
    'b: 'a, 
[src]

Create a parser that parses symbols that match this parser or another parser.

pub fn or_chain<V: 'a, U: 'a, G: ParseFn<T, U, E>>(
    self,
    other: Parser<'a, T, U, E, G>
) -> Parser<'a, T, Vec<V>, E, OrChainFn<F, G, O, U>> where
    O: IntoChain<Item = V>,
    U: IntoChain<Item = V>, 
[src]

Create a parser that parses symbols that match this parser or another parser where both parsers are chains.

pub fn or_chain_fallback<V: 'a, U: 'a, G: ParseFn<T, U, E>>(
    self,
    other: Parser<'a, T, U, E, G>
) -> Parser<'a, T, Vec<V>, E, OrChainFallbackFn<F, G, O, U>> where
    O: IntoChain<Item = V>,
    U: IntoChain<Item = V>, 
[src]

Create a parser that parses symbols that match this parser or another fallback parser where both parsers are chains, 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 or_fallback<'b, G: ParseFn<T, O, E>>(
    self,
    other: Parser<'a, T, O, E, G>
) -> Parser<'b, T, O, E, impl ParseFn<T, O, E> + Captures<'b> + 'a> where
    'a: 'b,
    'b: 'a, 
[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<'b>(
    self,
    repeat: impl Into<Repeat>
) -> Parser<'a, T, Vec<O>, E, impl ParseFn<T, Vec<O>, E> + Captures<'b> + 'a> where
    'a: 'b,
    'b: 'a, 
[src]

Create a parser that parses symbols that match this parser multiple times, according to the given repetition rule.

pub fn collect<'b, U: FromIterator<O::Item>>(
    self
) -> Parser<'a, T, U, E, impl ParseFn<T, U, E> + Captures<'b> + 'a> where
    O: IntoIterator,
    'a: 'b,
    'b: 'a, 
[src]

Create a parser that parses symbols that match this parser and then another parser.

pub fn reduce_left<'b, A, B>(
    self,
    f: impl Fn(B, A) -> A + Clone + 'a
) -> Parser<'a, T, A, E, impl ParseFn<T, A, E> + Captures<'b> + 'a> where
    O: ReduceLeft<A, B>,
    'a: 'b,
    'b: 'a, 
[src]

Create a parser that left-reduces this parser down into another type according to the given reduction function.

pub fn reduce_right<'b, A, B>(
    self,
    f: impl Fn(A, B) -> A + Clone + 'a
) -> Parser<'a, T, A, E, impl ParseFn<T, A, E> + Captures<'b> + 'a> where
    O: ReduceRight<A, B>,
    'a: 'b,
    'b: 'a, 
[src]

Create a parser that right-reduces this parser down into another type according to the given reduction function.

pub fn parse(&self, tokens: &[T]) -> Result<O, E>[src]

Attempt to parse an array-like list of symbols using this parser.

impl<'a, O: 'a, E: ParseError<char> + 'a, F: ParseFn<char, O, E> + 'a> Parser<'a, char, O, E, F>[src]

pub fn parse_str(&self, string: impl AsRef<str>) -> Result<O, E>[src]

Attempt to parse a string using this parser.

Trait Implementations

impl<'a, T: Clone + 'a, O: 'a, E: ParseError<T> + 'a, F: ParseFn<T, O, E> + 'a> Clone for Parser<'a, T, O, E, F>[src]

Auto Trait Implementations

impl<'a, T, O, E, F> Send for Parser<'a, T, O, E, F> where
    E: Sync,
    F: Send,
    O: Sync,
    T: Sync

impl<'a, T, O, E, F> Sync for Parser<'a, T, O, E, F> where
    E: Sync,
    F: Sync,
    O: Sync,
    T: Sync

impl<'a, T, O, E, F> Unpin for Parser<'a, T, O, E, F> where
    F: Unpin

impl<'a, T, O, E, F> UnwindSafe for Parser<'a, T, O, E, F> where
    E: RefUnwindSafe,
    F: UnwindSafe,
    O: RefUnwindSafe,
    T: RefUnwindSafe

impl<'a, T, O, E, F> RefUnwindSafe for Parser<'a, T, O, E, F> where
    E: RefUnwindSafe,
    F: RefUnwindSafe,
    O: RefUnwindSafe,
    T: RefUnwindSafe

Blanket Implementations

impl<'a, T> Captures<'a> for T where
    T: ?Sized
[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> From<T> for T[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = !

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> Any for T where
    T: 'static + ?Sized
[src]