From 604667fa82f72309ee692c77086e22766cc3a8ee Mon Sep 17 00:00:00 2001 From: Daniel Rosenwasser Date: Mon, 16 Sep 2013 22:38:53 -0400 Subject: 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. --- src/libsyntax/parse/lexer.rs | 2 ++ 1 file changed, 2 insertions(+) (limited to 'src/libsyntax/parse') 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)); } -- cgit 1.4.1-3-g733a5