combine_proc_macro/
boilerplate.rs

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