Type Definition lip::BoxedParser

source ·
pub type BoxedParser<'a, A, S> = Box<dyn FnMut(&'a str, Location, S) -> ParseResult<'a, A, S> + 'a>;

Trait Implementations§

source§

impl<'a, A, S: Clone + 'a> Parser<'a> for BoxedParser<'a, A, S>

§

type Output = A

§

type State = S

source§

fn parse( &mut self, input: &'a str, location: Location, state: S ) -> ParseResult<'a, A, S>

Parse a given input, starting at a given location and state.
source§

fn run( &mut self, input: &'a str, state: Self::State ) -> ParseResult<'a, Self::Output, Self::State>

Run the parser on a given input, starting at the first character. Read more
source§

fn map<F, NewOutput: 'a>(self, map_fn: F) -> Map<Self, F>where Self: Sized + 'a, F: Fn(Self::Output) -> NewOutput + 'a,

Map the output to a new output if parse succeeds. Otherwise, return error as usual. Read more
source§

fn map_with_state<F, NewOutput: 'a>(self, map_fn: F) -> MapWithState<Self, F>where Self: Sized + 'a, F: Fn(Self::Output, Self::State) -> NewOutput + 'a,

The map function is supplied both the output and the state of the parser. Otherwise, return error as usual. Read more
source§

fn map_err<F>(self, map_fn: F) -> MapErr<Self, F>where Self: Sized + 'a, F: Fn(String) -> String,

Map the error message to a new message if parse fails. Otherwise, return output as usual. Read more
source§

fn and_then<F, P2, B>(self, f: F) -> AndThen<Self, F>where Self: Sized + 'a, P2: Parser<'a, Output = B>, F: Fn(Self::Output) -> P2,

Returns a new parser which is given the current output if parse succeeds. Otherwise, return error as usual. Read more
source§

fn pred<F>(self, predicate: F, expecting: &'a str) -> Pred<'_, Self, F>where Self: Sized + 'a, F: Fn(&Self::Output) -> bool,

Judge if the output meets the requirement using a predicate function if the parse succeeds. Otherwise, return error as usual.
source§

fn ignore(self) -> Ignore<Self>where Self: Sized + 'a,

Ignore the parse output and return () (emtpy tuple)
source§

fn update_state<F>(self, f: F) -> UpdateState<Self, F>where Self: Sized + 'a, F: Fn(Self::Output, Self::State) -> Self::State,

Update the state given the new output and state of the parse if parse succeeds. Otherwise, return error as usual.
source§

fn update<B, F>(self, f: F) -> Update<Self, F>where Self: Sized + 'a, F: FnOnce(&'a str, Self::Output, Location, Self::State) -> ParseResult<'a, B, Self::State> + Clone,

Update the result of the parser if parse succeeds. Otherwise, return error as usual. Read more
source§

fn end(self) -> End<Self>where Self: Sized + 'a,

Check if you have reached the end of the input you are parsing. Read more
source§

fn skip<P2>(self, ignored_parser: P2) -> Skip<Self, P2>where Self: Sized + 'a, P2: Parser<'a>,

Skip values in a parser pipeline. Read more
source§

fn backtrackable(self) -> Backtrackable<Self>where Self: Sized + 'a,

source§

fn first_of_two<T2>(self) -> OneOfTwo<Self, T2>where Self: Sized + 'a, T2: Parser<'a, Output = Self::Output, State = Self::State>,

source§

fn second_of_two<T1>(self) -> OneOfTwo<T1, Self>where Self: Sized + 'a, T1: Parser<'a, Output = Self::Output, State = Self::State>,

source§

fn first_of_three<T2, T3>(self) -> OneOfThree<Self, T2, T3>where Self: Sized + 'a, T2: Parser<'a, Output = Self::Output, State = Self::State>, T3: Parser<'a, Output = Self::Output, State = Self::State>,

source§

fn second_of_three<T1, T3>(self) -> OneOfThree<T1, Self, T3>where Self: Sized + 'a, T1: Parser<'a, Output = Self::Output, State = Self::State>, T3: Parser<'a, Output = Self::Output, State = Self::State>,

source§

fn third_of_three<T1, T2>(self) -> OneOfThree<T1, T2, Self>where Self: Sized + 'a, T1: Parser<'a, Output = Self::Output, State = Self::State>, T2: Parser<'a, Output = Self::Output, State = Self::State>,