Function combine::chainr1 [] [src]

pub fn chainr1<P, Op>(parser: P, op: Op) -> Chainr1<P, Op> where P: Parser,
        Op: Parser<Input=P::Input>,
        Op::Output: FnOnce(P::Output, P::Output) -> P::Output

Parses p one or more times separated by op. The value returned is the one produced by the right associative application of the function returned by op.

let number = digit().map(|c: char| c.to_digit(10).unwrap());
let pow = token('^').map(|_| |l: u32, r: u32| l.pow(r));
let mut parser = chainr1(number, pow);
    assert_eq!(parser.parse("2^3^2"), Ok((512, "")));
}