maud/maud_macros/src/lib.rs

25 lines
589 B
Rust
Raw Normal View History

2014-12-17 21:11:56 +13:00
#![crate_type = "dylib"]
#![feature(plugin_registrar, quote)]
2015-02-27 14:34:57 +13:00
#![feature(collections, 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-03-01 20:07:50 -05:00
use syntax::ext::base::{ExtCtxt, MacEager, 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-03-01 20:07:50 -05:00
MacEager::expr(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
}