2012-12-10 19:32:48 -06:00
|
|
|
// 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.
|
|
|
|
|
2012-11-20 18:07:57 -06:00
|
|
|
#[allow(non_implicitly_copyable_typarams)];
|
|
|
|
|
2012-11-16 16:50:35 -06:00
|
|
|
extern mod syntax;
|
|
|
|
|
|
|
|
use syntax::ext::base::ext_ctxt;
|
|
|
|
|
|
|
|
fn syntax_extension(ext_cx: @ext_ctxt) {
|
2012-11-20 18:07:57 -06:00
|
|
|
let e_toks : ~[syntax::ast::token_tree] = quote_tokens!(1 + 2);
|
|
|
|
let p_toks : ~[syntax::ast::token_tree] = quote_tokens!((x, 1 .. 4, *));
|
2012-11-16 16:50:35 -06:00
|
|
|
|
2012-12-06 18:18:41 -06:00
|
|
|
let a: @syntax::ast::expr = quote_expr!(1 + 2);
|
2012-11-16 16:50:35 -06:00
|
|
|
let _b: Option<@syntax::ast::item> = quote_item!( const foo : int = $e_toks; );
|
|
|
|
let _c: @syntax::ast::pat = quote_pat!( (x, 1 .. 4, *) );
|
2012-12-06 18:18:41 -06:00
|
|
|
let _d: @syntax::ast::stmt = quote_stmt!( let x = $a; );
|
2012-11-16 16:50:35 -06:00
|
|
|
let _e: @syntax::ast::expr = quote_expr!( match foo { $p_toks => 10 } );
|
|
|
|
}
|
|
|
|
|
|
|
|
fn main() {
|
|
|
|
}
|
|
|
|
|