1 2 3 4 5 6 7 8 9 10 11 12 13
macro_rules! dispatch { ($match_parser: expr; $( $pat:pat $(if $pred:expr)? => $expr: expr ),+ $(,)? ) => { move |i| { let (i, initial) = $match_parser.parse(i)?; match initial { $( $pat $(if $pred)? => $expr.parse(i), )* } } } }