// Copyright 2012-2014 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 or the MIT license // , at your // option. This file may not be copied, modified, or distributed // except according to those terms. // ignore-android // ignore-pretty: does not work well with `--test` #![feature(quote)] extern crate syntax; use syntax::ext::base::ExtCtxt; use std::gc::Gc; fn syntax_extension(cx: &ExtCtxt) { let e_toks : Vec = quote_tokens!(cx, 1 + 2); let p_toks : Vec = quote_tokens!(cx, (x, 1 .. 4, *)); let a: Gc = quote_expr!(cx, 1 + 2); let _b: Option> = quote_item!(cx, static foo : int = $e_toks; ); let _c: Gc = quote_pat!(cx, (x, 1 .. 4, *) ); let _d: Gc = quote_stmt!(cx, let x = $a; ); let _d: syntax::ast::Arm = quote_arm!(cx, (ref x, ref y) = (x, y) ); let _e: Gc = quote_expr!(cx, match foo { $p_toks => 10 } ); let _f: Gc = quote_expr!(cx, ()); let _g: Gc = quote_expr!(cx, true); let _h: Gc = quote_expr!(cx, 'a'); let i: Option> = quote_item!(cx, #[deriving(Eq)] struct Foo; ); assert!(i.is_some()); } fn main() { }