summary refs log tree commit diff
path: root/src/comp/syntax/ext/concat_idents.rs
blob: c487a3ecc3612a85c4545326b92bacd9b72d7621 (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
import option;
import base::*;
import syntax::ast;

fn expand_syntax_ext(cx: ext_ctxt, sp: codemap::span, arg: @ast::expr,
                     _body: option::t<str>) -> @ast::expr {
    let args: [@ast::expr] =
        alt arg.node {
          ast::expr_vec(elts, _) { elts }
          _ {
            cx.span_fatal(sp, "#concat_idents requires a vector argument .")
          }
        };
    let res: ast::ident = "";
    for e: @ast::expr in args {
        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};
}