maud/maud_macros/src/lib.rs
Chris Wong 270781b255 Show error on unexpected end of input
Without this error, rustc would treat our dummy result as a real one,
causing much pain.
2015-01-12 16:24:53 +13:00

27 lines
659 B
Rust

#![crate_type = "dylib"]
#![feature(plugin_registrar, quote)]
#![allow(unstable)]
extern crate syntax;
extern crate rustc;
extern crate maud;
use syntax::ast::TokenTree;
use syntax::codemap::Span;
use syntax::ext::base::{DummyResult, ExtCtxt, MacExpr, MacResult};
use rustc::plugin::Registry;
mod parse;
mod render;
fn expand_html<'cx>(cx: &'cx mut ExtCtxt, sp: Span, args: &[TokenTree]) -> Box<MacResult + 'cx> {
match parse::parse(cx, args, sp) {
Some(expr) => MacExpr::new(expr),
None => DummyResult::any(sp),
}
}
#[plugin_registrar]
pub fn plugin_registrar(reg: &mut Registry) {
reg.register_macro("html", expand_html);
}