}
#[proc_macro]
-pub fn reconstruct_group(input: TokenStream) -> TokenStream {
+pub fn reconstruct_groups(input: TokenStream) -> TokenStream {
let mut output = TokenStream::new();
dbg!(&input);
for tt in input {
TokenTree::Group(g) => {
let delim = g.delimiter();
dbg!(&delim);
- TokenTree::Group(Group::new(delim, g.stream()))
+ let stream = reconstruct_groups(g.stream());
+ TokenTree::Group(Group::new(delim, stream))
},
other => other,
};
dbg_dump!(1 + $v)
} }
macro_rules! one_plus_reconstruct { { $v:expr } => {
- dbg_dump!(1 + reconstruct_group!($v))
+ reconstruct_groups!(1 + $v)
} }
fn main() {
println!("1 + (2<<3) should be 17");
-// println!("{} without proc_macro", one_plus!(2 << 3));
-// println!("{} dbg_dump", one_plus_dbg!(2 << 3));
+ println!("{} without proc_macro", one_plus!(2 << 3));
+ println!("{} dbg_dump", one_plus_dbg!(2 << 3));
println!("{} reconstruct", one_plus_reconstruct!(2 << 3));
}