Mercurial > hg > octave-nkf
diff libinterp/parse-tree/lex.ll @ 17244:9de751a10910
Add support for hexadecimal escape sequences in double-quoted strings (bug #39775)
* lex.ll (<DQ_STRING_START>\\x[0-9a-fA-F]+): New pattern to parse hex
escape sequences in double-quoted strings.
* strings.txi: Uncomment and clean up the descriptions of octal and hex
escape sequences.
author | Mike Miller <mtmiller@ieee.org> |
---|---|
date | Wed, 14 Aug 2013 02:07:07 -0400 |
parents | bc12849bb6cc |
children | 8be8a65d3ca8 |
line wrap: on
line diff
--- a/libinterp/parse-tree/lex.ll +++ b/libinterp/parse-tree/lex.ll @@ -694,6 +694,21 @@ curr_lexer->string_text += static_cast<unsigned char> (result); } +<DQ_STRING_START>\\x[0-9a-fA-F]+ { + curr_lexer->lexer_debug ("<DQ_STRING_START>\\\\x[0-9a-fA-F]+"); + + curr_lexer->current_input_column += yyleng; + + int result; + sscanf (yytext+2, "%x", &result); + + // Truncate the value silently instead of checking the range like + // we do for octal above. This is to match C/C++ where any number + // of digits is allowed but the value is implementation-defined if + // it exceeds the range of the character type. + curr_lexer->string_text += static_cast<unsigned char> (result); + } + <DQ_STRING_START>"\\a" { curr_lexer->lexer_debug ("<DQ_STRING_START>\"\\\\a\"");