[][src]Trait gobble::ptrait::Parser

pub trait Parser: Sized {
    type Out;
    fn parse<'a>(&self, i: &LCChars<'a>) -> ParseRes<'a, Self::Out>;

    fn expected(&self) -> Expected { ... }
fn parse_s(&self, s: &str) -> Result<Self::Out, ParseError> { ... }
fn parse_sn<'a>(
        &self,
        s: &'a str
    ) -> Result<(&'a str, Self::Out), ParseError> { ... }
fn then<P: Parser<Out = V2>, V2>(self, b: P) -> Then<Self, P> { ... }
fn then_ig<P: Parser<Out = V2>, V2>(self, b: P) -> ThenIg<Self, P> { ... }
fn ig_then<P: Parser<Out = V2>, V2>(self, b: P) -> IgThen<Self, P> { ... }
fn or<P: Parser<Out = Self::Out>>(self, p: P) -> Or<Self, P> { ... }
fn map<F: Fn(Self::Out) -> V2, V2>(self, f: F) -> Map<Self, V2, F> { ... }
fn try_map<F: Fn(Self::Out) -> Result<V2, Expected>, V2>(
        self,
        f: F
    ) -> TryMap<Self, V2, F> { ... }
fn asv<R: Clone>(self, r: R) -> As<Self, R> { ... }
fn ig(self) -> As<Self, ()> { ... }
fn map_exp<F: Fn(Expected) -> Expected>(self, f: F) -> MapExp<Self, F> { ... }
fn brk(self) -> Break<Self> { ... } }

The core trait for parsing

Associated Types

type Out

Loading content...

Required methods

fn parse<'a>(&self, i: &LCChars<'a>) -> ParseRes<'a, Self::Out>

Loading content...

Provided methods

fn expected(&self) -> Expected

fn parse_s(&self, s: &str) -> Result<Self::Out, ParseError>

fn parse_sn<'a>(&self, s: &'a str) -> Result<(&'a str, Self::Out), ParseError>

fn then<P: Parser<Out = V2>, V2>(self, b: P) -> Then<Self, P>

returns a parser that will combine the results of this and the given parser into a tuple

fn then_ig<P: Parser<Out = V2>, V2>(self, b: P) -> ThenIg<Self, P>

returns a Parser that will require the given parser completes, but ignores its result useful for dropping brackets and whitespace

fn ig_then<P: Parser<Out = V2>, V2>(self, b: P) -> IgThen<Self, P>

returns a Parser that will require this parser completes, but only return the result of the given parser useful for dropping brackets and whitespace etc

fn or<P: Parser<Out = Self::Out>>(self, p: P) -> Or<Self, P>

Returns a Parser that will try both child parsers, (A first) and return the first successfl result

fn map<F: Fn(Self::Out) -> V2, V2>(self, f: F) -> Map<Self, V2, F>

Returns a Parser that converts the result of a successful parse to a different type. Much like map on iterators and Result

fn try_map<F: Fn(Self::Out) -> Result<V2, Expected>, V2>(
    self,
    f: F
) -> TryMap<Self, V2, F>

Returns a Parser that converts the result of a successful parse to a different type. however the map function can fail and return a result The Error type should be err::ECode, this does not have line associated. That will be attacked by the TryMap object so this will pass that error up correctly

fn asv<R: Clone>(self, r: R) -> As<Self, R>

fn ig(self) -> As<Self, ()>

fn map_exp<F: Fn(Expected) -> Expected>(self, f: F) -> MapExp<Self, F>

fn brk(self) -> Break<Self>

Loading content...

Implementations on Foreign Types

impl Parser for &'static str[src]

type Out = &'static str

impl Parser for char[src]

type Out = char

impl<A, B> Parser for (A, B) where
    A: Parser,
    B: Parser
[src]

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

impl<A, B, C> Parser for (A, B, C) where
    A: Parser,
    B: Parser,
    C: Parser
[src]

type Out = (A::Out, B::Out, C::Out)

impl<A, B, C, D> Parser for (A, B, C, D) where
    A: Parser,
    B: Parser,
    C: Parser,
    D: Parser
[src]

type Out = (A::Out, B::Out, C::Out, D::Out)

impl<A, B, C, D, E> Parser for (A, B, C, D, E) where
    A: Parser,
    B: Parser,
    C: Parser,
    D: Parser,
    E: Parser
[src]

type Out = (A::Out, B::Out, C::Out, D::Out, E::Out)

impl<A, B, C, D, E, F> Parser for (A, B, C, D, E, F) where
    A: Parser,
    B: Parser,
    C: Parser,
    D: Parser,
    E: Parser,
    F: Parser
[src]

type Out = (A::Out, B::Out, C::Out, D::Out, E::Out, F::Out)

Loading content...

Implementors

impl<A> Parser for Maybe<A> where
    A: Parser
[src]

type Out = Option<A::Out>

impl<A, B> Parser for Wrap<A, B> where
    A: Parser,
    B: Parser
[src]

type Out = B::Out

impl<A, B> Parser for IgThen<A, B> where
    A: Parser,
    B: Parser
[src]

type Out = B::Out

impl<A, B> Parser for Then<A, B> where
    A: Parser,
    B: Parser
[src]

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

impl<A, B> Parser for ThenIg<A, B> where
    A: Parser,
    B: Parser
[src]

type Out = A::Out

impl<A, B> Parser for SepPlus<A, B> where
    A: Parser,
    B: Parser
[src]

type Out = Vec<A::Out>

impl<A, B> Parser for SepStar<A, B> where
    A: Parser,
    B: Parser
[src]

type Out = Vec<A::Out>

impl<A, B> Parser for String2P<A, B> where
    A: Parser,
    B: Parser,
    A::Out: Into<String>,
    B::Out: AsRef<str>, 
[src]

type Out = String

impl<A, B, C> Parser for Reflect<A, B, C> where
    A: Parser,
    B: Parser,
    C: Parser
[src]

type Out = (Vec<A::Out>, B::Out, Vec<C::Out>)

impl<A, B, C> Parser for SepUntil<A, B, C> where
    A: Parser,
    B: Parser,
    C: Parser
[src]

type Out = Vec<A::Out>

impl<A, B, V> Parser for Or<A, B> where
    A: Parser<Out = V>,
    B: Parser<Out = V>, 
[src]

type Out = V

impl<A: CharBool> Parser for CharExact<A>[src]

type Out = String

impl<A: CharBool> Parser for CharMin<A>[src]

type Out = String

impl<A: Parser> Parser for Exact<A>[src]

type Out = Vec<A::Out>

impl<A: Parser> Parser for RepPlus<A>[src]

type Out = Vec<A::Out>

impl<A: Parser> Parser for RepStar<A>[src]

type Out = Vec<A::Out>

impl<A: Parser> Parser for PSkipExact<A>[src]

type Out = ()

impl<A: Parser> Parser for PSkipPlus<A>[src]

type Out = ()

impl<A: Parser> Parser for PSkipStar<A>[src]

type Out = ()

impl<A: Parser<Out = char>, B: Parser> Parser for CharsUntil<A, B>[src]

type Out = (String, B::Out)

impl<A: Parser<Out = AV>, AV, B, F: Fn(A::Out) -> B> Parser for Map<A, B, F>[src]

type Out = B

impl<A: Parser<Out = AV>, AV: Into<String> + AsRef<str>> Parser for StringRepeat<A, AV>[src]

type Out = String

impl<A: Parser, B, F: Fn(A::Out) -> Result<B, Expected>> Parser for TryMap<A, B, F>[src]

type Out = B

impl<A: Parser, B: Parser> Parser for RepUntil<A, B>[src]

type Out = (Vec<A::Out>, B::Out)

impl<A: Parser, R: Clone> Parser for As<A, R>[src]

type Out = R

impl<CB: CharBool> Parser for CharPlus<CB>[src]

type Out = String

impl<CB: CharBool> Parser for CharStar<CB>[src]

type Out = String

impl<CB: CharBool> Parser for OneChar<CB>[src]

type Out = char

impl<CB: CharBool> Parser for CharSkip<CB>[src]

type Out = ()

impl<CB: CharBool> Parser for CharSkipExact<CB>[src]

type Out = ()

impl<CB: CharBool> Parser for CharSkipPlus<CB>[src]

type Out = ()

impl<P: Parser> Parser for Break<P>[src]

type Out = P::Out

impl<P: Parser> Parser for KeyWord<P>[src]

type Out = P::Out

impl<P: Parser> Parser for PPos<P>[src]

type Out = Pos<P::Out>

impl<P: Parser> Parser for Peek<P>[src]

type Out = P::Out

impl<P: Parser<Out = V>, V: Debug> Parser for FailOn<P>[src]

type Out = ()

impl<P: Parser, F: Fn(Expected) -> Expected> Parser for MapExp<P, F>[src]

type Out = P::Out

impl<V, F: for<'a> Fn(&LCChars<'a>) -> ParseRes<'a, V>> Parser for F[src]

type Out = V

Loading content...