mpl_macro/lib.rs
1mod generator;
2mod mplg;
3
4use proc_macro::TokenStream;
5
6/// This macro creates
7/// let ident = parser_ident.replace("Parser", "");
8/// `{ident}Variable` enum,
9/// `{ident}Rules` const {variable_i_ident}_RULE for each rule,
10/// and impl Parser for `{parser_ident}`.
11///
12/// # Examples
13///
14/// ``` ignore
15/// use mpl_macro::Parse;
16///
17/// #[derive(Parse)]
18/// #[mplg = "{your path}/my.mplg"]
19/// pub struct MyParser;
20/// ```
21#[proc_macro_derive(Parse, attributes(mplg))]
22pub fn derive_parse(input: TokenStream) -> TokenStream {
23 generator::derive_parser(input.into()).into()
24}