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
use espr::{ast::SyntaxTree, codegen::rust::*, ir::IR};
use proc_macro::TokenStream;
#[proc_macro]
pub fn inline_express(input: TokenStream) -> TokenStream {
let input: syn::LitStr =
syn::parse(input).expect("inline_express! argument must be string literal");
let st = SyntaxTree::parse(&input.value()).expect("Tokenize failed");
let ir = IR::from_syntax_tree(&st).expect("Failed in semantic analysis phase");
ir.to_token_stream(CratePrefix::External).into()
}