PEG parser combinators using operator overloading without macros.
Expose the method field in Parser to allow custom combinators
Input symbol's trait bounds change Copy
to Clone
.
pub struct Parser<'a, I, O> {
method: Box<Fn(&mut Input<I>) -> Result<O> + 'a>,
}
to
pub struct Parser<'a, I, O> {
method: Box<Fn(&'a [I], usize) -> Result<(O, usize)> + 'a>,
}
This is like 2.0 version, but avoids potential issue such as #23.
p.many(range)
, like p.repeat(range) but return slice instead of vector.p.cache()
, can be used to remember parser output result in case of potential backtracking.p.repeat(n)
repeat p exactly n times.Thanks for Jeremy Fitzhardinge's contribution.