From ebf7b402ea9ac4d065f2dbf5c514b7a46bf0fc81 Mon Sep 17 00:00:00 2001 From: Rui Ueyama Date: Mon, 20 Jul 2020 19:24:56 +0900 Subject: [PATCH] Recognize wide character literal For now, L'' is equivalent to ''. --- test/literal.c | 3 +++ tokenize.c | 7 +++++++ 2 files changed, 10 insertions(+) diff --git a/test/literal.c b/test/literal.c index c0fa499..472b72d 100644 --- a/test/literal.c +++ b/test/literal.c @@ -95,6 +95,9 @@ int main() { of(char), \ "sizeof(char)"); + ASSERT(4, sizeof(L'\0')); + ASSERT(97, L'a'); + printf("OK\n"); return 0; } diff --git a/tokenize.c b/tokenize.c index dd8d50c..760235b 100644 --- a/tokenize.c +++ b/tokenize.c @@ -432,6 +432,13 @@ Token *tokenize(File *file) { continue; } + // Wide character literal + if (startswith(p, "L'")) { + cur = read_char_literal(cur, p + 1); + p += cur->len + 1; + continue; + } + // Identifier or keyword if (is_ident1(*p)) { char *q = p++;