about summary refs log tree commit diff
path: root/src/test/run-pass-fulldeps/quote-tokens.rs
blob: 3ec54955229d3e5e98d0c2cde5dac0d04222ced0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
// Copyright 2012 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 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
// except according to those terms.

#[allow(non_implicitly_copyable_typarams)];

extern mod syntax;

use syntax::ext::base::ext_ctxt;

fn syntax_extension(ext_cx: @ext_ctxt) {
    let e_toks : ~[syntax::ast::token_tree] = quote_tokens!(1 + 2);
    let p_toks : ~[syntax::ast::token_tree] = quote_tokens!((x, 1 .. 4, *));

    let a: @syntax::ast::expr = quote_expr!(1 + 2);
    let _b: Option<@syntax::ast::item> = quote_item!( static foo : int = $e_toks; );
    let _c: @syntax::ast::pat = quote_pat!( (x, 1 .. 4, *) );
    let _d: @syntax::ast::stmt = quote_stmt!( let x = $a; );
    let _e: @syntax::ast::expr = quote_expr!( match foo { $p_toks => 10 } );
}

fn main() {
}