UNPKG

meriyah

Version:

A 100% compliant, self-hosted javascript parser with high focus on both performance and stability

1,275 lines (1,265 loc) • 324 kB
'use strict'; const unicodeLookup = ((compressed, lookup) => { const result = new Uint32Array(69632); let index = 0; let subIndex = 0; while (index < 2571) { const inst = compressed[index++]; if (inst < 0) { subIndex -= inst; } else { let code = compressed[index++]; if (inst & 2) code = lookup[code]; if (inst & 1) { result.fill(code, subIndex, subIndex += compressed[index++]); } else { result[subIndex++] = code; } } } return result; })([-1, 2, 26, 2, 27, 2, 5, -1, 0, 77595648, 3, 44, 2, 3, 0, 14, 2, 63, 2, 64, 3, 0, 3, 0, 3168796671, 0, 4294956992, 2, 1, 2, 0, 2, 41, 3, 0, 4, 0, 4294966523, 3, 0, 4, 2, 16, 2, 65, 2, 0, 0, 4294836735, 0, 3221225471, 0, 4294901942, 2, 66, 0, 134152192, 3, 0, 2, 0, 4294951935, 3, 0, 2, 0, 2683305983, 0, 2684354047, 2, 18, 2, 0, 0, 4294961151, 3, 0, 2, 2, 19, 2, 0, 0, 608174079, 2, 0, 2, 60, 2, 7, 2, 6, 0, 4286611199, 3, 0, 2, 2, 1, 3, 0, 3, 0, 4294901711, 2, 40, 0, 4089839103, 0, 2961209759, 0, 1342439375, 0, 4294543342, 0, 3547201023, 0, 1577204103, 0, 4194240, 0, 4294688750, 2, 2, 0, 80831, 0, 4261478351, 0, 4294549486, 2, 2, 0, 2967484831, 0, 196559, 0, 3594373100, 0, 3288319768, 0, 8469959, 0, 65472, 2, 3, 0, 4093640191, 0, 660618719, 0, 65487, 0, 4294828015, 0, 4092591615, 0, 1616920031, 0, 982991, 2, 3, 2, 0, 0, 2163244511, 0, 4227923919, 0, 4236247022, 2, 71, 0, 4284449919, 0, 851904, 2, 4, 2, 12, 0, 67076095, -1, 2, 72, 0, 1073741743, 0, 4093607775, -1, 0, 50331649, 0, 3265266687, 2, 33, 0, 4294844415, 0, 4278190047, 2, 20, 2, 137, -1, 3, 0, 2, 2, 23, 2, 0, 2, 10, 2, 0, 2, 15, 2, 22, 3, 0, 10, 2, 74, 2, 0, 2, 75, 2, 76, 2, 77, 2, 0, 2, 78, 2, 0, 2, 11, 0, 261632, 2, 25, 3, 0, 2, 2, 13, 2, 4, 3, 0, 18, 2, 79, 2, 5, 3, 0, 2, 2, 80, 0, 2151677951, 2, 29, 2, 9, 0, 909311, 3, 0, 2, 0, 814743551, 2, 49, 0, 67090432, 3, 0, 2, 2, 42, 2, 0, 2, 6, 2, 0, 2, 30, 2, 8, 0, 268374015, 2, 110, 2, 51, 2, 0, 2, 81, 0, 134153215, -1, 2, 7, 2, 0, 2, 8, 0, 2684354559, 0, 67044351, 0, 3221160064, 2, 17, -1, 3, 0, 2, 2, 53, 0, 1046528, 3, 0, 3, 2, 9, 2, 0, 2, 54, 0, 4294960127, 2, 10, 2, 6, 2, 11, 0, 4294377472, 2, 12, 3, 0, 16, 2, 13, 2, 0, 2, 82, 2, 10, 2, 0, 2, 83, 2, 84, 2, 85, 0, 12288, 2, 55, 0, 1048577, 2, 86, 2, 14, -1, 2, 14, 0, 131042, 2, 87, 2, 88, 2, 89, 2, 0, 2, 34, -83, 3, 0, 7, 0, 1046559, 2, 0, 2, 15, 2, 0, 0, 2147516671, 2, 21, 3, 90, 2, 2, 0, -16, 2, 91, 0, 524222462, 2, 4, 2, 0, 0, 4269801471, 2, 4, 3, 0, 2, 2, 28, 2, 16, 3, 0, 2, 2, 17, 2, 0, -1, 2, 18, -16, 3, 0, 206, -2, 3, 0, 692, 2, 73, -1, 2, 18, 2, 10, 3, 0, 8, 2, 93, 2, 133, 2, 0, 0, 3220242431, 3, 0, 3, 2, 19, 2, 94, 2, 95, 3, 0, 2, 2, 96, 2, 0, 2, 97, 2, 46, 2, 0, 0, 4351, 2, 0, 2, 9, 3, 0, 2, 0, 67043391, 0, 3909091327, 2, 0, 2, 24, 2, 9, 2, 20, 3, 0, 2, 0, 67076097, 2, 8, 2, 0, 2, 21, 0, 67059711, 0, 4236247039, 3, 0, 2, 0, 939524103, 0, 8191999, 2, 101, 2, 102, 2, 22, 2, 23, 3, 0, 3, 0, 67057663, 3, 0, 349, 2, 103, 2, 104, 2, 7, -264, 3, 0, 11, 2, 24, 3, 0, 2, 2, 32, -1, 0, 3774349439, 2, 105, 2, 106, 3, 0, 2, 2, 19, 2, 107, 3, 0, 10, 2, 10, 2, 18, 2, 0, 2, 47, 2, 0, 2, 31, 2, 108, 2, 25, 0, 1638399, 0, 57344, 2, 109, 3, 0, 3, 2, 20, 2, 26, 2, 27, 2, 5, 2, 28, 2, 0, 2, 8, 2, 111, -1, 2, 112, 2, 113, 2, 114, -1, 3, 0, 3, 2, 12, -2, 2, 0, 2, 29, -3, 0, 536870912, -4, 2, 20, 2, 0, 2, 36, 0, 1, 2, 0, 2, 67, 2, 6, 2, 12, 2, 10, 2, 0, 2, 115, -1, 3, 0, 4, 2, 10, 2, 23, 2, 116, 2, 7, 2, 0, 2, 117, 2, 0, 2, 118, 2, 119, 2, 120, 2, 0, 2, 9, 3, 0, 9, 2, 21, 2, 30, 2, 31, 2, 121, 2, 122, -2, 2, 123, 2, 124, 2, 30, 2, 21, 2, 8, -2, 2, 125, 2, 30, 2, 32, -2, 2, 0, 2, 39, -2, 0, 4277137519, 0, 2269118463, -1, 3, 20, 2, -1, 2, 33, 2, 38, 2, 0, 3, 30, 2, 2, 35, 2, 19, -3, 3, 0, 2, 2, 34, -1, 2, 0, 2, 35, 2, 0, 2, 35, 2, 0, 2, 48, 2, 0, 0, 4294950463, 2, 37, -7, 2, 0, 0, 203775, 2, 57, 0, 4026531840, 2, 20, 2, 43, 2, 36, 2, 18, 2, 37, 2, 18, 2, 126, 2, 21, 3, 0, 2, 2, 38, 0, 2151677888, 2, 0, 2, 12, 0, 4294901764, 2, 144, 2, 0, 2, 58, 2, 56, 0, 5242879, 3, 0, 2, 0, 402644511, -1, 2, 128, 2, 39, 0, 3, -1, 2, 129, 2, 130, 2, 0, 0, 67045375, 2, 40, 0, 4226678271, 0, 3766565279, 0, 2039759, 2, 132, 2, 41, 0, 1046437, 0, 6, 3, 0, 2, 0, 3288270847, 0, 3, 3, 0, 2, 0, 67043519, -5, 2, 0, 0, 4282384383, 0, 1056964609, -1, 3, 0, 2, 0, 67043345, -1, 2, 0, 2, 42, 2, 23, 2, 50, 2, 11, 2, 61, 2, 38, -5, 2, 0, 2, 12, -3, 3, 0, 2, 0, 2147484671, 2, 134, 0, 4190109695, 2, 52, -2, 2, 135, 0, 4244635647, 0, 27, 2, 0, 2, 8, 2, 43, 2, 0, 2, 68, 2, 18, 2, 0, 2, 42, -6, 2, 0, 2, 45, 2, 59, 2, 44, 2, 45, 2, 46, 2, 47, 0, 8388351, -2, 2, 136, 0, 3028287487, 2, 48, 2, 138, 0, 33259519, 2, 49, -9, 2, 21, 0, 4294836223, 0, 3355443199, 0, 134152199, -2, 2, 69, -2, 3, 0, 28, 2, 32, -3, 3, 0, 3, 2, 17, 3, 0, 6, 2, 50, -81, 2, 18, 3, 0, 2, 2, 36, 3, 0, 33, 2, 25, 2, 30, 3, 0, 124, 2, 12, 3, 0, 18, 2, 38, -213, 2, 0, 2, 32, -54, 3, 0, 17, 2, 42, 2, 8, 2, 23, 2, 0, 2, 8, 2, 23, 2, 51, 2, 0, 2, 21, 2, 52, 2, 139, 2, 25, -13, 2, 0, 2, 53, -6, 3, 0, 2, -4, 3, 0, 2, 0, 4294936575, 2, 0, 0, 4294934783, -2, 0, 196635, 3, 0, 191, 2, 54, 3, 0, 38, 2, 30, 2, 55, 2, 34, -278, 2, 140, 3, 0, 9, 2, 141, 2, 142, 2, 56, 3, 0, 11, 2, 7, -72, 3, 0, 3, 2, 143, 0, 1677656575, -130, 2, 26, -16, 2, 0, 2, 24, 2, 38, -16, 0, 4161266656, 0, 4071, 0, 15360, -4, 2, 57, -13, 3, 0, 2, 2, 58, 2, 0, 2, 145, 2, 146, 2, 62, 2, 0, 2, 147, 2, 148, 2, 149, 3, 0, 10, 2, 150, 2, 151, 2, 22, 3, 58, 2, 3, 152, 2, 3, 59, 2, 0, 4294954999, 2, 0, -16, 2, 0, 2, 92, 2, 0, 0, 2105343, 0, 4160749584, 0, 65534, -34, 2, 8, 2, 154, -6, 0, 4194303871, 0, 4294903771, 2, 0, 2, 60, 2, 100, -3, 2, 0, 0, 1073684479, 0, 17407, -9, 2, 18, 2, 17, 2, 0, 2, 32, -14, 2, 18, 2, 32, -6, 2, 18, 2, 12, -15, 2, 155, 3, 0, 6, 0, 8323103, -1, 3, 0, 2, 2, 61, -37, 2, 62, 2, 156, 2, 157, 2, 158, 2, 159, 2, 160, -105, 2, 26, -32, 3, 0, 1335, -1, 3, 0, 129, 2, 32, 3, 0, 6, 2, 10, 3, 0, 180, 2, 161, 3, 0, 233, 2, 162, 3, 0, 18, 2, 10, -77, 3, 0, 16, 2, 10, -47, 3, 0, 154, 2, 6, 3, 0, 130, 2, 25, -22250, 3, 0, 7, 2, 25, -6130, 3, 5, 2, -1, 0, 69207040, 3, 44, 2, 3, 0, 14, 2, 63, 2, 64, -3, 0, 3168731136, 0, 4294956864, 2, 1, 2, 0, 2, 41, 3, 0, 4, 0, 4294966275, 3, 0, 4, 2, 16, 2, 65, 2, 0, 2, 34, -1, 2, 18, 2, 66, -1, 2, 0, 0, 2047, 0, 4294885376, 3, 0, 2, 0, 3145727, 0, 2617294944, 0, 4294770688, 2, 25, 2, 67, 3, 0, 2, 0, 131135, 2, 98, 0, 70256639, 0, 71303167, 0, 272, 2, 42, 2, 6, 0, 32511, 2, 0, 2, 49, -1, 2, 99, 2, 68, 0, 4278255616, 0, 4294836227, 0, 4294549473, 0, 600178175, 0, 2952806400, 0, 268632067, 0, 4294543328, 0, 57540095, 0, 1577058304, 0, 1835008, 0, 4294688736, 2, 70, 2, 69, 0, 33554435, 2, 131, 2, 70, 0, 2952790016, 0, 131075, 0, 3594373096, 0, 67094296, 2, 69, -1, 0, 4294828000, 0, 603979263, 0, 654311424, 0, 3, 0, 4294828001, 0, 602930687, 0, 1610612736, 0, 393219, 0, 4294828016, 0, 671088639, 0, 2154840064, 0, 4227858435, 0, 4236247008, 2, 71, 2, 38, -1, 2, 4, 0, 917503, 2, 38, -1, 2, 72, 0, 537788335, 0, 4026531935, -1, 0, 1, -1, 2, 33, 2, 73, 0, 7936, -3, 2, 0, 0, 2147485695, 0, 1010761728, 0, 4292984930, 0, 16387, 2, 0, 2, 15, 2, 22, 3, 0, 10, 2, 74, 2, 0, 2, 75, 2, 76, 2, 77, 2, 0, 2, 78, 2, 0, 2, 12, -1, 2, 25, 3, 0, 2, 2, 13, 2, 4, 3, 0, 18, 2, 79, 2, 5, 3, 0, 2, 2, 80, 0, 2147745791, 3, 19, 2, 0, 122879, 2, 0, 2, 9, 0, 276824064, -2, 3, 0, 2, 2, 42, 2, 0, 0, 4294903295, 2, 0, 2, 30, 2, 8, -1, 2, 18, 2, 51, 2, 0, 2, 81, 2, 49, -1, 2, 21, 2, 0, 2, 29, -2, 0, 128, -2, 2, 28, 2, 9, 0, 8160, -1, 2, 127, 0, 4227907585, 2, 0, 2, 37, 2, 0, 2, 50, 0, 4227915776, 2, 10, 2, 6, 2, 11, -1, 0, 74440192, 3, 0, 6, -2, 3, 0, 8, 2, 13, 2, 0, 2, 82, 2, 10, 2, 0, 2, 83, 2, 84, 2, 85, -3, 2, 86, 2, 14, -3, 2, 87, 2, 88, 2, 89, 2, 0, 2, 34, -83, 3, 0, 7, 0, 817183, 2, 0, 2, 15, 2, 0, 0, 33023, 2, 21, 3, 90, 2, -17, 2, 91, 0, 524157950, 2, 4, 2, 0, 2, 92, 2, 4, 2, 0, 2, 22, 2, 28, 2, 16, 3, 0, 2, 2, 17, 2, 0, -1, 2, 18, -16, 3, 0, 206, -2, 3, 0, 692, 2, 73, -1, 2, 18, 2, 10, 3, 0, 8, 2, 93, 0, 3072, 2, 0, 0, 2147516415, 2, 10, 3, 0, 2, 2, 25, 2, 94, 2, 95, 3, 0, 2, 2, 96, 2, 0, 2, 97, 2, 46, 0, 4294965179, 0, 7, 2, 0, 2, 9, 2, 95, 2, 9, -1, 0, 1761345536, 2, 98, 0, 4294901823, 2, 38, 2, 20, 2, 99, 2, 35, 2, 100, 0, 2080440287, 2, 0, 2, 34, 2, 153, 0, 3296722943, 2, 0, 0, 1046675455, 0, 939524101, 0, 1837055, 2, 101, 2, 102, 2, 22, 2, 23, 3, 0, 3, 0, 7, 3, 0, 349, 2, 103, 2, 104, 2, 7, -264, 3, 0, 11, 2, 24, 3, 0, 2, 2, 32, -1, 0, 2700607615, 2, 105, 2, 106, 3, 0, 2, 2, 19, 2, 107, 3, 0, 10, 2, 10, 2, 18, 2, 0, 2, 47, 2, 0, 2, 31, 2, 108, -3, 2, 109, 3, 0, 3, 2, 20, -1, 3, 5, 2, 2, 110, 2, 0, 2, 8, 2, 111, -1, 2, 112, 2, 113, 2, 114, -1, 3, 0, 3, 2, 12, -2, 2, 0, 2, 29, -8, 2, 20, 2, 0, 2, 36, -1, 2, 0, 2, 67, 2, 6, 2, 30, 2, 10, 2, 0, 2, 115, -1, 3, 0, 4, 2, 10, 2, 18, 2, 116, 2, 7, 2, 0, 2, 117, 2, 0, 2, 118, 2, 119, 2, 120, 2, 0, 2, 9, 3, 0, 9, 2, 21, 2, 30, 2, 31, 2, 121, 2, 122, -2, 2, 123, 2, 124, 2, 30, 2, 21, 2, 8, -2, 2, 125, 2, 30, 2, 32, -2, 2, 0, 2, 39, -2, 0, 4277075969, 2, 30, -1, 3, 20, 2, -1, 2, 33, 2, 126, 2, 0, 3, 30, 2, 2, 35, 2, 19, -3, 3, 0, 2, 2, 34, -1, 2, 0, 2, 35, 2, 0, 2, 35, 2, 0, 2, 50, 2, 98, 0, 4294934591, 2, 37, -7, 2, 0, 0, 197631, 2, 57, -1, 2, 20, 2, 43, 2, 37, 2, 18, 0, 3, 2, 18, 2, 126, 2, 21, 2, 127, 2, 54, -1, 0, 2490368, 2, 127, 2, 25, 2, 18, 2, 34, 2, 127, 2, 38, 0, 4294901904, 0, 4718591, 2, 127, 2, 35, 0, 335544350, -1, 2, 128, 0, 2147487743, 0, 1, -1, 2, 129, 2, 130, 2, 8, -1, 2, 131, 2, 70, 0, 3758161920, 0, 3, 2, 132, 0, 12582911, 0, 655360, -1, 2, 0, 2, 29, 0, 2147485568, 0, 3, 2, 0, 2, 25, 0, 176, -5, 2, 0, 2, 17, 0, 251658240, -1, 2, 0, 2, 25, 0, 16, -1, 2, 0, 0, 16779263, -2, 2, 12, -1, 2, 38, -5, 2, 0, 2, 133, -3, 3, 0, 2, 2, 55, 2, 134, 0, 2147549183, 0, 2, -2, 2, 135, 2, 36, 0, 10, 0, 4294965249, 0, 67633151, 0, 4026597376, 2, 0, 0, 536871935, 2, 18, 2, 0, 2, 42, -6, 2, 0, 0, 1, 2, 59, 2, 17, 0, 1, 2, 46, 2, 25, -3, 2, 136, 2, 36, 2, 137, 2, 138, 0, 16778239, -10, 2, 35, 0, 4294836212, 2, 9, -3, 2, 69, -2, 3, 0, 28, 2, 32, -3, 3, 0, 3, 2, 17, 3, 0, 6, 2, 50, -81, 2, 18, 3, 0, 2, 2, 36, 3, 0, 33, 2, 25, 0, 126, 3, 0, 124, 2, 12, 3, 0, 18, 2, 38, -213, 2, 10, -55, 3, 0, 17, 2, 42, 2, 8, 2, 18, 2, 0, 2, 8, 2, 18, 2, 60, 2, 0, 2, 25, 2, 50, 2, 139, 2, 25, -13, 2, 0, 2, 73, -6, 3, 0, 2, -4, 3, 0, 2, 0, 67583, -1, 2, 107, -2, 0, 11, 3, 0, 191, 2, 54, 3, 0, 38, 2, 30, 2, 55, 2, 34, -278, 2, 140, 3, 0, 9, 2, 141, 2, 142, 2, 56, 3, 0, 11, 2, 7, -72, 3, 0, 3, 2, 143, 2, 144, -187, 3, 0, 2, 2, 58, 2, 0, 2, 145, 2, 146, 2, 62, 2, 0, 2, 147, 2, 148, 2, 149, 3, 0, 10, 2, 150, 2, 151, 2, 22, 3, 58, 2, 3, 152, 2, 3, 59, 2, 2, 153, -57, 2, 8, 2, 154, -7, 2, 18, 2, 0, 2, 60, -4, 2, 0, 0, 1065361407, 0, 16384, -9, 2, 18, 2, 60, 2, 0, 2, 133, -14, 2, 18, 2, 133, -6, 2, 18, 0, 81919, -15, 2, 155, 3, 0, 6, 2, 126, -1, 3, 0, 2, 0, 2063, -37, 2, 62, 2, 156, 2, 157, 2, 158, 2, 159, 2, 160, -138, 3, 0, 1335, -1, 3, 0, 129, 2, 32, 3, 0, 6, 2, 10, 3, 0, 180, 2, 161, 3, 0, 233, 2, 162, 3, 0, 18, 2, 10, -77, 3, 0, 16, 2, 10, -47, 3, 0, 154, 2, 6, 3, 0, 130, 2, 25, -28386], [4294967295, 4294967291, 4092460543, 4294828031, 4294967294, 134217726, 4294903807, 268435455, 2147483647, 1048575, 1073741823, 3892314111, 134217727, 1061158911, 536805376, 4294910143, 4294901759, 32767, 4294901760, 262143, 536870911, 8388607, 4160749567, 4294902783, 4294918143, 65535, 67043328, 2281701374, 4294967264, 2097151, 4194303, 255, 67108863, 4294967039, 511, 524287, 131071, 63, 127, 3238002687, 4294549487, 4290772991, 33554431, 4294901888, 4286578687, 67043329, 4294705152, 4294770687, 67043583, 1023, 15, 2047999, 67043343, 67051519, 16777215, 2147483648, 4294902000, 28, 4292870143, 4294966783, 16383, 67047423, 4294967279, 262083, 20511, 41943039, 493567, 4294959104, 603979775, 65536, 602799615, 805044223, 4294965206, 8191, 1031749119, 4294917631, 2134769663, 4286578493, 4282253311, 4294942719, 33540095, 4294905855, 2868854591, 1608515583, 265232348, 534519807, 2147614720, 1060109444, 4093640016, 17376, 2139062143, 224, 4169138175, 4294909951, 4286578688, 4294967292, 4294965759, 535511039, 4294966272, 4294967280, 32768, 8289918, 4294934399, 4294901775, 4294965375, 1602223615, 4294967259, 4294443008, 268369920, 4292804608, 4294967232, 486341884, 4294963199, 3087007615, 1073692671, 4128527, 4279238655, 4294902015, 4160684047, 4290246655, 469499899, 4294967231, 134086655, 4294966591, 2445279231, 3670015, 31, 4294967288, 4294705151, 3221208447, 4294902271, 4294549472, 4294921215, 4095, 4285526655, 4294966527, 4294966143, 64, 4294966719, 3774873592, 1877934080, 262151, 2555904, 536807423, 67043839, 3758096383, 3959414372, 3755993023, 2080374783, 4294835295, 4294967103, 4160749565, 4294934527, 4087, 2016, 2147446655, 184024726, 2862017156, 1593309078, 268434431, 268434414, 4294901763, 4294901761]); const isIDContinue = (code) => (unicodeLookup[(code >>> 5) + 0] >>> code & 31 & 1) !== 0; const isIDStart = (code) => (unicodeLookup[(code >>> 5) + 34816] >>> code & 31 & 1) !== 0; function advanceChar(parser) { parser.column++; return (parser.currentChar = parser.source.charCodeAt(++parser.index)); } function consumePossibleSurrogatePair(parser) { const hi = parser.currentChar; if ((hi & 0xfc00) !== 55296) return 0; const lo = parser.source.charCodeAt(parser.index + 1); if ((lo & 0xfc00) !== 56320) return 0; return 65536 + ((hi & 0x3ff) << 10) + (lo & 0x3ff); } function consumeLineFeed(parser, state) { parser.currentChar = parser.source.charCodeAt(++parser.index); parser.flags |= 1; if ((state & 4) === 0) { parser.column = 0; parser.line++; } } function scanNewLine(parser) { parser.flags |= 1; parser.currentChar = parser.source.charCodeAt(++parser.index); parser.column = 0; parser.line++; } function isExoticECMAScriptWhitespace(ch) { return (ch === 160 || ch === 65279 || ch === 133 || ch === 5760 || (ch >= 8192 && ch <= 8203) || ch === 8239 || ch === 8287 || ch === 12288 || ch === 8201 || ch === 65519); } function toHex(code) { return code < 65 ? code - 48 : (code - 65 + 10) & 0xf; } function convertTokenType(t) { switch (t) { case 134283266: return 'NumericLiteral'; case 134283267: return 'StringLiteral'; case 86021: case 86022: return 'BooleanLiteral'; case 86023: return 'NullLiteral'; case 65540: return 'RegularExpression'; case 67174408: case 67174409: case 131: return 'TemplateLiteral'; default: if ((t & 143360) === 143360) return 'Identifier'; if ((t & 4096) === 4096) return 'Keyword'; return 'Punctuator'; } } const CharTypes = [ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 8 | 1024, 0, 0, 8 | 2048, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 8192, 0, 1 | 2, 0, 0, 8192, 0, 0, 0, 256, 0, 256 | 32768, 0, 0, 2 | 16 | 128 | 32 | 64, 2 | 16 | 128 | 32 | 64, 2 | 16 | 32 | 64, 2 | 16 | 32 | 64, 2 | 16 | 32 | 64, 2 | 16 | 32 | 64, 2 | 16 | 32 | 64, 2 | 16 | 32 | 64, 2 | 16 | 512 | 64, 2 | 16 | 512 | 64, 0, 0, 16384, 0, 0, 0, 0, 1 | 2 | 64, 1 | 2 | 64, 1 | 2 | 64, 1 | 2 | 64, 1 | 2 | 64, 1 | 2 | 64, 1 | 2, 1 | 2, 1 | 2, 1 | 2, 1 | 2, 1 | 2, 1 | 2, 1 | 2, 1 | 2, 1 | 2, 1 | 2, 1 | 2, 1 | 2, 1 | 2, 1 | 2, 1 | 2, 1 | 2, 1 | 2, 1 | 2, 1 | 2, 0, 1, 0, 0, 1 | 2 | 4096, 0, 1 | 2 | 4 | 64, 1 | 2 | 4 | 64, 1 | 2 | 4 | 64, 1 | 2 | 4 | 64, 1 | 2 | 4 | 64, 1 | 2 | 4 | 64, 1 | 2 | 4, 1 | 2 | 4, 1 | 2 | 4, 1 | 2 | 4, 1 | 2 | 4, 1 | 2 | 4, 1 | 2 | 4, 1 | 2 | 4, 1 | 2 | 4, 1 | 2 | 4, 1 | 2 | 4, 1 | 2 | 4, 1 | 2 | 4, 1 | 2 | 4, 1 | 2 | 4, 1 | 2 | 4, 1 | 2 | 4, 1 | 2 | 4, 1 | 2 | 4, 1 | 2 | 4, 16384, 0, 0, 0, 0 ]; const isIdStart = [ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0 ]; const isIdPart = [ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0 ]; function isIdentifierStart(code) { return code <= 0x7F ? isIdStart[code] > 0 : isIDStart(code); } function isIdentifierPart(code) { return code <= 0x7F ? isIdPart[code] > 0 : isIDContinue(code) || (code === 8204 || code === 8205); } const CommentTypes = ['SingleLine', 'MultiLine', 'HTMLOpen', 'HTMLClose', 'HashbangComment']; function skipHashBang(parser) { const { source } = parser; if (parser.currentChar === 35 && source.charCodeAt(parser.index + 1) === 33) { advanceChar(parser); advanceChar(parser); skipSingleLineComment(parser, source, 0, 4, parser.tokenStart); } } function skipSingleHTMLComment(parser, source, state, context, type, start) { if (context & 2) parser.report(0); return skipSingleLineComment(parser, source, state, type, start); } function skipSingleLineComment(parser, source, state, type, start) { const { index } = parser; parser.tokenIndex = parser.index; parser.tokenLine = parser.line; parser.tokenColumn = parser.column; while (parser.index < parser.end) { if (CharTypes[parser.currentChar] & 8) { const isCR = parser.currentChar === 13; scanNewLine(parser); if (isCR && parser.index < parser.end && parser.currentChar === 10) parser.currentChar = source.charCodeAt(++parser.index); break; } else if ((parser.currentChar ^ 8232) <= 1) { scanNewLine(parser); break; } advanceChar(parser); parser.tokenIndex = parser.index; parser.tokenLine = parser.line; parser.tokenColumn = parser.column; } if (parser.options.onComment) { const loc = { start: { line: start.line, column: start.column, }, end: { line: parser.tokenLine, column: parser.tokenColumn, }, }; parser.options.onComment(CommentTypes[type & 0xff], source.slice(index, parser.tokenIndex), start.index, parser.tokenIndex, loc); } return state | 1; } function skipMultiLineComment(parser, source, state) { const { index } = parser; while (parser.index < parser.end) { if (parser.currentChar < 0x2b) { let skippedOneAsterisk = false; while (parser.currentChar === 42) { if (!skippedOneAsterisk) { state &= -5; skippedOneAsterisk = true; } if (advanceChar(parser) === 47) { advanceChar(parser); if (parser.options.onComment) { const loc = { start: { line: parser.tokenLine, column: parser.tokenColumn, }, end: { line: parser.line, column: parser.column, }, }; parser.options.onComment(CommentTypes[1 & 0xff], source.slice(index, parser.index - 2), index - 2, parser.index, loc); } parser.tokenIndex = parser.index; parser.tokenLine = parser.line; parser.tokenColumn = parser.column; return state; } } if (skippedOneAsterisk) { continue; } if (CharTypes[parser.currentChar] & 8) { if (parser.currentChar === 13) { state |= 1 | 4; scanNewLine(parser); } else { consumeLineFeed(parser, state); state = (state & -5) | 1; } } else { advanceChar(parser); } } else if ((parser.currentChar ^ 8232) <= 1) { state = (state & -5) | 1; scanNewLine(parser); } else { state &= -5; advanceChar(parser); } } parser.report(18); } var RegexState; (function (RegexState) { RegexState[RegexState["Empty"] = 0] = "Empty"; RegexState[RegexState["Escape"] = 1] = "Escape"; RegexState[RegexState["Class"] = 2] = "Class"; })(RegexState || (RegexState = {})); var RegexFlags; (function (RegexFlags) { RegexFlags[RegexFlags["Empty"] = 0] = "Empty"; RegexFlags[RegexFlags["IgnoreCase"] = 1] = "IgnoreCase"; RegexFlags[RegexFlags["Global"] = 2] = "Global"; RegexFlags[RegexFlags["Multiline"] = 4] = "Multiline"; RegexFlags[RegexFlags["Unicode"] = 16] = "Unicode"; RegexFlags[RegexFlags["Sticky"] = 8] = "Sticky"; RegexFlags[RegexFlags["DotAll"] = 32] = "DotAll"; RegexFlags[RegexFlags["Indices"] = 64] = "Indices"; RegexFlags[RegexFlags["UnicodeSets"] = 128] = "UnicodeSets"; })(RegexFlags || (RegexFlags = {})); function scanRegularExpression(parser) { const bodyStart = parser.index; let preparseState = RegexState.Empty; loop: while (true) { const ch = parser.currentChar; advanceChar(parser); if (preparseState & RegexState.Escape) { preparseState &= ~RegexState.Escape; } else { switch (ch) { case 47: if (!preparseState) break loop; else break; case 92: preparseState |= RegexState.Escape; break; case 91: preparseState |= RegexState.Class; break; case 93: preparseState &= RegexState.Escape; break; } } if (ch === 13 || ch === 10 || ch === 8232 || ch === 8233) { parser.report(34); } if (parser.index >= parser.source.length) { return parser.report(34); } } const bodyEnd = parser.index - 1; let mask = RegexFlags.Empty; let char = parser.currentChar; const { index: flagStart } = parser; while (isIdentifierPart(char)) { switch (char) { case 103: if (mask & RegexFlags.Global) parser.report(36, 'g'); mask |= RegexFlags.Global; break; case 105: if (mask & RegexFlags.IgnoreCase) parser.report(36, 'i'); mask |= RegexFlags.IgnoreCase; break; case 109: if (mask & RegexFlags.Multiline) parser.report(36, 'm'); mask |= RegexFlags.Multiline; break; case 117: if (mask & RegexFlags.Unicode) parser.report(36, 'u'); if (mask & RegexFlags.UnicodeSets) parser.report(36, 'vu'); mask |= RegexFlags.Unicode; break; case 118: if (mask & RegexFlags.Unicode) parser.report(36, 'uv'); if (mask & RegexFlags.UnicodeSets) parser.report(36, 'v'); mask |= RegexFlags.UnicodeSets; break; case 121: if (mask & RegexFlags.Sticky) parser.report(36, 'y'); mask |= RegexFlags.Sticky; break; case 115: if (mask & RegexFlags.DotAll) parser.report(36, 's'); mask |= RegexFlags.DotAll; break; case 100: if (mask & RegexFlags.Indices) parser.report(36, 'd'); mask |= RegexFlags.Indices; break; default: parser.report(35); } char = advanceChar(parser); } const flags = parser.source.slice(flagStart, parser.index); const pattern = parser.source.slice(bodyStart, bodyEnd); parser.tokenRegExp = { pattern, flags }; if (parser.options.raw) parser.tokenRaw = parser.source.slice(parser.tokenIndex, parser.index); parser.tokenValue = validate(parser, pattern, flags); return 65540; } function validate(parser, pattern, flags) { try { return new RegExp(pattern, flags); } catch { try { new RegExp(pattern, flags); return null; } catch { parser.report(34); } } } function scanString(parser, context, quote) { const { index: start } = parser; let ret = ''; let char = advanceChar(parser); let marker = parser.index; while ((CharTypes[char] & 8) === 0) { if (char === quote) { ret += parser.source.slice(marker, parser.index); advanceChar(parser); if (parser.options.raw) parser.tokenRaw = parser.source.slice(start, parser.index); parser.tokenValue = ret; return 134283267; } if ((char & 8) === 8 && char === 92) { ret += parser.source.slice(marker, parser.index); char = advanceChar(parser); if (char < 0x7f || char === 8232 || char === 8233) { const code = parseEscape(parser, context, char); if (code >= 0) ret += String.fromCodePoint(code); else handleStringError(parser, code, 0); } else { ret += String.fromCodePoint(char); } marker = parser.index + 1; } else if (char === 8232 || char === 8233) { parser.column = -1; parser.line++; } if (parser.index >= parser.end) parser.report(16); char = advanceChar(parser); } parser.report(16); } function parseEscape(parser, context, first, isTemplate = 0) { switch (first) { case 98: return 8; case 102: return 12; case 114: return 13; case 110: return 10; case 116: return 9; case 118: return 11; case 13: { if (parser.index < parser.end) { const nextChar = parser.source.charCodeAt(parser.index + 1); if (nextChar === 10) { parser.index = parser.index + 1; parser.currentChar = nextChar; } } } case 10: case 8232: case 8233: parser.column = -1; parser.line++; return -1; case 48: case 49: case 50: case 51: { let code = first - 48; let index = parser.index + 1; let column = parser.column + 1; if (index < parser.end) { const next = parser.source.charCodeAt(index); if ((CharTypes[next] & 32) === 0) { if (code !== 0 || CharTypes[next] & 512) { if (context & 1 || isTemplate) return -2; parser.flags |= 64; } } else if (context & 1 || isTemplate) { return -2; } else { parser.currentChar = next; code = (code << 3) | (next - 48); index++; column++; if (index < parser.end) { const next = parser.source.charCodeAt(index); if (CharTypes[next] & 32) { parser.currentChar = next; code = (code << 3) | (next - 48); index++; column++; } } parser.flags |= 64; } parser.index = index - 1; parser.column = column - 1; } return code; } case 52: case 53: case 54: case 55: { if (isTemplate || context & 1) return -2; let code = first - 48; const index = parser.index + 1; const column = parser.column + 1; if (index < parser.end) { const next = parser.source.charCodeAt(index); if (CharTypes[next] & 32) { code = (code << 3) | (next - 48); parser.currentChar = next; parser.index = index; parser.column = column; } } parser.flags |= 64; return code; } case 120: { const ch1 = advanceChar(parser); if ((CharTypes[ch1] & 64) === 0) return -4; const hi = toHex(ch1); const ch2 = advanceChar(parser); if ((CharTypes[ch2] & 64) === 0) return -4; const lo = toHex(ch2); return (hi << 4) | lo; } case 117: { const ch = advanceChar(parser); if (parser.currentChar === 123) { let code = 0; while ((CharTypes[advanceChar(parser)] & 64) !== 0) { code = (code << 4) | toHex(parser.currentChar); if (code > 1114111) return -5; } if (parser.currentChar < 1 || parser.currentChar !== 125) { return -4; } return code; } else { if ((CharTypes[ch] & 64) === 0) return -4; const ch2 = parser.source.charCodeAt(parser.index + 1); if ((CharTypes[ch2] & 64) === 0) return -4; const ch3 = parser.source.charCodeAt(parser.index + 2); if ((CharTypes[ch3] & 64) === 0) return -4; const ch4 = parser.source.charCodeAt(parser.index + 3); if ((CharTypes[ch4] & 64) === 0) return -4; parser.index += 3; parser.column += 3; parser.currentChar = parser.source.charCodeAt(parser.index); return (toHex(ch) << 12) | (toHex(ch2) << 8) | (toHex(ch3) << 4) | toHex(ch4); } } case 56: case 57: if (isTemplate || !parser.options.webcompat || context & 1) return -3; parser.flags |= 4096; default: return first; } } function handleStringError(parser, code, isTemplate) { switch (code) { case -1: return; case -2: parser.report(isTemplate ? 2 : 1); case -3: parser.report(isTemplate ? 3 : 14); case -4: parser.report(7); case -5: parser.report(104); } } function scanTemplate(parser, context) { const { index: start } = parser; let token = 67174409; let ret = ''; let char = advanceChar(parser); while (char !== 96) { if (char === 36 && parser.source.charCodeAt(parser.index + 1) === 123) { advanceChar(parser); token = 67174408; break; } else if (char === 92) { char = advanceChar(parser); if (char > 0x7e) { ret += String.fromCodePoint(char); } else { const { index, line, column } = parser; const code = parseEscape(parser, context | 1, char, 1); if (code >= 0) { ret += String.fromCodePoint(code); } else if (code !== -1 && context & 64) { parser.index = index; parser.line = line; parser.column = column; ret = null; char = scanBadTemplate(parser, char); if (char < 0) token = 67174408; break; } else { handleStringError(parser, code, 1); } } } else if (parser.index < parser.end) { if (char === 13 && parser.source.charCodeAt(parser.index) === 10) { ret += String.fromCodePoint(char); parser.currentChar = parser.source.charCodeAt(++parser.index); } if (((char & 83) < 3 && char === 10) || (char ^ 8232) <= 1) { parser.column = -1; parser.line++; } ret += String.fromCodePoint(char); } if (parser.index >= parser.end) parser.report(17); char = advanceChar(parser); } advanceChar(parser); parser.tokenValue = ret; parser.tokenRaw = parser.source.slice(start + 1, parser.index - (token === 67174409 ? 1 : 2)); return token; } function scanBadTemplate(parser, ch) { while (ch !== 96) { switch (ch) { case 36: { const index = parser.index + 1; if (index < parser.end && parser.source.charCodeAt(index) === 123) { parser.index = index; parser.column++; return -ch; } break; } case 10: case 8232: case 8233: parser.column = -1; parser.line++; } if (parser.index >= parser.end) parser.report(17); ch = advanceChar(parser); } return ch; } function scanTemplateTail(parser, context) { if (parser.index >= parser.end) parser.report(0); parser.index--; parser.column--; return scanTemplate(parser, context); } const errorMessages = { [0]: 'Unexpected token', [30]: "Unexpected token: '%0'", [1]: 'Octal escape sequences are not allowed in strict mode', [2]: 'Octal escape sequences are not allowed in template strings', [3]: '\\8 and \\9 are not allowed in template strings', [4]: 'Private identifier #%0 is not defined', [5]: 'Illegal Unicode escape sequence', [6]: 'Invalid code point %0', [7]: 'Invalid hexadecimal escape sequence', [9]: 'Octal literals are not allowed in strict mode', [8]: 'Decimal integer literals with a leading zero are forbidden in strict mode', [10]: 'Expected number in radix %0', [151]: 'Invalid left-hand side assignment to a destructible right-hand side', [11]: 'Non-number found after exponent indicator', [12]: 'Invalid BigIntLiteral', [13]: 'No identifiers allowed directly after numeric literal', [14]: 'Escapes \\8 or \\9 are not syntactically valid escapes', [15]: 'Escapes \\8 or \\9 are not allowed in strict mode', [16]: 'Unterminated string literal', [17]: 'Unterminated template literal', [18]: 'Multiline comment was not closed properly', [19]: 'The identifier contained dynamic unicode escape that was not closed', [20]: "Illegal character '%0'", [21]: 'Missing hexadecimal digits', [22]: 'Invalid implicit octal', [23]: 'Invalid line break in string literal', [24]: 'Only unicode escapes are legal in identifier names', [25]: "Expected '%0'", [26]: 'Invalid left-hand side in assignment', [27]: 'Invalid left-hand side in async arrow', [28]: 'Calls to super must be in the "constructor" method of a class expression or class declaration that has a superclass', [29]: 'Member access on super must be in a method', [31]: 'Await expression not allowed in formal parameter', [32]: 'Yield expression not allowed in formal parameter', [95]: "Unexpected token: 'escaped keyword'", [33]: 'Unary expressions as the left operand of an exponentiation expression must be disambiguated with parentheses', [123]: 'Async functions can only be declared at the top level or inside a block', [34]: 'Unterminated regular expression', [35]: 'Unexpected regular expression flag', [36]: "Duplicate regular expression flag '%0'", [37]: '%0 functions must have exactly %1 argument%2', [38]: 'Setter function argument must not be a rest parameter', [39]: '%0 declaration must have a name in this context', [40]: 'Function name may not contain any reserved words or be eval or arguments in strict mode', [41]: 'The rest operator is missing an argument', [42]: 'A getter cannot be a generator', [43]: 'A setter cannot be a generator', [44]: 'A computed property name must be followed by a colon or paren', [134]: 'Object literal keys that are strings or numbers must be a method or have a colon', [46]: 'Found `* async x(){}` but this should be `async * x(){}`', [45]: 'Getters and setters can not be generators', [47]: "'%0' can not be generator method", [48]: "No line break is allowed after '=>'", [49]: 'The left-hand side of the arrow can only be destructed through assignment', [50]: 'The binding declaration is not destructible', [51]: 'Async arrow can not be followed by new expression', [52]: "Classes may not have a static property named 'prototype'", [53]: 'Class constructor may not be a %0', [54]: 'Duplicate constructor method in class', [55]: 'Invalid increment/decrement operand', [56]: 'Invalid use of `new` keyword on an increment/decrement expression', [57]: '`=>` is an invalid assignment target', [58]: 'Rest element may not have a trailing comma', [59]: 'Missing initializer in %0 declaration', [60]: "'for-%0' loop head declarations can not have an initializer", [61]: 'Invalid left-hand side in for-%0 loop: Must have a single binding', [62]: 'Invalid shorthand property initializer', [63]: 'Property name __proto__ appears more than once in object literal', [64]: 'Let is disallowed as a lexically bound name', [65]: "Invalid use of '%0' inside new expression", [66]: "Illegal 'use strict' directive in function with non-simple parameter list", [67]: 'Identifier "let" disallowed as left-hand side expression in strict mode', [68]: 'Illegal continue statement', [69]: 'Illegal break statement', [70]: 'Cannot have `let[...]` as a var name in strict mode', [71]: 'Invalid destructuring assignment target', [72]: 'Rest parameter may not have a default initializer', [73]: 'The rest argument must the be last parameter', [74]: 'Invalid rest argument', [76]: 'In strict mode code, functions can only be declared at top level or inside a block', [77]: 'In non-strict mode code, functions can only be declared at top level, inside a block, or as the body of an if statement', [78]: 'Without web compatibility enabled functions can not be declared at top level, inside a block, or as the body of an if statement', [79]: "Class declaration can't appear in single-statement context", [80]: 'Invalid left-hand side in for-%0', [81]: 'Invalid assignment in for-%0', [82]: 'for await (... of ...) is only valid in async functions and async generators', [83]: 'The first token after the template expression should be a continuation of the template', [85]: '`let` declaration not allowed here and `let` cannot be a regular var name in strict mode', [84]: '`let \n [` is a restricted production at the start of a statement', [86]: 'Catch clause requires exactly one parameter, not more (and no trailing comma)', [87]: 'Catch clause parameter does not support default values', [88]: 'Missing catch or finally after try', [89]: 'More than one default clause in switch statement', [90]: 'Illegal newline after throw', [91]: 'Strict mode code may not include a with statement', [92]: 'Illegal return statement', [93]: 'The left hand side of the for-header binding declaration is not destructible', [94]: 'new.target only allowed within functions or static blocks', [96]: "'#' not followed by identifier", [102]: 'Invalid keyword', [101]: "Can not use 'let' as a class name", [100]: "'A lexical declaration can't define a 'let' binding", [99]: 'Can not use `let` as variable name in strict mode', [97]: "'%0' may not be used as an identifier in this context", [98]: 'Await is only valid in async functions', [103]: 'The %0 keyword can only be used with the module goal', [104]: 'Unicode codepoint must not be greater than 0x10FFFF', [105]: '%0 source must be string', [106]: 'Only a identifier or string can be used to indicate alias', [107]: "Only '*' or '{...}' can be imported after default", [108]: 'Trailing decorator may be followed by method', [109]: "Decorators can't be used with a constructor", [110]: 'Can not use `await` as identifier in module or async func', [111]: 'Can not use `await` as identifier in module', [112]: 'HTML comments are only allowed with web compatibility (Annex B)', [113]: "The identifier 'let' must not be in expression position in strict mode", [114]: 'Cannot assign to `eval` and `arguments` in strict mode', [115]: "The left-hand side of a for-of loop may not start with 'let'", [116]: 'Block body arrows can not be immediately invoked without a group', [117]: 'Block body arrows can not be immediately accessed without a group', [118]: 'Unexpected strict mode reserved word', [119]: 'Unexpected eval or arguments in strict mode', [120]: 'Decorators must not be followed by a semicolon', [121]: 'Calling delete on expression not allowed in strict mode', [122]: 'Pattern can not have a tail', [124]: 'Can not have a `yield` expression on the left side of a ternary', [125]: 'An arrow function can not have a postfix update operator', [126]: 'Invalid object literal key character after generator star', [127]: 'Private fields can not be deleted', [129]: 'Classes may not have a field called constructor', [128]: 'Classes may not have a private element named constructor', [130]: 'A class field initializer or static block may not contain arguments', [131]: 'Generators can only be declared at the top level or inside a block', [132]: 'Async methods are a restricted production and cannot have a newline following it', [133]: 'Unexpected character after object literal property name', [135]: 'Invalid key token', [136]: "Label '%0' has already been declared", [137]: 'continue statement must be nested within an iteration statement', [138]: "Undefined label '%0'", [139]: 'Trailing comma is disallowed inside import(...) arguments', [140]: 'Invalid binding in JSON import', [141]: 'import() requires exactly one argument', [142]: 'Cannot use new with import(...)', [143]: '... is not allowed in import()', [144]: "Expected '=>'", [145]: "Duplicate binding '%0'", [146]: 'Duplicate private identifier #%0', [147]: "Cannot export a duplicate name '%0'", [150]: 'Duplicate %0 for-binding', [148]: "Exported binding '%0' needs to refer to a top-level declared variable", [149]: 'Unexpected private field', [153]: 'Numeric separators are not allowed at the end of numeric literals', [152]: 'Only one underscore is allowed as numeric separator', [154]: 'JSX value should be either an expression or a quoted JSX text', [155]: 'Expected corresponding JSX closing tag for %0', [156]: 'Adjacent JSX elements must be wrapped in an enclosing tag', [157]: "JSX attributes must only be assigned a non-empty 'expression'", [158]: "'%0' has already been declared", [159]: "'%0' shadowed a catch clause binding", [160]: 'Dot property must be an identifier', [161]: 'Encountered invalid input after spread/rest argument', [162]: 'Catch without try', [163]: 'Finally without try', [164]: 'Expected corresponding closing tag for JSX fragment', [165]: 'Coalescing and logical operators used together in the same expression must be disambiguated with parentheses', [166]: 'Invalid tagged template on optional chain', [167]: 'Invalid optional chain from super property', [168]: 'Invalid optional chain from new expression', [169]: 'Cannot use "import.meta" outside a module', [170]: 'Leading decorators must be attached to a class declaration', [171]: 'An export name cannot include a lone surrogate, found %0', [172]: 'A string literal cannot be used as an exported binding without `from`', [173]: "Private fields can't be accessed on super", [174]: "The only valid meta property for import is 'import.meta'", [175]: "'import.meta' must not contain escaped characters", [176]: 'cannot use "await" as identifier inside an async function', [177]: 'cannot use "await" in static blocks', }; class ParseError extends SyntaxError { start; end; range; loc; description; constructor(start, end, type, ...params) { const description = errorMessages[type].replace(/%(\d+)/g, (_, i) => params[i]); const message = '[' + start.line + ':' + start.column + '-' + end.line + ':' + end.column + ']: ' + description; super(message); this.start = start.index; this.end = end.index; this.range = [start.index, end.index]; this.loc = { start: { line: start.line, column: start.column }, end: { line: end.line, column: end.column }, }; this.description = description; } } function scanNumber(parser, context, kind) { let char = parser.currentChar; let value = 0; let digit = 9; let atStart = kind & 64 ? 0 : 1; let digits = 0; let allowSeparator = 0; if (kind & 64) { value = '.' + scanDecimalDigitsOrSeparator(parser, char); char = parser.currentChar; if (char === 110) parser.report(12); } else { if (char === 48) { char = advanceChar(parser); if ((char | 32) === 120) { kind = 8 | 128; char = advanceChar(parser); while (CharTypes[char] & (64 | 4096)) { if (char === 95) { if (!allowSeparator) parser.report(152); allowSeparator = 0; char = advanceChar(parser); continue; } allowSeparator = 1; value = value * 0x10 + toHex(char); digits++; char = advanceChar(parser); } if (digits === 0 || !allowSeparator) { parser.report(digits === 0 ? 21 : 153); } } else if ((char | 32) === 111) { kind = 4 | 128; char = advanceChar(parser); while (CharTypes[char] & (32 | 4096)) { if (char === 95) { if (!allowSeparator) { parser.report(152); } allowSeparator = 0; char = advanceChar(parser); continue; }