| ... | ... | @@ -401,7 +401,9 @@ pub const Tokenizer = struct { |
| 401 | 401 | Zero, |
| 402 | 402 | IntegerLiteralOct, |
| 403 | 403 | IntegerLiteralBinary, |
| 404 | IntegerLiteralBinaryFirst, |
| 404 | 405 | IntegerLiteralHex, |
| 406 | IntegerLiteralHexFirst, |
| 405 | 407 | IntegerLiteral, |
| 406 | 408 | IntegerSuffix, |
| 407 | 409 | IntegerSuffixU, |
| ... | ... | @@ -1046,10 +1048,10 @@ pub const Tokenizer = struct { |
| 1046 | 1048 | state = .IntegerLiteralOct; |
| 1047 | 1049 | }, |
| 1048 | 1050 | 'b', 'B' => { |
| 1049 | | state = .IntegerLiteralBinary; |
| 1051 | state = .IntegerLiteralBinaryFirst; |
| 1050 | 1052 | }, |
| 1051 | 1053 | 'x', 'X' => { |
| 1052 | | state = .IntegerLiteralHex; |
| 1054 | state = .IntegerLiteralHexFirst; |
| 1053 | 1055 | }, |
| 1054 | 1056 | '.' => { |
| 1055 | 1057 | state = .FloatFraction; |
| ... | ... | @@ -1066,6 +1068,13 @@ pub const Tokenizer = struct { |
| 1066 | 1068 | self.index -= 1; |
| 1067 | 1069 | }, |
| 1068 | 1070 | }, |
| 1071 | .IntegerLiteralBinaryFirst => switch (c) { |
| 1072 | '0'...'7' => state = .IntegerLiteralBinary, |
| 1073 | else => { |
| 1074 | result.id = .Invalid; |
| 1075 | break; |
| 1076 | }, |
| 1077 | }, |
| 1069 | 1078 | .IntegerLiteralBinary => switch (c) { |
| 1070 | 1079 | '0', '1' => {}, |
| 1071 | 1080 | else => { |
| ... | ... | @@ -1073,6 +1082,19 @@ pub const Tokenizer = struct { |
| 1073 | 1082 | self.index -= 1; |
| 1074 | 1083 | }, |
| 1075 | 1084 | }, |
| 1085 | .IntegerLiteralHexFirst => switch (c) { |
| 1086 | '0'...'9', 'a'...'f', 'A'...'F' => state = .IntegerLiteralHex, |
| 1087 | '.' => { |
| 1088 | state = .FloatFractionHex; |
| 1089 | }, |
| 1090 | 'p', 'P' => { |
| 1091 | state = .FloatExponent; |
| 1092 | }, |
| 1093 | else => { |
| 1094 | result.id = .Invalid; |
| 1095 | break; |
| 1096 | }, |
| 1097 | }, |
| 1076 | 1098 | .IntegerLiteralHex => switch (c) { |
| 1077 | 1099 | '0'...'9', 'a'...'f', 'A'...'F' => {}, |
| 1078 | 1100 | '.' => { |
| ... | ... | @@ -1238,6 +1260,8 @@ pub const Tokenizer = struct { |
| 1238 | 1260 | .MultiLineCommentAsterisk, |
| 1239 | 1261 | .FloatExponent, |
| 1240 | 1262 | .MacroString, |
| 1263 | .IntegerLiteralBinaryFirst, |
| 1264 | .IntegerLiteralHexFirst, |
| 1241 | 1265 | => result.id = .Invalid, |
| 1242 | 1266 | |
| 1243 | 1267 | .FloatExponentDigits => result.id = if (counter == 0) .Invalid else .{ .FloatLiteral = .none }, |
| ... | ... | @@ -1523,6 +1547,7 @@ test "num suffixes" { |
| 1523 | 1547 | \\ 1.0f 1.0L 1.0 .0 1. |
| 1524 | 1548 | \\ 0l 0lu 0ll 0llu 0 |
| 1525 | 1549 | \\ 1u 1ul 1ull 1 |
| 1550 | \\ 0x 0b |
| 1526 | 1551 | \\ |
| 1527 | 1552 | , &[_]Token.Id{ |
| 1528 | 1553 | .{ .FloatLiteral = .f }, |
| ... | ... | @@ -1542,6 +1567,9 @@ test "num suffixes" { |
| 1542 | 1567 | .{ .IntegerLiteral = .llu }, |
| 1543 | 1568 | .{ .IntegerLiteral = .none }, |
| 1544 | 1569 | .Nl, |
| 1570 | .Invalid, |
| 1571 | .Invalid, |
| 1572 | .Nl, |
| 1545 | 1573 | }); |
| 1546 | 1574 | } |
| 1547 | 1575 | |