Add UTF-32 character literal

This commit is contained in:
Rui Ueyama 2020-07-06 18:59:25 +09:00
parent 454618cd15
commit 2dac3afece
2 changed files with 16 additions and 0 deletions

View File

@ -25,6 +25,15 @@ int main() {
ASSERT(0, strcmp(STR(u'a'), "u'a'"));
ASSERT(4, sizeof(U'\0'));
ASSERT(1, U'\xffffffff'>>31);
ASSERT(97, U'a');
ASSERT(946, U'β');
ASSERT(12354, U'');
ASSERT(127843, U'🍣');
ASSERT(0, strcmp(STR(U'a'), "U'a'"));
printf("OK\n");
return 0;
}

View File

@ -495,6 +495,13 @@ Token *tokenize(File *file) {
continue;
}
// UTF-32 character literal
if (startswith(p, "U'")) {
cur = cur->next = read_char_literal(p, p + 1, ty_uint);
p += cur->len;
continue;
}
// Identifier or keyword
if (is_ident1(*p)) {
char *start = p;