Function combine::chainl1[][src]

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

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

let number = digit().map(|c: char| c.to_digit(10).unwrap());
let sub = token('-').map(|_| |l: u32, r: u32| l - r);
let mut parser = chainl1(number, sub);
assert_eq!(parser.parse("9-3-5"), Ok((1, "")));