mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-08-06 16:19:23 +00:00
CppLexer: Correctly highlight hex escapes in string and char literals
\x consumes all hex digits following it. (If the resulting number then doesn't fit in the character type, the compiler emits an error.) \x would be much more convenient to use if it was always followed by exactly two hex digits (with \u and \U for higher codepoints), but that's sadly not the world we live in.
This commit is contained in:
parent
c1b7fd644c
commit
34dc163441
Notes:
sideshowbarker
2024-07-19 04:34:36 +09:00
Author: https://github.com/nico
Commit: 34dc163441
Pull-request: https://github.com/SerenityOS/serenity/pull/2896
1 changed files with 1 additions and 4 deletions
|
@ -287,11 +287,8 @@ Vector<CppToken> CppLexer::lex()
|
|||
}
|
||||
case 'x': {
|
||||
size_t hex_digits = 0;
|
||||
for (size_t i = 0; i < 2; ++i) {
|
||||
if (!isxdigit(peek(2 + i)))
|
||||
break;
|
||||
while (isxdigit(peek(2 + hex_digits)))
|
||||
++hex_digits;
|
||||
}
|
||||
return 2 + hex_digits;
|
||||
}
|
||||
case 'u':
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue