rust/src/comp/syntax/ext/concat_idents.rs

25 lines
735 B
Rust
Raw Normal View History

import option;
import base::*;
import syntax::ast;
fn expand_syntax_ext(cx: ext_ctxt, sp: codemap::span, arg: @ast::expr,
_body: ast::mac_body) -> @ast::expr {
let args: [@ast::expr] =
alt arg.node {
ast::expr_vec(elts, _) { elts }
_ {
2011-09-02 17:34:58 -05:00
cx.span_fatal(sp, "#concat_idents requires a vector argument .")
}
};
2011-09-02 17:34:58 -05:00
let res: ast::ident = "";
for e: @ast::expr in args {
2011-09-02 17:34:58 -05:00
res += expr_to_ident(cx, e, "expected an ident");
}
ret @{id: cx.next_id(),
node: ast::expr_path(@{node: {global: false, idents: [res],
types: []},
span: sp}),
span: sp};
}