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.
This commit is contained in:
parent
4dc3a97698
commit
604667fa82
3 changed files with 47 additions and 1 deletions
|
|
@ -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));
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue