diff options
| author | Daniel Rosenwasser <DanielRosenwasser@gmail.com> | 2013-09-16 22:38:53 -0400 |
|---|---|---|
| committer | Daniel Rosenwasser <DanielRosenwasser@gmail.com> | 2013-09-17 23:52:29 -0400 |
| commit | 604667fa82f72309ee692c77086e22766cc3a8ee (patch) | |
| tree | e8b95da46456c3deba9eb584a45d891ec8b38f93 /src/libsyntax/parse | |
| parent | 4dc3a97698d393e16c9519a9f42bb72de167a217 (diff) | |
| download | rust-604667fa82f72309ee692c77086e22766cc3a8ee.tar.gz rust-604667fa82f72309ee692c77086e22766cc3a8ee.zip | |
Added support for a `\0` escape sequence.
This commit adds support for `\0` escapes in character and string literals. Since `\0` is equivalent to `\x00`, this is a direct translation to the latter escape sequence. Future builds will be able to compile using `\0` directly. Also updated the grammar specification and added a test for NUL characters.
Diffstat (limited to 'src/libsyntax/parse')
| -rw-r--r-- | src/libsyntax/parse/lexer.rs | 2 |
1 files changed, 2 insertions, 0 deletions
diff --git a/src/libsyntax/parse/lexer.rs b/src/libsyntax/parse/lexer.rs index c267a673fce..0bc9e619274 100644 --- a/src/libsyntax/parse/lexer.rs +++ b/src/libsyntax/parse/lexer.rs @@ -699,6 +699,7 @@ fn next_token_inner(rdr: @mut StringReader) -> token::Token { '\\' => { c2 = '\\'; } '\'' => { c2 = '\''; } '"' => { c2 = '"'; } + '0' => { c2 = '\x00'; } 'x' => { c2 = scan_numeric_escape(rdr, 2u); } 'u' => { c2 = scan_numeric_escape(rdr, 4u); } 'U' => { c2 = scan_numeric_escape(rdr, 8u); } @@ -738,6 +739,7 @@ fn next_token_inner(rdr: @mut StringReader) -> token::Token { '\'' => accum_str.push_char('\''), '"' => accum_str.push_char('"'), '\n' => consume_whitespace(rdr), + '0' => accum_str.push_char('\x00'), 'x' => { accum_str.push_char(scan_numeric_escape(rdr, 2u)); } |
