1 // Copyright 2012-2014 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 // ignore-pretty: does not work well with `--test`
15 #![feature(managed_boxes)]
19 use syntax::ext::base::ExtCtxt;
21 fn syntax_extension(cx: &ExtCtxt) {
22 let e_toks : Vec<syntax::ast::TokenTree> = quote_tokens!(cx, 1 + 2);
23 let p_toks : Vec<syntax::ast::TokenTree> = quote_tokens!(cx, (x, 1 .. 4, *));
25 let a: @syntax::ast::Expr = quote_expr!(cx, 1 + 2);
26 let _b: Option<@syntax::ast::Item> = quote_item!(cx, static foo : int = $e_toks; );
27 let _c: @syntax::ast::Pat = quote_pat!(cx, (x, 1 .. 4, *) );
28 let _d: @syntax::ast::Stmt = quote_stmt!(cx, let x = $a; );
29 let _e: @syntax::ast::Expr = quote_expr!(cx, match foo { $p_toks => 10 } );
31 let _f: @syntax::ast::Expr = quote_expr!(cx, ());
32 let _g: @syntax::ast::Expr = quote_expr!(cx, true);
33 let _h: @syntax::ast::Expr = quote_expr!(cx, 'a');
35 let i: Option<@syntax::ast::Item> = quote_item!(cx, #[deriving(Eq)] struct Foo; );