Mercurial > octave-nkf
comparison 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 |
comparison
equal
deleted
inserted
replaced
17243:f4c8c66faf34 | 17244:9de751a10910 |
---|---|
692 error ("invalid octal escape sequence in character string"); | 692 error ("invalid octal escape sequence in character string"); |
693 else | 693 else |
694 curr_lexer->string_text += static_cast<unsigned char> (result); | 694 curr_lexer->string_text += static_cast<unsigned char> (result); |
695 } | 695 } |
696 | 696 |
697 <DQ_STRING_START>\\x[0-9a-fA-F]+ { | |
698 curr_lexer->lexer_debug ("<DQ_STRING_START>\\\\x[0-9a-fA-F]+"); | |
699 | |
700 curr_lexer->current_input_column += yyleng; | |
701 | |
702 int result; | |
703 sscanf (yytext+2, "%x", &result); | |
704 | |
705 // Truncate the value silently instead of checking the range like | |
706 // we do for octal above. This is to match C/C++ where any number | |
707 // of digits is allowed but the value is implementation-defined if | |
708 // it exceeds the range of the character type. | |
709 curr_lexer->string_text += static_cast<unsigned char> (result); | |
710 } | |
711 | |
697 <DQ_STRING_START>"\\a" { | 712 <DQ_STRING_START>"\\a" { |
698 curr_lexer->lexer_debug ("<DQ_STRING_START>\"\\\\a\""); | 713 curr_lexer->lexer_debug ("<DQ_STRING_START>\"\\\\a\""); |
699 | 714 |
700 curr_lexer->current_input_column += yyleng; | 715 curr_lexer->current_input_column += yyleng; |
701 curr_lexer->string_text += '\a'; | 716 curr_lexer->string_text += '\a'; |