- bool is_unsigned = false;
- bool min_long = false;
- bool min_longlong = false;
-
- if(c == 'U' || c == 'u') {
- is_unsigned = true;
- next_char();
- if(c == 'L' || c == 'l') {
- min_long = true;
- next_char();
- if(c == 'L' || c == 'l') {
- min_longlong = true;
- next_char();
- }
- }
- } else if(c == 'l' || c == 'L') {
- min_long = true;
- next_char();
- if(c == 'l' || c == 'L') {
- min_longlong = true;
- next_char();
- if(c == 'u' || c == 'U') {
- is_unsigned = true;
- next_char();
- }
- } else if(c == 'u' || c == 'U') {
- is_unsigned = true;
- next_char();
- lexer_token.datatype = type_unsigned_long;
- }
- }
-
- if(!is_unsigned) {
- long long v = lexer_token.v.intvalue;
- if(!min_long) {
- if(v >= TARGET_INT_MIN && v <= TARGET_INT_MAX) {
- lexer_token.datatype = type_int;
- return;
- } else if(is_oct_hex && v >= 0 && v <= TARGET_UINT_MAX) {
- lexer_token.datatype = type_unsigned_int;
- return;
- }
- }
- if(!min_longlong) {
- if(v >= TARGET_LONG_MIN && v <= TARGET_LONG_MAX) {
- lexer_token.datatype = type_long;
- return;
- } else if(is_oct_hex && v >= 0 && v <= TARGET_ULONG_MAX) {
- lexer_token.datatype = type_unsigned_long;
- return;
- }
- }
- unsigned long long uv = (unsigned long long) v;
- if(is_oct_hex && uv > (unsigned long long) TARGET_LONGLONG_MAX) {
- lexer_token.datatype = type_unsigned_long_long;
- return;
- }
-
- lexer_token.datatype = type_long_long;
- } else {
- unsigned long long v = (unsigned long long) lexer_token.v.intvalue;
- if(!min_long && v <= TARGET_UINT_MAX) {
- lexer_token.datatype = type_unsigned_int;
- return;
- }
- if(!min_longlong && v <= TARGET_ULONG_MAX) {
- lexer_token.datatype = type_unsigned_long;
- return;
- }
- lexer_token.datatype = type_unsigned_long_long;
- }
+ /* C11 Annex D.1 */
+ if ( v == 0x000A8) return true;
+ if ( v == 0x000AA) return true;
+ if ( v == 0x000AD) return true;
+ if ( v == 0x000AF) return true;
+ if (0x000B2 <= v && v <= 0x000B5) return true;
+ if (0x000B7 <= v && v <= 0x000BA) return true;
+ if (0x000BC <= v && v <= 0x000BE) return true;
+ if (0x000C0 <= v && v <= 0x000D6) return true;
+ if (0x000D8 <= v && v <= 0x000F6) return true;
+ if (0x000F8 <= v && v <= 0x000FF) return true;
+ if (0x00100 <= v && v <= 0x0167F) return true;
+ if (0x01681 <= v && v <= 0x0180D) return true;
+ if (0x0180F <= v && v <= 0x01FFF) return true;
+ if (0x0200B <= v && v <= 0x0200D) return true;
+ if (0x0202A <= v && v <= 0x0202E) return true;
+ if (0x0203F <= v && v <= 0x02040) return true;
+ if ( v == 0x02054) return true;
+ if (0x02060 <= v && v <= 0x0206F) return true;
+ if (0x02070 <= v && v <= 0x0218F) return true;
+ if (0x02460 <= v && v <= 0x024FF) return true;
+ if (0x02776 <= v && v <= 0x02793) return true;
+ if (0x02C00 <= v && v <= 0x02DFF) return true;
+ if (0x02E80 <= v && v <= 0x02FFF) return true;
+ if (0x03004 <= v && v <= 0x03007) return true;
+ if (0x03021 <= v && v <= 0x0302F) return true;
+ if (0x03031 <= v && v <= 0x0303F) return true;
+ if (0x03040 <= v && v <= 0x0D7FF) return true;
+ if (0x0F900 <= v && v <= 0x0FD3D) return true;
+ if (0x0FD40 <= v && v <= 0x0FDCF) return true;
+ if (0x0FDF0 <= v && v <= 0x0FE44) return true;
+ if (0x0FE47 <= v && v <= 0x0FFFD) return true;
+ if (0x10000 <= v && v <= 0x1FFFD) return true;
+ if (0x20000 <= v && v <= 0x2FFFD) return true;
+ if (0x30000 <= v && v <= 0x3FFFD) return true;
+ if (0x40000 <= v && v <= 0x4FFFD) return true;
+ if (0x50000 <= v && v <= 0x5FFFD) return true;
+ if (0x60000 <= v && v <= 0x6FFFD) return true;
+ if (0x70000 <= v && v <= 0x7FFFD) return true;
+ if (0x80000 <= v && v <= 0x8FFFD) return true;
+ if (0x90000 <= v && v <= 0x9FFFD) return true;
+ if (0xA0000 <= v && v <= 0xAFFFD) return true;
+ if (0xB0000 <= v && v <= 0xBFFFD) return true;
+ if (0xC0000 <= v && v <= 0xCFFFD) return true;
+ if (0xD0000 <= v && v <= 0xDFFFD) return true;
+ if (0xE0000 <= v && v <= 0xEFFFD) return true;
+ return false;