Struct pom::parser::Parser
[−]
[src]
pub struct Parser<'a, I, O> { /* fields omitted */ }
Parser combinator.
Methods
impl<'a, I, O> Parser<'a, I, O>
[src]
fn new<P>(parse: P) -> Parser<'a, I, O> where P: Fn(&mut Input<I>) -> Result<O> + 'a
Create new parser.
fn parse(&self, input: &mut Input<I>) -> Result<O>
Apply the parser to parse input.
fn map<U, F>(self, f: F) -> Parser<'a, I, U> where F: Fn(O) -> U + 'a, I: 'static, O: 'static, U: 'static
Convert parser result to desired value.
fn convert<U, E, F>(self, f: F) -> Parser<'a, I, U> where F: Fn(O) -> Result<U, E> + 'a,
E: Debug,
I: Copy + 'static,
O: 'static,
U: 'static
E: Debug,
I: Copy + 'static,
O: 'static,
U: 'static
Convert parser result to desired value, fail in case of conversion error.
fn pos(self) -> Parser<'a, I, usize> where I: Copy + 'static, O: 'static
Get input position after matching parser.
fn collect(self) -> Parser<'a, I, Vec<I>> where I: Copy + 'static, O: 'static
Collect all matched input symbols.
fn discard(self) -> Parser<'a, I, ()> where I: 'static, O: 'static
Discard parser output.
fn opt(self) -> Parser<'a, I, Option<O>> where I: 'static, O: 'static
Make parser optional.
fn repeat<R>(self, range: R) -> Parser<'a, I, Vec<O>> where R: RangeArgument<usize> + Debug + 'a, I: Copy + 'static, O: 'static
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
fn name(self, name: &'a str) -> Parser<'a, I, O> where I: Copy + 'static, O: 'static
Give parser a name to identify parsing errors.
Trait Implementations
impl<'b, 'a: 'b, I: Copy + 'static, O: 'static, U: 'static> Add<Parser<'b, I, U>> for Parser<'a, I, O>
[src]
Sequence reserve value
type Output = Parser<'b, I, (O, U)>
The resulting type after applying the +
operator
fn add(self, other: Parser<'b, I, U>) -> Self::Output
The method for the +
operator
impl<'a, 'b: 'a, I: Copy + 'static, O: 'static, U: 'static> Sub<Parser<'b, 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<'b, I, U>) -> Self::Output
The method for the -
operator
impl<'b, 'a: 'b, I: Copy + 'static, O: 'static, U: 'static> Mul<Parser<'b, I, U>> for Parser<'a, I, O>
[src]
Sequence discard first value
type Output = Parser<'b, I, U>
The resulting type after applying the *
operator
fn mul(self, other: Parser<'b, I, U>) -> Self::Output
The method for the *
operator
impl<'b, 'a: 'b, I: Copy + 'static, O: 'static, U: 'static, F: Fn(O) -> Parser<'b, I, U> + 'b> Shr<F> for Parser<'a, I, O>
[src]
Chain two passers where the second parser depends on the first's result.
type Output = Parser<'b, I, U>
The resulting type after applying the >>
operator
fn shr(self, other: F) -> Self::Output
The method for the >>
operator
impl<'a, I: 'static, O: 'static> BitOr 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
The method for the |
operator
impl<'a, I: Copy + 'static, O: 'static> 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
The method for the unary -
operator
impl<'a, I: Copy + 'static, O: 'static> Not for Parser<'a, I, O>
[src]
Not predicate