maud/maud_macros/src/lib.rs

47 lines
978 B
Rust
Raw Normal View History

#![feature(proc_macro)]
2016-12-29 12:20:08 +13:00
#![recursion_limit = "1000"] // if_chain
2014-12-17 21:11:56 +13:00
#![doc(html_root_url = "https://docs.rs/maud_macros/0.16.3")]
2016-12-29 12:20:08 +13:00
#[macro_use]
extern crate if_chain;
extern crate literalext;
extern crate proc_macro;
// TODO move lints into their own `maud_lints` crate
// mod lints;
2014-12-18 18:57:55 +13:00
mod parse;
mod render;
2014-12-17 21:11:56 +13:00
use proc_macro::TokenStream;
type ParseResult<T> = Result<T, String>;
2016-01-01 11:43:59 +13:00
#[proc_macro]
pub fn html(args: TokenStream) -> TokenStream {
match parse::parse(args) {
Ok(expr) => expr,
Err(e) => panic!(e),
}
2016-08-15 20:32:39 +12:00
}
#[proc_macro]
pub fn html_debug(args: TokenStream) -> TokenStream {
match parse::parse(args) {
Ok(expr) => {
println!("expansion:\n{}", expr);
expr
},
Err(e) => panic!(e),
}
}
/*
2014-12-17 21:11:56 +13:00
#[plugin_registrar]
pub fn plugin_registrar(reg: &mut Registry) {
reg.register_macro("html", expand_html);
reg.register_macro("html_debug", expand_html_debug);
lints::register_lints(reg);
2014-12-17 21:11:56 +13:00
}
*/