schala/schala-codegen/src/lib.rs

57 lines
1.0 KiB
Rust

#![feature(proc_macro)]
extern crate proc_macro;
use proc_macro::TokenStream;
#[proc_macro]
pub fn compiler_pass_sequence(input: TokenStream) -> TokenStream {
r#"
fn new_execute(&mut self, input: &str, _options: &EvalOptions) -> FinishedComputation {
let mut evaluation = UnfinishedComputation::default();
evaluation.output(Err("this comes at ye from the macro".to_string()))
}
"#.parse().unwrap()
}
/* #[compiler_pass(<name of pass>*/
#[proc_macro_attribute]
pub fn compiler_pass(metadata: TokenStream, function: TokenStream) -> TokenStream {
//println!("FROM MACRO: {}", function);
println!("Compiler pass metadata: {}", metadata);
function
}
#[cfg(test)]
mod tests {
#[test]
fn it_works() {
assert_eq!(2 + 2, 4);
}
}
/* in Rocket
*
#[get("/")]
fn hi() -> &'static str {
"hello"
}
GETS MAPPED TO:
static hi_info = RouteInfo {
name: "hi",
method: Method::Get,
path: "/",
handler: hi_route,
}
fn hi_route(req: &Request) -> Outcome {
let responder = hi();
Outcome::from(req, responder);
}
*/