1#![doc=include_str!("../README.md")]
2
3#[macro_export]
6#[cfg(doc)]
7macro_rules! makero {
8 { ... } => { ... };
9}
10
11#[macro_export]
12#[cfg(not(doc))]
13macro_rules! makero {
14 ($(#[$attr:meta])* macro_rules! $name:ident $($x:tt)*) => {
15 makero!(_ ($) $name $(#[$attr])* macro_rules! $name $($x)*);
16 };
17 (_ ($d:tt) $name:ident $(#[$attr:meta])* $(macro_rules! $fn:ident {$( ($($arg:tt)*) => {$($result:tt)*} $(;)? )*} )*) => {
18 $(#[$attr])*
19 macro_rules! $name {
20 $($(
21 (_makero (fn $fn $d _makero_return:tt) $($arg)*) => {
22 $name!{_makero $d _makero_return $($result)*}
23 };
24 (_makero impl $d prev:tt ($fn ! ($d($d arg:tt)*) $d($d next:tt)*) $d ret:tt) => {
25 $name!{_makero impl () ($d($d arg)*) (fn $fn (impl $d prev ($d($d next)*) $d ret))}
26 };
27 )*)*
28 (_makero impl $d prev:tt (($d($d inner:tt)*) $d($d next:tt)*) $d ret:tt) => {
29 $name!{_makero impl () ($d($d inner)*) (impl wrap () $d prev ($d($d next)*) $d ret)}
30 };
31 (_makero impl $d prev:tt ([$d($d inner:tt)*] $d($d next:tt)*) $d ret:tt) => {
32 $name!{_makero impl () ($d($d inner)*) (impl wrap [] $d prev ($d($d next)*) $d ret)}
33 };
34 (_makero impl $d prev:tt ({$d($d inner:tt)*} $d($d next:tt)*) $d ret:tt) => {
35 $name!{_makero impl () ($d($d inner)*) (impl wrap {} $d prev ($d($d next)*) $d ret)}
36 };
37 (_makero impl ($d($d prev:tt)*) ($d cur:tt $d($d next:tt)*) $d ret:tt) => {
38 $name!{_makero impl ($d($d prev)* $d cur) ($d($d next)*) $d ret}
39 };
40 (_makero impl ($d($d prev:tt)*) () $d ret:tt) => {
41 $name!{_makero $d ret $d($d prev)*}
42 };
43 (_makero (impl wrap () ($d($d prev:tt)*) ($d($d next:tt)*) $d ret:tt) $d($d cur:tt)*) => {
44 $name!{_makero impl ($d($d prev)* ($d($d cur)*)) ($d($d next)*) $d ret}
45 };
46 (_makero (impl wrap [] ($d($d prev:tt)*) ($d($d next:tt)*) $d ret:tt) $d($d cur:tt)*) => {
47 $name!{_makero impl ($d($d prev)* [$d($d cur)*]) ($d($d next)*) $d ret}
48 };
49 (_makero (impl wrap {} ($d($d prev:tt)*) ($d($d next:tt)*) $d ret:tt) $d($d cur:tt)*) => {
50 $name!{_makero impl ($d($d prev)* {$d($d cur)*}) ($d($d next)*) $d ret}
51 };
52 (_makero (impl $d prev:tt ($d($d next:tt)*) $d ret:tt) $d($d cur:tt)*) => {
53 $name!{_makero impl $d prev ($d($d cur)* $d($d next)*) $d ret}
54 };
55 (_makero return $d($d result:tt)*) => {
56 $d($d result)*
57 };
58 ($d($d x:tt)*) => {
59 $name!{_makero impl () ($name!($d($d x)*)) return}
60 };
61 }
62 };
63}