aqua_parse_macro/lib.rs
1#![allow(unused_imports)]
2
3use proc_macro2::*;
4use syn::*;
5use quote::*;
6use syn::punctuated::Punctuated;
7use syn::spanned::Spanned;
8use syn::token::Comma;
9
10mod enum_helper;
11mod derive_helper;
12mod options;
13mod parameters;
14mod struct_helper;
15mod token_helper;
16
17use parameters::*;
18use struct_helper::*;
19use enum_helper::*;
20use derive_helper::*;
21use options::*;
22use token_helper::*;
23
24extern crate proc_macro;
25
26/// Types that derive `Parse` will automatically implement `Parse`, provided its members or fields do also.
27///
28/// An implementation of `Parse` for a `struct` will parse each of its fields in sequence, failing completely
29/// if one returns `Err`.
30///
31/// An `enum` parses it variants in the defined order starting at the same index, choosing and initializing the first variant to parse
32/// successfully.
33///
34/// ## Attributes
35///
36/// ### `#[strict]`
37/// Disables `Space` being parsed before and after each `Parse` type.
38///
39/// ### `#[error(...)]`
40/// Is used on a `struct` or variant and will format an error message for when `Error`
41/// is returned from `Self::parse`.
42///
43
44#[proc_macro_derive(Parse, attributes(strict, pattern, error, label, errors))]
45pub fn parse_derive(input: proc_macro::TokenStream) -> proc_macro::TokenStream {
46
47 crate::derive_helper(input.into()).into()
48
49}