summaryrefslogtreecommitdiffstats
path: root/vendor/xflags-macros/src/lib.rs
blob: 8fac00587a942f909adb4acb16e56a78150a0234 (plain)
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
mod ast;
mod parse;
mod emit;
mod update;

#[proc_macro]
pub fn xflags(_ts: proc_macro::TokenStream) -> proc_macro::TokenStream {
    // Stub out the code, but let rust-analyzer resolve the invocation
    #[cfg(not(test))]
    {
        let cmd = parse::parse(_ts).unwrap();
        let text = emit::emit(&cmd);
        text.parse().unwrap()
    }
    #[cfg(test)]
    unimplemented!()
}

#[cfg(test)]
pub fn compile(src: &str) -> String {
    use proc_macro2::TokenStream;

    let ts = src.parse::<TokenStream>().unwrap();
    let cmd = parse::parse(ts).unwrap();
    emit::emit(&cmd)
}