schala/schala-codegen/src/lib.rs

34 lines
702 B
Rust
Raw Normal View History

#![feature(proc_macro)]
extern crate proc_macro;
#[macro_use]
extern crate quote;
extern crate syn;
2018-04-30 02:24:21 -07:00
use proc_macro::TokenStream;
2018-04-30 02:24:21 -07:00
use syn::DeriveInput;
#[proc_macro]
pub fn print_a_thing(_input: TokenStream) -> TokenStream {
"println!(\"Invoked from a proc macro\");".parse().unwrap()
}
#[proc_macro_derive(ProgrammingLanguageInterface)]
pub fn derive_programming_language_interface(input: TokenStream) -> TokenStream {
2018-04-30 02:24:21 -07:00
let ast: DeriveInput = syn::parse(input).unwrap();
let name = &ast.ident;
let tokens = quote! {
impl ProgrammingLanguageInterface for #name {
}
};
tokens.into()
}
#[cfg(test)]
mod tests {
#[test]
fn it_works() {
assert_eq!(2 + 2, 4);
}
}