rust/src/comp/syntax/ext/ident_to_str.rs
Marijn Haverbeke fc6b7c8b38 Reformat for new mode syntax, step 1
Long lines were fixed in a very crude way, as I'll be following up
with another reformat in a bit.
2011-09-12 12:04:14 +02:00

24 lines
705 B
Rust

import std::vec;
import std::str;
import std::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, "#ident_to_str requires a vector argument .")
}
};
if vec::len::<@ast::expr>(args) != 1u {
cx.span_fatal(sp, "malformed #ident_to_str call");
}
ret make_new_lit(cx, sp,
ast::lit_str(expr_to_ident(cx, args[0u],
"expected an ident")));
}