1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#![feature(proc_macro_hygiene)]
#![feature(external_doc)]
#![doc(include = "../README.md")]

extern crate proc_macro;
extern crate proc_macro2;

mod resyn;
use proc_macro::TokenStream;
use quote::quote;

/// Changes the `Block` parsing syntax so that the `::()` postfix
/// serves as a general postfix operator.
#[proc_macro]
pub fn sonic_spin(item: TokenStream) -> TokenStream {
    let rebraced = {
        use std::str::FromStr;
        let rebraced: String = String::from("{") + &item.to_string() + &"}";
        TokenStream::from_str(&rebraced).unwrap()
    };

    let input = syn::parse_macro_input!(rebraced as resyn::expr::Block);
    let reparsed = quote! {
       #input
    };

    // let quoted = format!(" ==> <  {}  >\n", &reparsed);
    // println!("{}", &quoted);

    reparsed.into()
}