maud/maud_macros/src/lib.rs

25 lines
579 B
Rust
Raw Normal View History

2014-12-17 21:11:56 +13:00
#![crate_type = "dylib"]
#![feature(plugin_registrar, quote)]
2015-02-02 20:53:47 +13:00
#![feature(core, rustc_private)]
2014-12-17 21:11:56 +13:00
extern crate syntax;
extern crate rustc;
2014-12-19 11:53:40 +13:00
extern crate maud;
2014-12-17 21:11:56 +13:00
2014-12-19 18:25:44 +13:00
use syntax::ast::TokenTree;
2014-12-17 21:11:56 +13:00
use syntax::codemap::Span;
2015-01-12 16:46:12 +13:00
use syntax::ext::base::{ExtCtxt, MacExpr, MacResult};
2014-12-17 21:11:56 +13:00
use rustc::plugin::Registry;
2014-12-18 18:57:55 +13:00
mod parse;
mod render;
2014-12-17 21:11:56 +13:00
2014-12-19 18:25:44 +13:00
fn expand_html<'cx>(cx: &'cx mut ExtCtxt, sp: Span, args: &[TokenTree]) -> Box<MacResult + 'cx> {
2015-01-12 16:46:12 +13:00
MacExpr::new(parse::parse(cx, args, sp))
2014-12-17 21:11:56 +13:00
}
#[plugin_registrar]
pub fn plugin_registrar(reg: &mut Registry) {
2014-12-19 18:25:44 +13:00
reg.register_macro("html", expand_html);
2014-12-17 21:11:56 +13:00
}