1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 14:17:36 +00:00

CppLexer: Support \U escapes in addition to \u escapes

This commit is contained in:
Nico Weber 2020-07-26 21:06:44 -04:00 committed by Andreas Kling
parent 58308748cb
commit c1b7fd644c

View file

@ -294,15 +294,17 @@ Vector<CppToken> CppLexer::lex()
} }
return 2 + hex_digits; return 2 + hex_digits;
} }
case 'u': { case 'u':
case 'U': {
bool is_unicode = true; bool is_unicode = true;
for (size_t i = 0; i < 4; ++i) { size_t number_of_digits = peek(1) == 'u' ? 4 : 8;
for (size_t i = 0; i < number_of_digits; ++i) {
if (!isxdigit(peek(2 + i))) { if (!isxdigit(peek(2 + i))) {
is_unicode = false; is_unicode = false;
break; break;
} }
} }
return is_unicode ? 6 : 0; return is_unicode ? 2 + number_of_digits : 0;
} }
default: default:
return 0; return 0;