blob: f1c0e05991d2ed39f0a36092b277c3b15ba38c74 (
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
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
|
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 text = match parse::xflags(_ts) {
Ok(cmd) => emit::emit(&cmd),
Err(err) => format!("compile_error!(\"invalid flags syntax, {err}\");"),
};
text.parse().unwrap()
}
#[cfg(test)]
unimplemented!()
}
#[proc_macro]
pub fn parse_or_exit(_ts: proc_macro::TokenStream) -> proc_macro::TokenStream {
// Stub out the code, but let rust-analyzer resolve the invocation
#[cfg(not(test))]
{
let text = match parse::parse_or_exit(_ts) {
Ok(cmd) => emit::emit(&cmd),
Err(err) => format!("compile_error!(\"invalid flags syntax, {err}\")"),
};
text.parse().unwrap()
}
#[cfg(test)]
{
let _ = parse::parse_or_exit;
unimplemented!();
}
}
#[cfg(test)]
pub fn compile(src: &str) -> String {
use proc_macro2::TokenStream;
let ts = src.parse::<TokenStream>().unwrap();
let cmd = parse::xflags(ts).unwrap();
emit::emit(&cmd)
}
|