diff options
| author | Simon Sapin <simon.sapin@exyr.org> | 2014-06-06 16:04:04 +0100 |
|---|---|---|
| committer | Simon Sapin <simon.sapin@exyr.org> | 2014-06-17 23:41:03 +0200 |
| commit | bccdba02960b3cd428addbc2c856065ebb81eb04 (patch) | |
| tree | 09c67823ea70b74b18af5ba2470b337968d758aa /src/libsyntax/parse/token.rs | |
| parent | 2fd618e77accd37426819952ad443e50bb3c9015 (diff) | |
| download | rust-bccdba02960b3cd428addbc2c856065ebb81eb04.tar.gz rust-bccdba02960b3cd428addbc2c856065ebb81eb04.zip | |
Add a b'x' byte literal of type u8.
Diffstat (limited to 'src/libsyntax/parse/token.rs')
| -rw-r--r-- | src/libsyntax/parse/token.rs | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/src/libsyntax/parse/token.rs b/src/libsyntax/parse/token.rs index a4a022708d9..b8f13624a32 100644 --- a/src/libsyntax/parse/token.rs +++ b/src/libsyntax/parse/token.rs @@ -78,6 +78,7 @@ pub enum Token { DOLLAR, /* Literals */ + LIT_BYTE(u8), LIT_CHAR(char), LIT_INT(i64, ast::IntTy), LIT_UINT(u64, ast::UintTy), @@ -193,6 +194,14 @@ pub fn to_str(t: &Token) -> String { DOLLAR => "$".to_string(), /* Literals */ + LIT_BYTE(b) => { + let mut res = String::from_str("b'"); + (b as char).escape_default(|c| { + res.push_char(c); + }); + res.push_char('\''); + res + } LIT_CHAR(c) => { let mut res = String::from_str("'"); c.escape_default(|c| { @@ -273,6 +282,7 @@ pub fn can_begin_expr(t: &Token) -> bool { IDENT(_, _) => true, UNDERSCORE => true, TILDE => true, + LIT_BYTE(_) => true, LIT_CHAR(_) => true, LIT_INT(_, _) => true, LIT_UINT(_, _) => true, @@ -311,6 +321,7 @@ pub fn close_delimiter_for(t: &Token) -> Option<Token> { pub fn is_lit(t: &Token) -> bool { match *t { + LIT_BYTE(_) => true, LIT_CHAR(_) => true, LIT_INT(_, _) => true, LIT_UINT(_, _) => true, |
