Struct rushell_deps_pom::parser::Parser[][src]

pub struct Parser<'a, I: Sized, O> {
    pub method: Box<dyn Fn(Arc<dyn Input<I>>, usize) -> Result<(O, usize)> + Sync + Send + 'a>,
}

Parser combinator.

Fields

method: Box<dyn Fn(Arc<dyn Input<I>>, usize) -> Result<(O, usize)> + Sync + Send + 'a>

Implementations

impl<'a, I: Send, O: Send> Parser<'a, I, O>[src]

pub fn new<P>(parse: P) -> Parser<'a, I, O> where
    P: Fn(Arc<dyn Input<I>>, usize) -> Result<(O, usize)> + 'a + Sync + Send
[src]

Create new parser.

pub fn parse(&self, input: Arc<dyn Input<I>>) -> Result<O>[src]

Apply the parser to parse input.

pub fn parse_at(
    &self,
    input: Arc<dyn Input<I>>,
    start: usize
) -> Result<(O, usize)>
[src]

Parse input at specified position.

pub fn map<U, F>(self, f: F) -> Parser<'a, I, U> where
    F: Fn(O) -> U + 'a + Sync + Send,
    I: 'a,
    O: 'a,
    U: Send
[src]

Convert parser result to desired value.

pub fn map_collect<U, F>(self, f: F) -> Parser<'a, I, U> where
    F: Fn(O, Vec<I>) -> U + 'a + Sync + Send,
    O: 'a,
    I: 'a,
    U: Send
[src]

Convert parser result to desired value. Matched slice is also delivered.

pub fn custom_parser<U, F>(self, f: F) -> Parser<'a, I, U> where
    F: Fn(O, Arc<dyn Input<I>>, usize) -> Result<(U, usize)> + 'a + Sync + Send,
    I: 'a,
    O: 'a,
    U: Send
[src]

pub fn log(self, message: &'a str) -> Parser<'a, I, O> where
    I: 'a,
    O: 'a + Debug
[src]

pub fn convert<U, E, F>(self, f: F) -> Parser<'a, I, U> where
    F: Fn(O) -> Result<U, E> + 'a + Sync + Send,
    E: Debug,
    I: 'a,
    O: 'a,
    U: Send
[src]

Convert parser result to desired value, fail in case of conversion error.

pub fn pos(self) -> Parser<'a, I, usize> where
    I: 'a,
    O: 'a, 
[src]

Cache parser output result to speed up backtracking. Get input position after matching parser.

pub fn range(self) -> Parser<'a, I, (usize, usize)> where
    I: 'a,
    O: 'a, 
[src]

pub fn collect(self) -> Parser<'a, I, Vec<I>> where
    I: 'a + Clone,
    O: 'a, 
[src]

Collect all matched input symbols.

pub fn discard(self) -> Parser<'a, I, ()> where
    I: 'a,
    O: 'a, 
[src]

Discard parser output.

pub fn opt(self) -> Parser<'a, I, Option<O>> where
    I: 'a,
    O: 'a, 
[src]

Make parser optional.

pub fn repeat<R>(self, range: R) -> Parser<'a, I, Vec<O>> where
    R: RangeArgument<usize> + Debug + 'a + Sync + Send,
    O: 'a,
    I: 'a, 
[src]

p.repeat(5) repeat p exactly 5 times p.repeat(0..) repeat p zero or more times p.repeat(1..) repeat p one or more times p.repeat(1..4) match p at least 1 and at most 3 times

pub fn name(self, name: &'a str) -> Parser<'a, I, O> where
    O: 'a,
    I: 'a, 
[src]

Give parser a name to identify parsing errors.

pub fn expect(self, name: &'a str) -> Parser<'a, I, O> where
    O: 'a,
    I: 'a, 
[src]

Mark parser as expected, abort early when failed in ordered choice.

Trait Implementations

impl<'a, I: 'a + Send, O: 'a + Send, U: 'a + Send> Add<Parser<'a, I, U>> for Parser<'a, I, O>[src]

Sequence reserve value

type Output = Parser<'a, I, (O, U)>

The resulting type after applying the + operator.

fn add(self, other: Parser<'a, I, U>) -> Self::Output[src]

Performs the + operation. Read more

impl<'a, I: 'a + Send, O: 'a + Send> BitOr<Parser<'a, I, O>> for Parser<'a, I, O>[src]

Ordered choice

type Output = Parser<'a, I, O>

The resulting type after applying the | operator.

fn bitor(self, other: Parser<'a, I, O>) -> Self::Output[src]

Performs the | operation. Read more

impl<'a, I: 'a + Send, O: 'a, U: 'a + Send> Mul<Parser<'a, I, U>> for Parser<'a, I, O>[src]

Sequence discard first value

type Output = Parser<'a, I, U>

The resulting type after applying the * operator.

fn mul(self, other: Parser<'a, I, U>) -> Self::Output[src]

Performs the * operation. Read more

impl<'a, I: 'a + Send, O: 'a> Neg for Parser<'a, I, O>[src]

And predicate

type Output = Parser<'a, I, bool>

The resulting type after applying the - operator.

fn neg(self) -> Self::Output[src]

Performs the unary - operation. Read more

impl<'a, I: 'a + Send, O: 'a> Not for Parser<'a, I, O>[src]

Not predicate

type Output = Parser<'a, I, bool>

The resulting type after applying the ! operator.

fn not(self) -> Self::Output[src]

Performs the unary ! operation. Read more

impl<'a, I: 'a + Send, O: 'a, U: Send, F: 'a + Fn(O) -> Parser<'a, I, U> + Sync + Send> Shr<F> for Parser<'a, I, O>[src]

Chain two parsers where the second parser depends on the first’s result.

type Output = Parser<'a, I, U>

The resulting type after applying the >> operator.

fn shr(self, other: F) -> Self::Output[src]

Performs the >> operation. Read more

impl<'a, I: 'a + Send, O: 'a + Send, U: 'a> Sub<Parser<'a, I, U>> for Parser<'a, I, O>[src]

Sequence discard second value

type Output = Parser<'a, I, O>

The resulting type after applying the - operator.

fn sub(self, other: Parser<'a, I, U>) -> Self::Output[src]

Performs the - operation. Read more

Auto Trait Implementations

impl<'a, I, O> !RefUnwindSafe for Parser<'a, I, O>

impl<'a, I, O> Send for Parser<'a, I, O>

impl<'a, I, O> Sync for Parser<'a, I, O>

impl<'a, I, O> Unpin for Parser<'a, I, O>

impl<'a, I, O> !UnwindSafe for Parser<'a, I, O>

Blanket Implementations

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

pub fn type_id(&self) -> TypeId[src]

Gets the TypeId of self. Read more

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

pub fn borrow(&self) -> &T[src]

Immutably borrows from an owned value. Read more

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

pub fn borrow_mut(&mut self) -> &mut T[src]

Mutably borrows from an owned value. Read more

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

pub fn from(t: T) -> T[src]

Performs the conversion.

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

pub fn into(self) -> U[src]

Performs the conversion.

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.

pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>[src]

Performs the conversion.

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.

pub fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>[src]

Performs the conversion.