1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
#[macro_export]
/// A macro to remove the generics boilerplate when defining parsers.
macro_rules! parser {
    (fn $name:ident() -> $output:ty $block:block) => {
        pub fn $name<I>() -> impl ::combine::Parser<Input = I, Output = $output>
        where
            I: ::combine::Stream<Item = $crate::Token>,
            I::Error: ::combine::ParseError<I::Item, I::Range, I::Position>,
        {
            $block
        }
    };
    (fn $name:ident($input:ident: &mut Input) -> $output:ty $block:block) => {
        pub fn $name<I>($input: &mut I) -> ::combine::ParseResult<$output, I>
        where
            I: ::combine::Stream<Item = $crate::Token>,
            I::Error: ::combine::ParseError<I::Item, I::Range, I::Position>,
        {
            $block
        }
    };
}