rust/src/libsyntax/ext/concat_idents.rs

29 lines
1.1 KiB
Rust
Raw Normal View History

// 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-09-04 18:37:29 +00:00
use base::*;
fn expand_syntax_ext(cx: ext_ctxt, sp: codemap::span, arg: ast::mac_arg,
_body: ast::mac_body) -> @ast::expr {
let args = get_mac_args_no_max(cx,sp,arg,1u,~"concat_idents");
2012-07-18 23:18:02 +00:00
let mut res_str = ~"";
2012-06-30 23:19:07 +00:00
for args.each |e| {
2012-07-18 23:18:02 +00:00
res_str += *cx.parse_sess().interner.get(
expr_to_ident(cx, *e, ~"expected an ident"));
}
2012-07-18 23:18:02 +00:00
let res = cx.parse_sess().interner.intern(@res_str);
2012-08-02 00:30:05 +00:00
return @{id: cx.next_id(),
callee_id: cx.next_id(),
2012-07-18 23:18:02 +00:00
node: ast::expr_path(@{span: sp, global: false, idents: ~[res],
2012-08-20 19:23:37 +00:00
rp: None, types: ~[]}),
span: sp};
}