[][src]Struct pahs::ParseDriver

pub struct ParseDriver<S = ()> {
    pub state: S,
}

Maintains (optional) parsing state/context and serves as an easy entry point for some of the combinators.

Fields

state: S

The parser state

Implementations

impl ParseDriver<()>[src]

pub fn new() -> Self[src]

Creates a new ParseDriver without state.

impl<S> ParseDriver<S>[src]

pub fn with_state(state: S) -> Self[src]

Creates a new ParseDriver with state as initial state.

pub fn optional<P, T, E, F>(
    &mut self,
    pos: P,
    parser: F
) -> Progress<P, Option<T>, E> where
    P: Pos,
    E: Recoverable,
    F: FnOnce(&mut ParseDriver<S>, P) -> Progress<P, T, E>, 
[src]

Wraps the specified parser, making it optional.

If parser was successful, the value is mapped to Some(value). Recoverable failures are mapped to successes, with None as value. Irrecoverable failures stay that way.

pub fn alternate<P, T, E>(
    &mut self,
    pos: P
) -> Alternate<'_, P, T, E, S, LastErrorOnly<E>> where
    P: Pos,
    E: Recoverable
[src]

Tries all parsers supplied via one, in order, until one matches.

If none of the parsers were successful, returns the error of the last run parser. If you want to retrieve the errors of the other parsers as well, see alternate_accumulate_errors.

See Alternate.

pub fn alternate_accumulate_errors<P, T, E, A>(
    &mut self,
    pos: P,
    error_accumulator: A
) -> Alternate<'_, P, T, E, S, A> where
    P: Pos,
    E: Recoverable,
    A: ErrorAccumulator<P, E>, 
[src]

Tries all parsers supplied via one, in order, until one matches, accumulating errors of all failed parsers.

If none of the parsers were successful, returns the error accumulated by the error_accumulator.

See Alternate.

Trait Implementations

impl<S: Debug> Debug for ParseDriver<S>[src]

impl Default for ParseDriver<()>[src]

Auto Trait Implementations

impl<S> RefUnwindSafe for ParseDriver<S> where
    S: RefUnwindSafe
[src]

impl<S> Send for ParseDriver<S> where
    S: Send
[src]

impl<S> Sync for ParseDriver<S> where
    S: Sync
[src]

impl<S> Unpin for ParseDriver<S> where
    S: Unpin
[src]

impl<S> UnwindSafe for ParseDriver<S> where
    S: UnwindSafe
[src]

Blanket Implementations

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

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

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

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

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

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

type Error = Infallible

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.