xparse_macros/
lib.rs

1use proc_macro::TokenStream;
2use syn::{parse_macro_input, Error};
3
4mod exprs;
5mod parser;
6
7/**
8# parser macro
9
10This macro should only be attached onto type aliases when defining parsing rules or their components.
11The behaviour is expected to be like normal type aliases, but it fixes the compiler defects that fail to handle recursive type definitions and arbitary const generic types.
12
13This is used when:
14+ It contains recursive parser rules.
15+ It contains inline const arguments.
16
17## Usage
18```ignore
19#[parser]
20type MyRule = Some<Combinators>;
21```
22
23When dealing with recursive parser rules, input/output types should be specified:
24
25```ignore
26#[parser(Input, Output)]
27type MyRule = Some<Recursive<Combinators>>;
28```
29
30 */
31#[proc_macro_attribute]
32pub fn parser(args: TokenStream, input: TokenStream) -> TokenStream {
33    parser::handle(parse_macro_input!(input), parse_macro_input!(args))
34        .unwrap_or_else(Error::into_compile_error)
35        .into()
36}