1 // Copyright 2017 The Rust Project Developers. See the COPYRIGHT
2 // file at the top-level directory of this distribution and at
3 // http://rust-lang.org/COPYRIGHT.
5 // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6 // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7 // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8 // option. This file may not be copied, modified, or distributed
9 // except according to those terms.
12 #![feature(plugin_registrar)]
13 #![feature(rustc_private)]
14 #![plugin(proc_macro_plugin)]
16 extern crate rustc_plugin
;
19 use rustc_plugin
::Registry
;
20 use syntax
::ext
::base
::SyntaxExtension
;
21 use syntax
::symbol
::Symbol
;
22 use syntax
::tokenstream
::TokenStream
;
25 pub fn plugin_registrar(reg
: &mut Registry
) {
26 reg
.register_syntax_extension(Symbol
::intern("hello"),
27 SyntaxExtension
::ProcMacro(Box
::new(hello
)));
30 // This macro is not very interesting, but it does contain delimited tokens with
31 // no content - `()` and `{}` - which has caused problems in the past.
32 // Also, it tests that we can escape `$` via `$$`.
33 fn hello(_
: TokenStream
) -> TokenStream
{
36 macro_rules
! m { ($$($$t:tt)*) => { $$($$t)* }
}