[][src]Trait kombi::Parser

pub trait Parser<Iter> where
    Self: Sized,
    Iter: Iterator + Clone
{ type Output; fn parse(&self, i: Iter) -> Option<(Iter, Self::Output)>; fn many(self) -> Many<Iter, Self> { ... }
fn maybe(self) -> Maybe<Iter, Self> { ... }
fn or<Other: Parser<Iter>>(self, other: Other) -> Or<Iter, Self, Other> { ... }
fn then<Other: Parser<Iter>>(self, other: Other) -> Then<Iter, Self, Other> { ... }
fn transform<F: Fn(Self::Output) -> Option<T>, T>(
        self,
        f: F
    ) -> Transform<Iter, Self, F, T> { ... } }

Associated Types

type Output

Loading content...

Required methods

fn parse(&self, i: Iter) -> Option<(Iter, Self::Output)>

Tries to parse the provided Iterator. Returns the unparsed rest of the data and a value on success.

Loading content...

Provided methods

fn many(self) -> Many<Iter, Self>

Runs the Parser repeatedly until it fails. The results are stored in a Vec.

fn maybe(self) -> Maybe<Iter, Self>

Make the Parser optional, so that it will succeed even if it fails.

fn or<Other: Parser<Iter>>(self, other: Other) -> Or<Iter, Self, Other>

Require that either this or the provided Parser succeed. If both succeed, the one that has consumed the most bytes will be chosen.

fn then<Other: Parser<Iter>>(self, other: Other) -> Then<Iter, Self, Other>

Chain two Parsers together, requiring both to succeed.

fn transform<F: Fn(Self::Output) -> Option<T>, T>(
    self,
    f: F
) -> Transform<Iter, Self, F, T>

Apply the provided function to the Output of this Parser.

Loading content...

Implementations on Foreign Types

impl<Iter> Parser<Iter> for char where
    Iter: Iterator<Item = char> + Clone
[src]

Matches for a character.

type Output = char

impl<'a, Iter> Parser<Iter> for &'a str where
    Iter: Iterator<Item = char> + Clone
[src]

Matches for a string.

type Output = &'a str

impl<Iter> Parser<Iter> for () where
    Iter: Iterator + Clone
[src]

() ensures that there is no remaining data.

type Output = ()

Loading content...

Implementors

impl<Iter> Parser<Iter> for NaturalNumber where
    Iter: Iterator<Item = char> + Clone
[src]

type Output = u128

impl<Iter, A> Parser<Iter> for Many<Iter, A> where
    Iter: Iterator + Clone,
    A: Parser<Iter>, 
[src]

type Output = Vec<A::Output>

impl<Iter, A> Parser<Iter> for Maybe<Iter, A> where
    Iter: Iterator + Clone,
    A: Parser<Iter>, 
[src]

type Output = Option<A::Output>

impl<Iter, A, B> Parser<Iter> for Or<Iter, A, B> where
    Iter: Iterator + Clone,
    A: Parser<Iter>,
    B: Parser<Iter>, 
[src]

type Output = Either<A::Output, B::Output>

impl<Iter, A, B> Parser<Iter> for Then<Iter, A, B> where
    Iter: Iterator + Clone,
    A: Parser<Iter>,
    B: Parser<Iter>, 
[src]

type Output = (A::Output, B::Output)

impl<Iter, A, F, T> Parser<Iter> for Transform<Iter, A, F, T> where
    Iter: Iterator + Clone,
    A: Parser<Iter>,
    F: Fn(A::Output) -> Option<T>, 
[src]

type Output = T

impl<Iter, F, T> Parser<Iter> for F where
    Iter: Iterator + Clone,
    F: Fn(Iter) -> Option<(Iter, T)>, 
[src]

type Output = T

Loading content...