diff options
| author | Simon Sapin <simon.sapin@exyr.org> | 2014-06-13 18:56:24 +0100 |
|---|---|---|
| committer | Simon Sapin <simon.sapin@exyr.org> | 2014-06-17 23:43:18 +0200 |
| commit | b8a4c1415b154fa1e5bd8bb54e681f0f5e21e2a4 (patch) | |
| tree | 9a68d3b4eae31521d410062ca5ff9fc7018dc233 /src/libsyntax/parse/token.rs | |
| parent | d7e01b5809cd600a30bab29da698acb3d1b52409 (diff) | |
| download | rust-b8a4c1415b154fa1e5bd8bb54e681f0f5e21e2a4.tar.gz rust-b8a4c1415b154fa1e5bd8bb54e681f0f5e21e2a4.zip | |
Add br##"xx"## raw byte string literals.
Diffstat (limited to 'src/libsyntax/parse/token.rs')
| -rw-r--r-- | src/libsyntax/parse/token.rs | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/src/libsyntax/parse/token.rs b/src/libsyntax/parse/token.rs index b76dcaf0b94..a2af417ed79 100644 --- a/src/libsyntax/parse/token.rs +++ b/src/libsyntax/parse/token.rs @@ -88,6 +88,7 @@ pub enum Token { LIT_STR(ast::Ident), LIT_STR_RAW(ast::Ident, uint), /* raw str delimited by n hash symbols */ LIT_BINARY(Rc<Vec<u8>>), + LIT_BINARY_RAW(Rc<Vec<u8>>, uint), /* raw binary str delimited by n hash symbols */ /* Name components */ // an identifier contains an "is_mod_name" boolean, @@ -243,6 +244,10 @@ pub fn to_str(t: &Token) -> String { "b\"{}\"", v.iter().map(|&b| b as char).collect::<String>().escape_default()) } + LIT_BINARY_RAW(ref s, n) => { + format!("br{delim}\"{string}\"{delim}", + delim="#".repeat(n), string=s.as_slice().to_ascii().as_str_ascii()) + } /* Name components */ IDENT(s, _) => get_ident(s).get().to_string(), @@ -298,6 +303,7 @@ pub fn can_begin_expr(t: &Token) -> bool { LIT_STR(_) => true, LIT_STR_RAW(_, _) => true, LIT_BINARY(_) => true, + LIT_BINARY_RAW(_, _) => true, POUND => true, AT => true, NOT => true, @@ -338,6 +344,7 @@ pub fn is_lit(t: &Token) -> bool { LIT_STR(_) => true, LIT_STR_RAW(_, _) => true, LIT_BINARY(_) => true, + LIT_BINARY_RAW(_, _) => true, _ => false } } |
