Treat it as a synonym for LIT_STR for now.
}
match tts[0] {
- ast::tt_tok(_, token::LIT_STR(ident)) => cx.str_of(ident),
+ ast::tt_tok(_, token::LIT_STR(ident))
+ | ast::tt_tok(_, token::LIT_STR_RAW(ident, _)) => cx.str_of(ident),
_ => cx.span_fatal(sp, format!("{} requires a string.", name)),
}
}
~[mk_ident(cx, sp, ident)]);
}
+ LIT_STR_RAW(ident, n) => {
+ return cx.expr_call_ident(sp,
+ id_ext("LIT_STR_RAW"),
+ ~[mk_ident(cx, sp, ident),
+ cx.expr_uint(sp, n)]);
+ }
+
IDENT(ident, b) => {
return cx.expr_call_ident(sp,
id_ext("IDENT"),
content_start_bpos,
content_end_bpos,
str_to_ident);
- return token::LIT_STR(str_content);
+ return token::LIT_STR_RAW(str_content, hash_count);
}
'-' => {
if nextch(rdr) == '>' {
let TokenAndSpan {tok, sp: _} =
env.string_reader.next_token();
let id = token::str_to_ident("\"#a\\b\x00c\"");
- assert_eq!(tok, token::LIT_STR(id));
+ assert_eq!(tok, token::LIT_STR_RAW(id, 3));
}
#[test] fn line_doc_comments() {
token::LIT_FLOAT_UNSUFFIXED(s) =>
lit_float_unsuffixed(self.id_to_str(s)),
token::LIT_STR(s) => lit_str(self.id_to_str(s)),
+ token::LIT_STR_RAW(s, _) => lit_str(self.id_to_str(s)),
token::LPAREN => { self.expect(&token::RPAREN); lit_nil },
_ => { self.unexpected_last(tok); }
}
// parse a string as an ABI spec on an extern type or module
fn parse_opt_abis(&self) -> Option<AbiSet> {
match *self.token {
- token::LIT_STR(s) => {
+ token::LIT_STR(s)
+ | token::LIT_STR_RAW(s, _) => {
self.bump();
let the_string = ident_to_str(&s);
let mut abis = AbiSet::empty();
pub fn parse_optional_str(&self) -> Option<@str> {
match *self.token {
- token::LIT_STR(s) => {
+ token::LIT_STR(s)
+ | token::LIT_STR_RAW(s, _) => {
self.bump();
Some(ident_to_str(&s))
}
LIT_FLOAT(ast::Ident, ast::float_ty),
LIT_FLOAT_UNSUFFIXED(ast::Ident),
LIT_STR(ast::Ident),
+ LIT_STR_RAW(ast::Ident, uint), /* raw str delimited by n hash symbols */
/* Name components */
// an identifier contains an "is_mod_name" boolean,
body
}
LIT_STR(ref s) => { format!("\"{}\"", ident_to_str(s).escape_default()) }
+ LIT_STR_RAW(ref s, n) => {
+ format!("r{delim}\"{string}\"{delim}",
+ delim="#".repeat(n), string=ident_to_str(s))
+ }
/* Name components */
IDENT(s, _) => input.get(s.name).to_owned(),
LIT_FLOAT(_, _) => true,
LIT_FLOAT_UNSUFFIXED(_) => true,
LIT_STR(_) => true,
+ LIT_STR_RAW(_, _) => true,
POUND => true,
AT => true,
NOT => true,
LIT_FLOAT(_, _) => true,
LIT_FLOAT_UNSUFFIXED(_) => true,
LIT_STR(_) => true,
+ LIT_STR_RAW(_, _) => true,
_ => false
}
}