@typescript-deploys/pr-build 5.3.0-pr-55820-7 → 5.3.0-pr-55600-27
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/tsc.js +1027 -152
- package/lib/tsserver.js +1041 -162
- package/lib/typescript.d.ts +15 -0
- package/lib/typescript.js +1040 -164
- package/lib/typingsInstaller.js +997 -72
- package/package.json +2 -2
package/lib/typingsInstaller.js
CHANGED
|
@@ -54,7 +54,7 @@ var path = __toESM(require("path"));
|
|
|
54
54
|
|
|
55
55
|
// src/compiler/corePublic.ts
|
|
56
56
|
var versionMajorMinor = "5.3";
|
|
57
|
-
var version = `${versionMajorMinor}.0-insiders.
|
|
57
|
+
var version = `${versionMajorMinor}.0-insiders.20230922`;
|
|
58
58
|
|
|
59
59
|
// src/compiler/core.ts
|
|
60
60
|
var emptyArray = [];
|
|
@@ -3198,6 +3198,24 @@ var ScriptKind = /* @__PURE__ */ ((ScriptKind3) => {
|
|
|
3198
3198
|
ScriptKind3[ScriptKind3["Deferred"] = 7] = "Deferred";
|
|
3199
3199
|
return ScriptKind3;
|
|
3200
3200
|
})(ScriptKind || {});
|
|
3201
|
+
var ScriptTarget = /* @__PURE__ */ ((ScriptTarget3) => {
|
|
3202
|
+
ScriptTarget3[ScriptTarget3["ES3"] = 0] = "ES3";
|
|
3203
|
+
ScriptTarget3[ScriptTarget3["ES5"] = 1] = "ES5";
|
|
3204
|
+
ScriptTarget3[ScriptTarget3["ES2015"] = 2] = "ES2015";
|
|
3205
|
+
ScriptTarget3[ScriptTarget3["ES2016"] = 3] = "ES2016";
|
|
3206
|
+
ScriptTarget3[ScriptTarget3["ES2017"] = 4] = "ES2017";
|
|
3207
|
+
ScriptTarget3[ScriptTarget3["ES2018"] = 5] = "ES2018";
|
|
3208
|
+
ScriptTarget3[ScriptTarget3["ES2019"] = 6] = "ES2019";
|
|
3209
|
+
ScriptTarget3[ScriptTarget3["ES2020"] = 7] = "ES2020";
|
|
3210
|
+
ScriptTarget3[ScriptTarget3["ES2021"] = 8] = "ES2021";
|
|
3211
|
+
ScriptTarget3[ScriptTarget3["ES2022"] = 9] = "ES2022";
|
|
3212
|
+
ScriptTarget3[ScriptTarget3["ES2023"] = 10] = "ES2023";
|
|
3213
|
+
ScriptTarget3[ScriptTarget3["ES2024"] = 11] = "ES2024";
|
|
3214
|
+
ScriptTarget3[ScriptTarget3["ESNext"] = 99] = "ESNext";
|
|
3215
|
+
ScriptTarget3[ScriptTarget3["JSON"] = 100] = "JSON";
|
|
3216
|
+
ScriptTarget3[ScriptTarget3["Latest"] = 99 /* ESNext */] = "Latest";
|
|
3217
|
+
return ScriptTarget3;
|
|
3218
|
+
})(ScriptTarget || {});
|
|
3201
3219
|
var TransformFlags = /* @__PURE__ */ ((TransformFlags3) => {
|
|
3202
3220
|
TransformFlags3[TransformFlags3["None"] = 0] = "None";
|
|
3203
3221
|
TransformFlags3[TransformFlags3["ContainsTypeScript"] = 1] = "ContainsTypeScript";
|
|
@@ -5469,6 +5487,43 @@ var Diagnostics = {
|
|
|
5469
5487
|
The_left_hand_side_of_a_for_in_statement_cannot_be_a_using_declaration: diag(1493, 1 /* Error */, "The_left_hand_side_of_a_for_in_statement_cannot_be_a_using_declaration_1493", "The left-hand side of a 'for...in' statement cannot be a 'using' declaration."),
|
|
5470
5488
|
The_left_hand_side_of_a_for_in_statement_cannot_be_an_await_using_declaration: diag(1494, 1 /* Error */, "The_left_hand_side_of_a_for_in_statement_cannot_be_an_await_using_declaration_1494", "The left-hand side of a 'for...in' statement cannot be an 'await using' declaration."),
|
|
5471
5489
|
_0_modifier_cannot_appear_on_an_await_using_declaration: diag(1495, 1 /* Error */, "_0_modifier_cannot_appear_on_an_await_using_declaration_1495", "'{0}' modifier cannot appear on an 'await using' declaration."),
|
|
5490
|
+
_0_is_not_a_valid_character_escape: diag(1496, 1 /* Error */, "_0_is_not_a_valid_character_escape_1496", "'\\{0}' is not a valid character escape."),
|
|
5491
|
+
Unknown_regular_expression_flag: diag(1497, 1 /* Error */, "Unknown_regular_expression_flag_1497", "Unknown regular expression flag."),
|
|
5492
|
+
Duplicate_regular_expression_flag: diag(1498, 1 /* Error */, "Duplicate_regular_expression_flag_1498", "Duplicate regular expression flag."),
|
|
5493
|
+
This_regular_expression_flag_is_only_available_when_targeting_0_or_later: diag(1499, 1 /* Error */, "This_regular_expression_flag_is_only_available_when_targeting_0_or_later_1499", "This regular expression flag is only available when targeting '{0}' or later."),
|
|
5494
|
+
The_Unicode_u_flag_and_the_Unicode_Sets_v_flag_cannot_be_set_simultaneously: diag(1500, 1 /* Error */, "The_Unicode_u_flag_and_the_Unicode_Sets_v_flag_cannot_be_set_simultaneously_1500", "The Unicode (u) flag and the Unicode Sets (v) flag cannot be set simultaneously."),
|
|
5495
|
+
Named_capturing_groups_are_only_available_when_targeting_ES2018_or_later: diag(1501, 1 /* Error */, "Named_capturing_groups_are_only_available_when_targeting_ES2018_or_later_1501", "Named capturing groups are only available when targeting 'ES2018' or later."),
|
|
5496
|
+
Subpattern_flags_must_be_present_when_there_is_a_minus_sign: diag(1502, 1 /* Error */, "Subpattern_flags_must_be_present_when_there_is_a_minus_sign_1502", "Subpattern flags must be present when there is a minus sign."),
|
|
5497
|
+
Incomplete_quantifier_Digit_expected: diag(1503, 1 /* Error */, "Incomplete_quantifier_Digit_expected_1503", "Incomplete quantifier. Digit expected."),
|
|
5498
|
+
Numbers_out_of_order_in_quantifier: diag(1504, 1 /* Error */, "Numbers_out_of_order_in_quantifier_1504", "Numbers out of order in quantifier."),
|
|
5499
|
+
There_is_nothing_available_for_repetition: diag(1505, 1 /* Error */, "There_is_nothing_available_for_repetition_1505", "There is nothing available for repetition."),
|
|
5500
|
+
Unexpected_0_Did_you_mean_to_escape_it_with_backslash: diag(1506, 1 /* Error */, "Unexpected_0_Did_you_mean_to_escape_it_with_backslash_1506", "Unexpected '{0}'. Did you mean to escape it with backslash?"),
|
|
5501
|
+
This_regular_expression_flag_cannot_be_toggled_within_a_subpattern: diag(1507, 1 /* Error */, "This_regular_expression_flag_cannot_be_toggled_within_a_subpattern_1507", "This regular expression flag cannot be toggled within a subpattern."),
|
|
5502
|
+
k_must_be_followed_by_a_capturing_group_name_enclosed_in_angle_brackets: diag(1508, 1 /* Error */, "k_must_be_followed_by_a_capturing_group_name_enclosed_in_angle_brackets_1508", "'\\k' must be followed by a capturing group name enclosed in angle brackets."),
|
|
5503
|
+
q_is_only_available_inside_character_class: diag(1509, 1 /* Error */, "q_is_only_available_inside_character_class_1509", "'\\q' is only available inside character class."),
|
|
5504
|
+
c_must_be_followed_by_an_ASCII_letter: diag(1510, 1 /* Error */, "c_must_be_followed_by_an_ASCII_letter_1510", "'\\c' must be followed by an ASCII letter."),
|
|
5505
|
+
Undetermined_character_escape: diag(1511, 1 /* Error */, "Undetermined_character_escape_1511", "Undetermined character escape."),
|
|
5506
|
+
Expected_a_capturing_group_name: diag(1512, 1 /* Error */, "Expected_a_capturing_group_name_1512", "Expected a capturing group name."),
|
|
5507
|
+
Named_capturing_groups_with_the_same_name_must_be_mutually_exclusive_to_each_other: diag(1513, 1 /* Error */, "Named_capturing_groups_with_the_same_name_must_be_mutually_exclusive_to_each_other_1513", "Named capturing groups with the same name must be mutually exclusive to each other."),
|
|
5508
|
+
A_character_class_range_must_not_be_bounded_by_another_character_class: diag(1514, 1 /* Error */, "A_character_class_range_must_not_be_bounded_by_another_character_class_1514", "A character class range must not be bounded by another character class."),
|
|
5509
|
+
Range_out_of_order_in_character_class: diag(1515, 1 /* Error */, "Range_out_of_order_in_character_class_1515", "Range out of order in character class."),
|
|
5510
|
+
Anything_that_would_possibly_match_more_than_a_single_character_is_invalid_inside_a_negated_character_class: diag(1516, 1 /* Error */, "Anything_that_would_possibly_match_more_than_a_single_character_is_invalid_inside_a_negated_characte_1516", "Anything that would possibly match more than a single character is invalid inside a negated character class."),
|
|
5511
|
+
Operators_must_not_be_mixed_within_a_character_class_Wrap_it_in_a_nested_class_instead: diag(1517, 1 /* Error */, "Operators_must_not_be_mixed_within_a_character_class_Wrap_it_in_a_nested_class_instead_1517", "Operators must not be mixed within a character class. Wrap it in a nested class instead."),
|
|
5512
|
+
Expected_a_class_set_oprand: diag(1518, 1 /* Error */, "Expected_a_class_set_oprand_1518", "Expected a class set oprand."),
|
|
5513
|
+
q_must_be_followed_by_string_alternatives_enclosed_in_braces: diag(1519, 1 /* Error */, "q_must_be_followed_by_string_alternatives_enclosed_in_braces_1519", "'\\q' must be followed by string alternatives enclosed in braces."),
|
|
5514
|
+
A_character_class_must_not_contain_a_reserved_double_punctuator_Did_you_mean_to_escape_it_with_backslash: diag(1520, 1 /* Error */, "A_character_class_must_not_contain_a_reserved_double_punctuator_Did_you_mean_to_escape_it_with_backs_1520", "A character class must not contain a reserved double punctuator. Did you mean to escape it with backslash?"),
|
|
5515
|
+
Expected_a_Unicode_property_name: diag(1521, 1 /* Error */, "Expected_a_Unicode_property_name_1521", "Expected a Unicode property name."),
|
|
5516
|
+
Unknown_Unicode_property_name: diag(1522, 1 /* Error */, "Unknown_Unicode_property_name_1522", "Unknown Unicode property name."),
|
|
5517
|
+
Expected_a_Unicode_property_value: diag(1523, 1 /* Error */, "Expected_a_Unicode_property_value_1523", "Expected a Unicode property value."),
|
|
5518
|
+
Unknown_Unicode_property_value: diag(1524, 1 /* Error */, "Unknown_Unicode_property_value_1524", "Unknown Unicode property value."),
|
|
5519
|
+
Expected_a_Unicode_property_name_or_value: diag(1525, 1 /* Error */, "Expected_a_Unicode_property_name_or_value_1525", "Expected a Unicode property name or value."),
|
|
5520
|
+
Any_Unicode_property_that_would_possibly_match_more_than_a_single_character_is_only_available_when_the_Unicode_Sets_v_flag_is_set: diag(1526, 1 /* Error */, "Any_Unicode_property_that_would_possibly_match_more_than_a_single_character_is_only_available_when_t_1526", "Any Unicode property that would possibly match more than a single character is only available when the Unicode Sets (v) flag is set."),
|
|
5521
|
+
Unknown_Unicode_property_name_or_value: diag(1527, 1 /* Error */, "Unknown_Unicode_property_name_or_value_1527", "Unknown Unicode property name or value."),
|
|
5522
|
+
Unicode_property_value_expressions_are_only_available_when_the_Unicode_u_flag_or_the_Unicode_Sets_v_flag_is_set: diag(1528, 1 /* Error */, "Unicode_property_value_expressions_are_only_available_when_the_Unicode_u_flag_or_the_Unicode_Sets_v__1528", "Unicode property value expressions are only available when the Unicode (u) flag or the Unicode Sets (v) flag is set."),
|
|
5523
|
+
_0_must_be_followed_by_a_Unicode_property_value_expression_enclosed_in_braces: diag(1529, 1 /* Error */, "_0_must_be_followed_by_a_Unicode_property_value_expression_enclosed_in_braces_1529", "'\\{0}' must be followed by a Unicode property value expression enclosed in braces."),
|
|
5524
|
+
There_is_no_capturing_group_named_0_in_this_regular_expression: diag(1530, 1 /* Error */, "There_is_no_capturing_group_named_0_in_this_regular_expression_1530", "There is no capturing group named '{0}' in this regular expression."),
|
|
5525
|
+
A_decimal_escape_must_refer_to_an_existent_capturing_group_There_are_only_0_capturing_groups_in_this_regular_expression: diag(1531, 1 /* Error */, "A_decimal_escape_must_refer_to_an_existent_capturing_group_There_are_only_0_capturing_groups_in_this_1531", "A decimal escape must refer to an existent capturing group. There are only {0} capturing groups in this regular expression."),
|
|
5526
|
+
Decimal_escapes_are_invalid_when_there_are_no_capturing_groups_in_a_regular_expression: diag(1532, 1 /* Error */, "Decimal_escapes_are_invalid_when_there_are_no_capturing_groups_in_a_regular_expression_1532", "Decimal escapes are invalid when there are no capturing groups in a regular expression."),
|
|
5472
5527
|
The_types_of_0_are_incompatible_between_these_types: diag(2200, 1 /* Error */, "The_types_of_0_are_incompatible_between_these_types_2200", "The types of '{0}' are incompatible between these types."),
|
|
5473
5528
|
The_types_returned_by_0_are_incompatible_between_these_types: diag(2201, 1 /* Error */, "The_types_returned_by_0_are_incompatible_between_these_types_2201", "The types returned by '{0}' are incompatible between these types."),
|
|
5474
5529
|
Call_signature_return_types_0_and_1_are_incompatible: diag(
|
|
@@ -7066,7 +7121,7 @@ var Diagnostics = {
|
|
|
7066
7121
|
Could_not_convert_to_arrow_function: diag(95151, 3 /* Message */, "Could_not_convert_to_arrow_function_95151", "Could not convert to arrow function"),
|
|
7067
7122
|
Could_not_convert_to_named_function: diag(95152, 3 /* Message */, "Could_not_convert_to_named_function_95152", "Could not convert to named function"),
|
|
7068
7123
|
Could_not_convert_to_anonymous_function: diag(95153, 3 /* Message */, "Could_not_convert_to_anonymous_function_95153", "Could not convert to anonymous function"),
|
|
7069
|
-
|
|
7124
|
+
Can_only_convert_string_concatenation: diag(95154, 3 /* Message */, "Can_only_convert_string_concatenation_95154", "Can only convert string concatenation"),
|
|
7070
7125
|
Selection_is_not_a_valid_statement_or_statements: diag(95155, 3 /* Message */, "Selection_is_not_a_valid_statement_or_statements_95155", "Selection is not a valid statement or statements"),
|
|
7071
7126
|
Add_missing_function_declaration_0: diag(95156, 3 /* Message */, "Add_missing_function_declaration_0_95156", "Add missing function declaration '{0}'"),
|
|
7072
7127
|
Add_all_missing_function_declarations: diag(95157, 3 /* Message */, "Add_all_missing_function_declarations_95157", "Add all missing function declarations"),
|
|
@@ -7302,6 +7357,26 @@ var textToToken = new Map(Object.entries({
|
|
|
7302
7357
|
"#": 63 /* HashToken */,
|
|
7303
7358
|
"`": 62 /* BacktickToken */
|
|
7304
7359
|
}));
|
|
7360
|
+
var charToRegExpFlag = new Map(Object.entries({
|
|
7361
|
+
d: 1 /* HasIndices */,
|
|
7362
|
+
g: 2 /* Global */,
|
|
7363
|
+
i: 4 /* IgnoreCase */,
|
|
7364
|
+
m: 8 /* Multiline */,
|
|
7365
|
+
s: 16 /* DotAll */,
|
|
7366
|
+
u: 32 /* Unicode */,
|
|
7367
|
+
v: 64 /* UnicodeSets */,
|
|
7368
|
+
y: 128 /* Sticky */
|
|
7369
|
+
}));
|
|
7370
|
+
var regExpFlagToFirstAvailableLanguageVersion = /* @__PURE__ */ new Map([
|
|
7371
|
+
[1 /* HasIndices */, 9 /* ES2022 */],
|
|
7372
|
+
[2 /* Global */, 0 /* ES3 */],
|
|
7373
|
+
[4 /* IgnoreCase */, 0 /* ES3 */],
|
|
7374
|
+
[8 /* Multiline */, 0 /* ES3 */],
|
|
7375
|
+
[16 /* DotAll */, 5 /* ES2018 */],
|
|
7376
|
+
[32 /* Unicode */, 2 /* ES2015 */],
|
|
7377
|
+
[64 /* UnicodeSets */, 11 /* ES2024 */],
|
|
7378
|
+
[128 /* Sticky */, 2 /* ES2015 */]
|
|
7379
|
+
]);
|
|
7305
7380
|
var unicodeES3IdentifierStart = [170, 170, 181, 181, 186, 186, 192, 214, 216, 246, 248, 543, 546, 563, 592, 685, 688, 696, 699, 705, 720, 721, 736, 740, 750, 750, 890, 890, 902, 902, 904, 906, 908, 908, 910, 929, 931, 974, 976, 983, 986, 1011, 1024, 1153, 1164, 1220, 1223, 1224, 1227, 1228, 1232, 1269, 1272, 1273, 1329, 1366, 1369, 1369, 1377, 1415, 1488, 1514, 1520, 1522, 1569, 1594, 1600, 1610, 1649, 1747, 1749, 1749, 1765, 1766, 1786, 1788, 1808, 1808, 1810, 1836, 1920, 1957, 2309, 2361, 2365, 2365, 2384, 2384, 2392, 2401, 2437, 2444, 2447, 2448, 2451, 2472, 2474, 2480, 2482, 2482, 2486, 2489, 2524, 2525, 2527, 2529, 2544, 2545, 2565, 2570, 2575, 2576, 2579, 2600, 2602, 2608, 2610, 2611, 2613, 2614, 2616, 2617, 2649, 2652, 2654, 2654, 2674, 2676, 2693, 2699, 2701, 2701, 2703, 2705, 2707, 2728, 2730, 2736, 2738, 2739, 2741, 2745, 2749, 2749, 2768, 2768, 2784, 2784, 2821, 2828, 2831, 2832, 2835, 2856, 2858, 2864, 2866, 2867, 2870, 2873, 2877, 2877, 2908, 2909, 2911, 2913, 2949, 2954, 2958, 2960, 2962, 2965, 2969, 2970, 2972, 2972, 2974, 2975, 2979, 2980, 2984, 2986, 2990, 2997, 2999, 3001, 3077, 3084, 3086, 3088, 3090, 3112, 3114, 3123, 3125, 3129, 3168, 3169, 3205, 3212, 3214, 3216, 3218, 3240, 3242, 3251, 3253, 3257, 3294, 3294, 3296, 3297, 3333, 3340, 3342, 3344, 3346, 3368, 3370, 3385, 3424, 3425, 3461, 3478, 3482, 3505, 3507, 3515, 3517, 3517, 3520, 3526, 3585, 3632, 3634, 3635, 3648, 3654, 3713, 3714, 3716, 3716, 3719, 3720, 3722, 3722, 3725, 3725, 3732, 3735, 3737, 3743, 3745, 3747, 3749, 3749, 3751, 3751, 3754, 3755, 3757, 3760, 3762, 3763, 3773, 3773, 3776, 3780, 3782, 3782, 3804, 3805, 3840, 3840, 3904, 3911, 3913, 3946, 3976, 3979, 4096, 4129, 4131, 4135, 4137, 4138, 4176, 4181, 4256, 4293, 4304, 4342, 4352, 4441, 4447, 4514, 4520, 4601, 4608, 4614, 4616, 4678, 4680, 4680, 4682, 4685, 4688, 4694, 4696, 4696, 4698, 4701, 4704, 4742, 4744, 4744, 4746, 4749, 4752, 4782, 4784, 4784, 4786, 4789, 4792, 4798, 4800, 4800, 4802, 4805, 4808, 4814, 4816, 4822, 4824, 4846, 4848, 4878, 4880, 4880, 4882, 4885, 4888, 4894, 4896, 4934, 4936, 4954, 5024, 5108, 5121, 5740, 5743, 5750, 5761, 5786, 5792, 5866, 6016, 6067, 6176, 6263, 6272, 6312, 7680, 7835, 7840, 7929, 7936, 7957, 7960, 7965, 7968, 8005, 8008, 8013, 8016, 8023, 8025, 8025, 8027, 8027, 8029, 8029, 8031, 8061, 8064, 8116, 8118, 8124, 8126, 8126, 8130, 8132, 8134, 8140, 8144, 8147, 8150, 8155, 8160, 8172, 8178, 8180, 8182, 8188, 8319, 8319, 8450, 8450, 8455, 8455, 8458, 8467, 8469, 8469, 8473, 8477, 8484, 8484, 8486, 8486, 8488, 8488, 8490, 8493, 8495, 8497, 8499, 8505, 8544, 8579, 12293, 12295, 12321, 12329, 12337, 12341, 12344, 12346, 12353, 12436, 12445, 12446, 12449, 12538, 12540, 12542, 12549, 12588, 12593, 12686, 12704, 12727, 13312, 19893, 19968, 40869, 40960, 42124, 44032, 55203, 63744, 64045, 64256, 64262, 64275, 64279, 64285, 64285, 64287, 64296, 64298, 64310, 64312, 64316, 64318, 64318, 64320, 64321, 64323, 64324, 64326, 64433, 64467, 64829, 64848, 64911, 64914, 64967, 65008, 65019, 65136, 65138, 65140, 65140, 65142, 65276, 65313, 65338, 65345, 65370, 65382, 65470, 65474, 65479, 65482, 65487, 65490, 65495, 65498, 65500];
|
|
7306
7381
|
var unicodeES3IdentifierPart = [170, 170, 181, 181, 186, 186, 192, 214, 216, 246, 248, 543, 546, 563, 592, 685, 688, 696, 699, 705, 720, 721, 736, 740, 750, 750, 768, 846, 864, 866, 890, 890, 902, 902, 904, 906, 908, 908, 910, 929, 931, 974, 976, 983, 986, 1011, 1024, 1153, 1155, 1158, 1164, 1220, 1223, 1224, 1227, 1228, 1232, 1269, 1272, 1273, 1329, 1366, 1369, 1369, 1377, 1415, 1425, 1441, 1443, 1465, 1467, 1469, 1471, 1471, 1473, 1474, 1476, 1476, 1488, 1514, 1520, 1522, 1569, 1594, 1600, 1621, 1632, 1641, 1648, 1747, 1749, 1756, 1759, 1768, 1770, 1773, 1776, 1788, 1808, 1836, 1840, 1866, 1920, 1968, 2305, 2307, 2309, 2361, 2364, 2381, 2384, 2388, 2392, 2403, 2406, 2415, 2433, 2435, 2437, 2444, 2447, 2448, 2451, 2472, 2474, 2480, 2482, 2482, 2486, 2489, 2492, 2492, 2494, 2500, 2503, 2504, 2507, 2509, 2519, 2519, 2524, 2525, 2527, 2531, 2534, 2545, 2562, 2562, 2565, 2570, 2575, 2576, 2579, 2600, 2602, 2608, 2610, 2611, 2613, 2614, 2616, 2617, 2620, 2620, 2622, 2626, 2631, 2632, 2635, 2637, 2649, 2652, 2654, 2654, 2662, 2676, 2689, 2691, 2693, 2699, 2701, 2701, 2703, 2705, 2707, 2728, 2730, 2736, 2738, 2739, 2741, 2745, 2748, 2757, 2759, 2761, 2763, 2765, 2768, 2768, 2784, 2784, 2790, 2799, 2817, 2819, 2821, 2828, 2831, 2832, 2835, 2856, 2858, 2864, 2866, 2867, 2870, 2873, 2876, 2883, 2887, 2888, 2891, 2893, 2902, 2903, 2908, 2909, 2911, 2913, 2918, 2927, 2946, 2947, 2949, 2954, 2958, 2960, 2962, 2965, 2969, 2970, 2972, 2972, 2974, 2975, 2979, 2980, 2984, 2986, 2990, 2997, 2999, 3001, 3006, 3010, 3014, 3016, 3018, 3021, 3031, 3031, 3047, 3055, 3073, 3075, 3077, 3084, 3086, 3088, 3090, 3112, 3114, 3123, 3125, 3129, 3134, 3140, 3142, 3144, 3146, 3149, 3157, 3158, 3168, 3169, 3174, 3183, 3202, 3203, 3205, 3212, 3214, 3216, 3218, 3240, 3242, 3251, 3253, 3257, 3262, 3268, 3270, 3272, 3274, 3277, 3285, 3286, 3294, 3294, 3296, 3297, 3302, 3311, 3330, 3331, 3333, 3340, 3342, 3344, 3346, 3368, 3370, 3385, 3390, 3395, 3398, 3400, 3402, 3405, 3415, 3415, 3424, 3425, 3430, 3439, 3458, 3459, 3461, 3478, 3482, 3505, 3507, 3515, 3517, 3517, 3520, 3526, 3530, 3530, 3535, 3540, 3542, 3542, 3544, 3551, 3570, 3571, 3585, 3642, 3648, 3662, 3664, 3673, 3713, 3714, 3716, 3716, 3719, 3720, 3722, 3722, 3725, 3725, 3732, 3735, 3737, 3743, 3745, 3747, 3749, 3749, 3751, 3751, 3754, 3755, 3757, 3769, 3771, 3773, 3776, 3780, 3782, 3782, 3784, 3789, 3792, 3801, 3804, 3805, 3840, 3840, 3864, 3865, 3872, 3881, 3893, 3893, 3895, 3895, 3897, 3897, 3902, 3911, 3913, 3946, 3953, 3972, 3974, 3979, 3984, 3991, 3993, 4028, 4038, 4038, 4096, 4129, 4131, 4135, 4137, 4138, 4140, 4146, 4150, 4153, 4160, 4169, 4176, 4185, 4256, 4293, 4304, 4342, 4352, 4441, 4447, 4514, 4520, 4601, 4608, 4614, 4616, 4678, 4680, 4680, 4682, 4685, 4688, 4694, 4696, 4696, 4698, 4701, 4704, 4742, 4744, 4744, 4746, 4749, 4752, 4782, 4784, 4784, 4786, 4789, 4792, 4798, 4800, 4800, 4802, 4805, 4808, 4814, 4816, 4822, 4824, 4846, 4848, 4878, 4880, 4880, 4882, 4885, 4888, 4894, 4896, 4934, 4936, 4954, 4969, 4977, 5024, 5108, 5121, 5740, 5743, 5750, 5761, 5786, 5792, 5866, 6016, 6099, 6112, 6121, 6160, 6169, 6176, 6263, 6272, 6313, 7680, 7835, 7840, 7929, 7936, 7957, 7960, 7965, 7968, 8005, 8008, 8013, 8016, 8023, 8025, 8025, 8027, 8027, 8029, 8029, 8031, 8061, 8064, 8116, 8118, 8124, 8126, 8126, 8130, 8132, 8134, 8140, 8144, 8147, 8150, 8155, 8160, 8172, 8178, 8180, 8182, 8188, 8255, 8256, 8319, 8319, 8400, 8412, 8417, 8417, 8450, 8450, 8455, 8455, 8458, 8467, 8469, 8469, 8473, 8477, 8484, 8484, 8486, 8486, 8488, 8488, 8490, 8493, 8495, 8497, 8499, 8505, 8544, 8579, 12293, 12295, 12321, 12335, 12337, 12341, 12344, 12346, 12353, 12436, 12441, 12442, 12445, 12446, 12449, 12542, 12549, 12588, 12593, 12686, 12704, 12727, 13312, 19893, 19968, 40869, 40960, 42124, 44032, 55203, 63744, 64045, 64256, 64262, 64275, 64279, 64285, 64296, 64298, 64310, 64312, 64316, 64318, 64318, 64320, 64321, 64323, 64324, 64326, 64433, 64467, 64829, 64848, 64911, 64914, 64967, 65008, 65019, 65056, 65059, 65075, 65076, 65101, 65103, 65136, 65138, 65140, 65140, 65142, 65276, 65296, 65305, 65313, 65338, 65343, 65343, 65345, 65370, 65381, 65470, 65474, 65479, 65482, 65487, 65490, 65495, 65498, 65500];
|
|
7307
7382
|
var unicodeES5IdentifierStart = [170, 170, 181, 181, 186, 186, 192, 214, 216, 246, 248, 705, 710, 721, 736, 740, 748, 748, 750, 750, 880, 884, 886, 887, 890, 893, 902, 902, 904, 906, 908, 908, 910, 929, 931, 1013, 1015, 1153, 1162, 1319, 1329, 1366, 1369, 1369, 1377, 1415, 1488, 1514, 1520, 1522, 1568, 1610, 1646, 1647, 1649, 1747, 1749, 1749, 1765, 1766, 1774, 1775, 1786, 1788, 1791, 1791, 1808, 1808, 1810, 1839, 1869, 1957, 1969, 1969, 1994, 2026, 2036, 2037, 2042, 2042, 2048, 2069, 2074, 2074, 2084, 2084, 2088, 2088, 2112, 2136, 2208, 2208, 2210, 2220, 2308, 2361, 2365, 2365, 2384, 2384, 2392, 2401, 2417, 2423, 2425, 2431, 2437, 2444, 2447, 2448, 2451, 2472, 2474, 2480, 2482, 2482, 2486, 2489, 2493, 2493, 2510, 2510, 2524, 2525, 2527, 2529, 2544, 2545, 2565, 2570, 2575, 2576, 2579, 2600, 2602, 2608, 2610, 2611, 2613, 2614, 2616, 2617, 2649, 2652, 2654, 2654, 2674, 2676, 2693, 2701, 2703, 2705, 2707, 2728, 2730, 2736, 2738, 2739, 2741, 2745, 2749, 2749, 2768, 2768, 2784, 2785, 2821, 2828, 2831, 2832, 2835, 2856, 2858, 2864, 2866, 2867, 2869, 2873, 2877, 2877, 2908, 2909, 2911, 2913, 2929, 2929, 2947, 2947, 2949, 2954, 2958, 2960, 2962, 2965, 2969, 2970, 2972, 2972, 2974, 2975, 2979, 2980, 2984, 2986, 2990, 3001, 3024, 3024, 3077, 3084, 3086, 3088, 3090, 3112, 3114, 3123, 3125, 3129, 3133, 3133, 3160, 3161, 3168, 3169, 3205, 3212, 3214, 3216, 3218, 3240, 3242, 3251, 3253, 3257, 3261, 3261, 3294, 3294, 3296, 3297, 3313, 3314, 3333, 3340, 3342, 3344, 3346, 3386, 3389, 3389, 3406, 3406, 3424, 3425, 3450, 3455, 3461, 3478, 3482, 3505, 3507, 3515, 3517, 3517, 3520, 3526, 3585, 3632, 3634, 3635, 3648, 3654, 3713, 3714, 3716, 3716, 3719, 3720, 3722, 3722, 3725, 3725, 3732, 3735, 3737, 3743, 3745, 3747, 3749, 3749, 3751, 3751, 3754, 3755, 3757, 3760, 3762, 3763, 3773, 3773, 3776, 3780, 3782, 3782, 3804, 3807, 3840, 3840, 3904, 3911, 3913, 3948, 3976, 3980, 4096, 4138, 4159, 4159, 4176, 4181, 4186, 4189, 4193, 4193, 4197, 4198, 4206, 4208, 4213, 4225, 4238, 4238, 4256, 4293, 4295, 4295, 4301, 4301, 4304, 4346, 4348, 4680, 4682, 4685, 4688, 4694, 4696, 4696, 4698, 4701, 4704, 4744, 4746, 4749, 4752, 4784, 4786, 4789, 4792, 4798, 4800, 4800, 4802, 4805, 4808, 4822, 4824, 4880, 4882, 4885, 4888, 4954, 4992, 5007, 5024, 5108, 5121, 5740, 5743, 5759, 5761, 5786, 5792, 5866, 5870, 5872, 5888, 5900, 5902, 5905, 5920, 5937, 5952, 5969, 5984, 5996, 5998, 6e3, 6016, 6067, 6103, 6103, 6108, 6108, 6176, 6263, 6272, 6312, 6314, 6314, 6320, 6389, 6400, 6428, 6480, 6509, 6512, 6516, 6528, 6571, 6593, 6599, 6656, 6678, 6688, 6740, 6823, 6823, 6917, 6963, 6981, 6987, 7043, 7072, 7086, 7087, 7098, 7141, 7168, 7203, 7245, 7247, 7258, 7293, 7401, 7404, 7406, 7409, 7413, 7414, 7424, 7615, 7680, 7957, 7960, 7965, 7968, 8005, 8008, 8013, 8016, 8023, 8025, 8025, 8027, 8027, 8029, 8029, 8031, 8061, 8064, 8116, 8118, 8124, 8126, 8126, 8130, 8132, 8134, 8140, 8144, 8147, 8150, 8155, 8160, 8172, 8178, 8180, 8182, 8188, 8305, 8305, 8319, 8319, 8336, 8348, 8450, 8450, 8455, 8455, 8458, 8467, 8469, 8469, 8473, 8477, 8484, 8484, 8486, 8486, 8488, 8488, 8490, 8493, 8495, 8505, 8508, 8511, 8517, 8521, 8526, 8526, 8544, 8584, 11264, 11310, 11312, 11358, 11360, 11492, 11499, 11502, 11506, 11507, 11520, 11557, 11559, 11559, 11565, 11565, 11568, 11623, 11631, 11631, 11648, 11670, 11680, 11686, 11688, 11694, 11696, 11702, 11704, 11710, 11712, 11718, 11720, 11726, 11728, 11734, 11736, 11742, 11823, 11823, 12293, 12295, 12321, 12329, 12337, 12341, 12344, 12348, 12353, 12438, 12445, 12447, 12449, 12538, 12540, 12543, 12549, 12589, 12593, 12686, 12704, 12730, 12784, 12799, 13312, 19893, 19968, 40908, 40960, 42124, 42192, 42237, 42240, 42508, 42512, 42527, 42538, 42539, 42560, 42606, 42623, 42647, 42656, 42735, 42775, 42783, 42786, 42888, 42891, 42894, 42896, 42899, 42912, 42922, 43e3, 43009, 43011, 43013, 43015, 43018, 43020, 43042, 43072, 43123, 43138, 43187, 43250, 43255, 43259, 43259, 43274, 43301, 43312, 43334, 43360, 43388, 43396, 43442, 43471, 43471, 43520, 43560, 43584, 43586, 43588, 43595, 43616, 43638, 43642, 43642, 43648, 43695, 43697, 43697, 43701, 43702, 43705, 43709, 43712, 43712, 43714, 43714, 43739, 43741, 43744, 43754, 43762, 43764, 43777, 43782, 43785, 43790, 43793, 43798, 43808, 43814, 43816, 43822, 43968, 44002, 44032, 55203, 55216, 55238, 55243, 55291, 63744, 64109, 64112, 64217, 64256, 64262, 64275, 64279, 64285, 64285, 64287, 64296, 64298, 64310, 64312, 64316, 64318, 64318, 64320, 64321, 64323, 64324, 64326, 64433, 64467, 64829, 64848, 64911, 64914, 64967, 65008, 65019, 65136, 65140, 65142, 65276, 65313, 65338, 65345, 65370, 65382, 65470, 65474, 65479, 65482, 65487, 65490, 65495, 65498, 65500];
|
|
@@ -7352,6 +7427,13 @@ function tokenToString(t) {
|
|
|
7352
7427
|
function stringToToken(s) {
|
|
7353
7428
|
return textToToken.get(s);
|
|
7354
7429
|
}
|
|
7430
|
+
var regExpFlagChars = makeReverseMap(charToRegExpFlag);
|
|
7431
|
+
function characterToRegularExpressionFlag(c) {
|
|
7432
|
+
return charToRegExpFlag.get(c);
|
|
7433
|
+
}
|
|
7434
|
+
function regularExpressionFlagToFirstAvailableLanguageVersion(f) {
|
|
7435
|
+
return regExpFlagToFirstAvailableLanguageVersion.get(f);
|
|
7436
|
+
}
|
|
7355
7437
|
function computeLineStarts(text) {
|
|
7356
7438
|
const result = [];
|
|
7357
7439
|
let pos = 0;
|
|
@@ -7415,8 +7497,11 @@ function isDigit(ch) {
|
|
|
7415
7497
|
function isHexDigit(ch) {
|
|
7416
7498
|
return isDigit(ch) || ch >= 65 /* A */ && ch <= 70 /* F */ || ch >= 97 /* a */ && ch <= 102 /* f */;
|
|
7417
7499
|
}
|
|
7418
|
-
function
|
|
7419
|
-
return
|
|
7500
|
+
function isASCIILetter(ch) {
|
|
7501
|
+
return ch >= 65 /* A */ && ch <= 90 /* Z */ || ch >= 97 /* a */ && ch <= 122 /* z */;
|
|
7502
|
+
}
|
|
7503
|
+
function isWordCharacter(ch) {
|
|
7504
|
+
return isASCIILetter(ch) || isDigit(ch) || ch === 95 /* _ */;
|
|
7420
7505
|
}
|
|
7421
7506
|
function isOctalDigit(ch) {
|
|
7422
7507
|
return ch >= 48 /* _0 */ && ch <= 55 /* _7 */;
|
|
@@ -7710,10 +7795,10 @@ function getShebang(text) {
|
|
|
7710
7795
|
}
|
|
7711
7796
|
}
|
|
7712
7797
|
function isIdentifierStart(ch, languageVersion) {
|
|
7713
|
-
return ch
|
|
7798
|
+
return isASCIILetter(ch) || ch === 36 /* $ */ || ch === 95 /* _ */ || ch > 127 /* maxAsciiCharacter */ && isUnicodeIdentifierStart(ch, languageVersion);
|
|
7714
7799
|
}
|
|
7715
7800
|
function isIdentifierPart(ch, languageVersion, identifierVariant) {
|
|
7716
|
-
return ch
|
|
7801
|
+
return isWordCharacter(ch) || ch === 36 /* $ */ || // "-" and ":" are valid in JSX Identifiers
|
|
7717
7802
|
(identifierVariant === 1 /* JSX */ ? ch === 45 /* minus */ || ch === 58 /* colon */ : false) || ch > 127 /* maxAsciiCharacter */ && isUnicodeIdentifierPart(ch, languageVersion);
|
|
7718
7803
|
}
|
|
7719
7804
|
function isIdentifierText(name, languageVersion, identifierVariant) {
|
|
@@ -8032,7 +8117,9 @@ function createScanner(languageVersion, skipTrivia2, languageVariant = 0 /* Stan
|
|
|
8032
8117
|
result += text.substring(start2, pos);
|
|
8033
8118
|
result += scanEscapeSequence(
|
|
8034
8119
|
/*shouldEmitInvalidEscapeError*/
|
|
8035
|
-
true
|
|
8120
|
+
true,
|
|
8121
|
+
/*isRegularExpression*/
|
|
8122
|
+
false
|
|
8036
8123
|
);
|
|
8037
8124
|
start2 = pos;
|
|
8038
8125
|
continue;
|
|
@@ -8076,7 +8163,11 @@ function createScanner(languageVersion, skipTrivia2, languageVariant = 0 /* Stan
|
|
|
8076
8163
|
}
|
|
8077
8164
|
if (currChar === 92 /* backslash */) {
|
|
8078
8165
|
contents += text.substring(start2, pos);
|
|
8079
|
-
contents += scanEscapeSequence(
|
|
8166
|
+
contents += scanEscapeSequence(
|
|
8167
|
+
shouldEmitInvalidEscapeError,
|
|
8168
|
+
/*isRegularExpression*/
|
|
8169
|
+
false
|
|
8170
|
+
);
|
|
8080
8171
|
start2 = pos;
|
|
8081
8172
|
continue;
|
|
8082
8173
|
}
|
|
@@ -8096,7 +8187,7 @@ function createScanner(languageVersion, skipTrivia2, languageVariant = 0 /* Stan
|
|
|
8096
8187
|
tokenValue = contents;
|
|
8097
8188
|
return resultingToken;
|
|
8098
8189
|
}
|
|
8099
|
-
function scanEscapeSequence(shouldEmitInvalidEscapeError) {
|
|
8190
|
+
function scanEscapeSequence(shouldEmitInvalidEscapeError, isRegularExpression) {
|
|
8100
8191
|
const start2 = pos;
|
|
8101
8192
|
pos++;
|
|
8102
8193
|
if (pos >= end) {
|
|
@@ -8124,7 +8215,7 @@ function createScanner(languageVersion, skipTrivia2, languageVariant = 0 /* Stan
|
|
|
8124
8215
|
pos++;
|
|
8125
8216
|
}
|
|
8126
8217
|
tokenFlags |= 2048 /* ContainsInvalidEscape */;
|
|
8127
|
-
if (shouldEmitInvalidEscapeError) {
|
|
8218
|
+
if (isRegularExpression || shouldEmitInvalidEscapeError) {
|
|
8128
8219
|
const code = parseInt(text.substring(start2 + 1, pos), 8);
|
|
8129
8220
|
error(Diagnostics.Octal_escape_sequences_are_not_allowed_Use_the_syntax_0, start2, pos - start2, "\\x" + code.toString(16).padStart(2, "0"));
|
|
8130
8221
|
return String.fromCharCode(code);
|
|
@@ -8133,7 +8224,7 @@ function createScanner(languageVersion, skipTrivia2, languageVariant = 0 /* Stan
|
|
|
8133
8224
|
case 56 /* _8 */:
|
|
8134
8225
|
case 57 /* _9 */:
|
|
8135
8226
|
tokenFlags |= 2048 /* ContainsInvalidEscape */;
|
|
8136
|
-
if (shouldEmitInvalidEscapeError) {
|
|
8227
|
+
if (isRegularExpression || shouldEmitInvalidEscapeError) {
|
|
8137
8228
|
error(Diagnostics.Escape_sequence_0_is_not_allowed, start2, pos - start2, text.substring(start2, pos));
|
|
8138
8229
|
return String.fromCharCode(ch);
|
|
8139
8230
|
}
|
|
@@ -8155,62 +8246,42 @@ function createScanner(languageVersion, skipTrivia2, languageVariant = 0 /* Stan
|
|
|
8155
8246
|
case 34 /* doubleQuote */:
|
|
8156
8247
|
return '"';
|
|
8157
8248
|
case 117 /* u */:
|
|
8158
|
-
if (pos < end && text.charCodeAt(pos) === 123 /* openBrace */) {
|
|
8159
|
-
pos
|
|
8160
|
-
|
|
8161
|
-
1,
|
|
8162
|
-
/*canHaveSeparators*/
|
|
8163
|
-
false
|
|
8164
|
-
);
|
|
8165
|
-
const escapedValue = escapedValueString ? parseInt(escapedValueString, 16) : -1;
|
|
8166
|
-
if (escapedValue < 0) {
|
|
8167
|
-
tokenFlags |= 2048 /* ContainsInvalidEscape */;
|
|
8168
|
-
if (shouldEmitInvalidEscapeError) {
|
|
8169
|
-
error(Diagnostics.Hexadecimal_digit_expected);
|
|
8170
|
-
}
|
|
8171
|
-
return text.substring(start2, pos);
|
|
8172
|
-
}
|
|
8173
|
-
if (!isCodePoint(escapedValue)) {
|
|
8174
|
-
tokenFlags |= 2048 /* ContainsInvalidEscape */;
|
|
8175
|
-
if (shouldEmitInvalidEscapeError) {
|
|
8176
|
-
error(Diagnostics.An_extended_Unicode_escape_value_must_be_between_0x0_and_0x10FFFF_inclusive);
|
|
8177
|
-
}
|
|
8178
|
-
return text.substring(start2, pos);
|
|
8179
|
-
}
|
|
8180
|
-
if (pos >= end) {
|
|
8181
|
-
tokenFlags |= 2048 /* ContainsInvalidEscape */;
|
|
8182
|
-
if (shouldEmitInvalidEscapeError) {
|
|
8183
|
-
error(Diagnostics.Unexpected_end_of_text);
|
|
8184
|
-
}
|
|
8185
|
-
return text.substring(start2, pos);
|
|
8186
|
-
}
|
|
8187
|
-
if (text.charCodeAt(pos) !== 125 /* closeBrace */) {
|
|
8188
|
-
tokenFlags |= 2048 /* ContainsInvalidEscape */;
|
|
8189
|
-
if (shouldEmitInvalidEscapeError) {
|
|
8190
|
-
error(Diagnostics.Unterminated_Unicode_escape_sequence);
|
|
8191
|
-
}
|
|
8192
|
-
return text.substring(start2, pos);
|
|
8193
|
-
}
|
|
8194
|
-
pos++;
|
|
8195
|
-
tokenFlags |= 8 /* ExtendedUnicodeEscape */;
|
|
8196
|
-
return utf16EncodeAsString(escapedValue);
|
|
8249
|
+
if ((!isRegularExpression || shouldEmitInvalidEscapeError) && pos < end && text.charCodeAt(pos) === 123 /* openBrace */) {
|
|
8250
|
+
pos -= 2;
|
|
8251
|
+
return scanExtendedUnicodeEscape(isRegularExpression || shouldEmitInvalidEscapeError);
|
|
8197
8252
|
}
|
|
8198
8253
|
for (; pos < start2 + 6; pos++) {
|
|
8199
8254
|
if (!(pos < end && isHexDigit(text.charCodeAt(pos)))) {
|
|
8200
8255
|
tokenFlags |= 2048 /* ContainsInvalidEscape */;
|
|
8201
|
-
if (shouldEmitInvalidEscapeError) {
|
|
8256
|
+
if (isRegularExpression || shouldEmitInvalidEscapeError) {
|
|
8202
8257
|
error(Diagnostics.Hexadecimal_digit_expected);
|
|
8203
8258
|
}
|
|
8204
8259
|
return text.substring(start2, pos);
|
|
8205
8260
|
}
|
|
8206
8261
|
}
|
|
8207
8262
|
tokenFlags |= 1024 /* UnicodeEscape */;
|
|
8208
|
-
|
|
8263
|
+
const escapedValue = parseInt(text.substring(start2 + 2, pos), 16);
|
|
8264
|
+
const escapedValueString = String.fromCharCode(escapedValue);
|
|
8265
|
+
if (isRegularExpression && shouldEmitInvalidEscapeError && escapedValue >= 55296 && escapedValue <= 56319 && pos + 6 < end && text.substring(pos, pos + 2) === "\\u" && text.charCodeAt(pos + 2) !== 123 /* openBrace */) {
|
|
8266
|
+
const nextStart = pos;
|
|
8267
|
+
let nextPos = pos + 2;
|
|
8268
|
+
for (; nextPos < nextStart + 6; nextPos++) {
|
|
8269
|
+
if (!isHexDigit(text.charCodeAt(pos))) {
|
|
8270
|
+
return escapedValueString;
|
|
8271
|
+
}
|
|
8272
|
+
}
|
|
8273
|
+
const nextEscapedValue = parseInt(text.substring(nextStart + 2, nextPos), 16);
|
|
8274
|
+
if (nextEscapedValue >= 56320 && nextEscapedValue <= 57343) {
|
|
8275
|
+
pos = nextPos;
|
|
8276
|
+
return escapedValueString + String.fromCharCode(nextEscapedValue);
|
|
8277
|
+
}
|
|
8278
|
+
}
|
|
8279
|
+
return escapedValueString;
|
|
8209
8280
|
case 120 /* x */:
|
|
8210
8281
|
for (; pos < start2 + 4; pos++) {
|
|
8211
8282
|
if (!(pos < end && isHexDigit(text.charCodeAt(pos)))) {
|
|
8212
8283
|
tokenFlags |= 2048 /* ContainsInvalidEscape */;
|
|
8213
|
-
if (shouldEmitInvalidEscapeError) {
|
|
8284
|
+
if (isRegularExpression || shouldEmitInvalidEscapeError) {
|
|
8214
8285
|
error(Diagnostics.Hexadecimal_digit_expected);
|
|
8215
8286
|
}
|
|
8216
8287
|
return text.substring(start2, pos);
|
|
@@ -8227,10 +8298,16 @@ function createScanner(languageVersion, skipTrivia2, languageVariant = 0 /* Stan
|
|
|
8227
8298
|
case 8233 /* paragraphSeparator */:
|
|
8228
8299
|
return "";
|
|
8229
8300
|
default:
|
|
8301
|
+
if (isRegularExpression && (shouldEmitInvalidEscapeError || isIdentifierPart(ch, languageVersion))) {
|
|
8302
|
+
error(Diagnostics._0_is_not_a_valid_character_escape, pos - 2, 2, String.fromCharCode(ch));
|
|
8303
|
+
}
|
|
8230
8304
|
return String.fromCharCode(ch);
|
|
8231
8305
|
}
|
|
8232
8306
|
}
|
|
8233
|
-
function scanExtendedUnicodeEscape() {
|
|
8307
|
+
function scanExtendedUnicodeEscape(shouldEmitInvalidEscapeError = true) {
|
|
8308
|
+
const start2 = pos;
|
|
8309
|
+
pos += 3;
|
|
8310
|
+
const escapedStart = pos;
|
|
8234
8311
|
const escapedValueString = scanMinimumNumberOfHexDigits(
|
|
8235
8312
|
1,
|
|
8236
8313
|
/*canHaveSeparators*/
|
|
@@ -8239,24 +8316,34 @@ function createScanner(languageVersion, skipTrivia2, languageVariant = 0 /* Stan
|
|
|
8239
8316
|
const escapedValue = escapedValueString ? parseInt(escapedValueString, 16) : -1;
|
|
8240
8317
|
let isInvalidExtendedEscape = false;
|
|
8241
8318
|
if (escapedValue < 0) {
|
|
8242
|
-
|
|
8319
|
+
if (shouldEmitInvalidEscapeError) {
|
|
8320
|
+
error(Diagnostics.Hexadecimal_digit_expected);
|
|
8321
|
+
}
|
|
8243
8322
|
isInvalidExtendedEscape = true;
|
|
8244
8323
|
} else if (escapedValue > 1114111) {
|
|
8245
|
-
|
|
8324
|
+
if (shouldEmitInvalidEscapeError) {
|
|
8325
|
+
error(Diagnostics.An_extended_Unicode_escape_value_must_be_between_0x0_and_0x10FFFF_inclusive, escapedStart, pos - escapedStart);
|
|
8326
|
+
}
|
|
8246
8327
|
isInvalidExtendedEscape = true;
|
|
8247
8328
|
}
|
|
8248
8329
|
if (pos >= end) {
|
|
8249
|
-
|
|
8330
|
+
if (shouldEmitInvalidEscapeError) {
|
|
8331
|
+
error(Diagnostics.Unexpected_end_of_text);
|
|
8332
|
+
}
|
|
8250
8333
|
isInvalidExtendedEscape = true;
|
|
8251
8334
|
} else if (text.charCodeAt(pos) === 125 /* closeBrace */) {
|
|
8252
8335
|
pos++;
|
|
8253
8336
|
} else {
|
|
8254
|
-
|
|
8337
|
+
if (shouldEmitInvalidEscapeError) {
|
|
8338
|
+
error(Diagnostics.Unterminated_Unicode_escape_sequence);
|
|
8339
|
+
}
|
|
8255
8340
|
isInvalidExtendedEscape = true;
|
|
8256
8341
|
}
|
|
8257
8342
|
if (isInvalidExtendedEscape) {
|
|
8258
|
-
|
|
8343
|
+
tokenFlags |= 2048 /* ContainsInvalidEscape */;
|
|
8344
|
+
return text.substring(start2, pos);
|
|
8259
8345
|
}
|
|
8346
|
+
tokenFlags |= 8 /* ExtendedUnicodeEscape */;
|
|
8260
8347
|
return utf16EncodeAsString(escapedValue);
|
|
8261
8348
|
}
|
|
8262
8349
|
function peekUnicodeEscape() {
|
|
@@ -8298,8 +8385,6 @@ function createScanner(languageVersion, skipTrivia2, languageVariant = 0 /* Stan
|
|
|
8298
8385
|
} else if (ch === 92 /* backslash */) {
|
|
8299
8386
|
ch = peekExtendedUnicodeEscape();
|
|
8300
8387
|
if (ch >= 0 && isIdentifierPart(ch, languageVersion)) {
|
|
8301
|
-
pos += 3;
|
|
8302
|
-
tokenFlags |= 8 /* ExtendedUnicodeEscape */;
|
|
8303
8388
|
result += scanExtendedUnicodeEscape();
|
|
8304
8389
|
start2 = pos;
|
|
8305
8390
|
continue;
|
|
@@ -8770,8 +8855,6 @@ function createScanner(languageVersion, skipTrivia2, languageVariant = 0 /* Stan
|
|
|
8770
8855
|
case 92 /* backslash */:
|
|
8771
8856
|
const extendedCookedChar = peekExtendedUnicodeEscape();
|
|
8772
8857
|
if (extendedCookedChar >= 0 && isIdentifierStart(extendedCookedChar, languageVersion)) {
|
|
8773
|
-
pos += 3;
|
|
8774
|
-
tokenFlags |= 8 /* ExtendedUnicodeEscape */;
|
|
8775
8858
|
tokenValue = scanExtendedUnicodeEscape() + scanIdentifierParts();
|
|
8776
8859
|
return token = getIdentifierToken();
|
|
8777
8860
|
}
|
|
@@ -8787,7 +8870,7 @@ function createScanner(languageVersion, skipTrivia2, languageVariant = 0 /* Stan
|
|
|
8787
8870
|
return token = 0 /* Unknown */;
|
|
8788
8871
|
case 35 /* hash */:
|
|
8789
8872
|
if (pos !== 0 && text[pos + 1] === "!") {
|
|
8790
|
-
error(Diagnostics.can_only_be_used_at_the_start_of_a_file);
|
|
8873
|
+
error(Diagnostics.can_only_be_used_at_the_start_of_a_file, pos, 2);
|
|
8791
8874
|
pos++;
|
|
8792
8875
|
return token = 0 /* Unknown */;
|
|
8793
8876
|
}
|
|
@@ -8796,8 +8879,6 @@ function createScanner(languageVersion, skipTrivia2, languageVariant = 0 /* Stan
|
|
|
8796
8879
|
pos++;
|
|
8797
8880
|
const extendedCookedChar2 = peekExtendedUnicodeEscape();
|
|
8798
8881
|
if (extendedCookedChar2 >= 0 && isIdentifierStart(extendedCookedChar2, languageVersion)) {
|
|
8799
|
-
pos += 3;
|
|
8800
|
-
tokenFlags |= 8 /* ExtendedUnicodeEscape */;
|
|
8801
8882
|
tokenValue = "#" + scanExtendedUnicodeEscape() + scanIdentifierParts();
|
|
8802
8883
|
return token = 81 /* PrivateIdentifier */;
|
|
8803
8884
|
}
|
|
@@ -8920,14 +9001,841 @@ function createScanner(languageVersion, skipTrivia2, languageVariant = 0 /* Stan
|
|
|
8920
9001
|
}
|
|
8921
9002
|
p++;
|
|
8922
9003
|
}
|
|
8923
|
-
|
|
9004
|
+
const isUnterminated = !!(tokenFlags & 4 /* Unterminated */);
|
|
9005
|
+
const endOfBody = p - (isUnterminated ? 0 : 1);
|
|
9006
|
+
let regExpFlags = 0 /* None */;
|
|
9007
|
+
while (p < end) {
|
|
9008
|
+
const ch = text.charCodeAt(p);
|
|
9009
|
+
if (!isIdentifierPart(ch, languageVersion)) {
|
|
9010
|
+
break;
|
|
9011
|
+
}
|
|
9012
|
+
const flag = characterToRegularExpressionFlag(String.fromCharCode(ch));
|
|
9013
|
+
if (flag === void 0) {
|
|
9014
|
+
error(Diagnostics.Unknown_regular_expression_flag, p, 1);
|
|
9015
|
+
} else if (regExpFlags & flag) {
|
|
9016
|
+
error(Diagnostics.Duplicate_regular_expression_flag, p, 1);
|
|
9017
|
+
} else if (((regExpFlags | flag) & 96 /* UnicodeMode */) === 96 /* UnicodeMode */) {
|
|
9018
|
+
error(Diagnostics.The_Unicode_u_flag_and_the_Unicode_Sets_v_flag_cannot_be_set_simultaneously, p, 1);
|
|
9019
|
+
} else {
|
|
9020
|
+
regExpFlags |= flag;
|
|
9021
|
+
const availableFrom = regularExpressionFlagToFirstAvailableLanguageVersion(flag);
|
|
9022
|
+
if (languageVersion < availableFrom) {
|
|
9023
|
+
error(Diagnostics.This_regular_expression_flag_is_only_available_when_targeting_0_or_later, p, 1, ScriptTarget[availableFrom]);
|
|
9024
|
+
}
|
|
9025
|
+
}
|
|
8924
9026
|
p++;
|
|
8925
9027
|
}
|
|
8926
|
-
pos =
|
|
9028
|
+
pos = tokenStart + 1;
|
|
9029
|
+
const saveTokenPos = tokenStart;
|
|
9030
|
+
const saveTokenFlags = tokenFlags;
|
|
9031
|
+
scanRegularExpressionWorker(text.slice(0, endOfBody), endOfBody, regExpFlags, isUnterminated);
|
|
9032
|
+
if (!isUnterminated) {
|
|
9033
|
+
pos = p;
|
|
9034
|
+
}
|
|
9035
|
+
tokenStart = saveTokenPos;
|
|
9036
|
+
tokenFlags = saveTokenFlags;
|
|
8927
9037
|
tokenValue = text.substring(tokenStart, pos);
|
|
8928
9038
|
token = 14 /* RegularExpressionLiteral */;
|
|
8929
9039
|
}
|
|
8930
9040
|
return token;
|
|
9041
|
+
function scanRegularExpressionWorker(text2, end2, regExpFlags, isUnterminated) {
|
|
9042
|
+
const unicodeMode = !!(regExpFlags & 96 /* UnicodeMode */);
|
|
9043
|
+
const unicodeSetsMode = !!(regExpFlags & 64 /* UnicodeSets */);
|
|
9044
|
+
let mayContainStrings = false;
|
|
9045
|
+
let numberOfCapturingGroups = 0;
|
|
9046
|
+
const groupSpecifiers = /* @__PURE__ */ new Set();
|
|
9047
|
+
const groupNameReferences = [];
|
|
9048
|
+
const decimalEscapes = [];
|
|
9049
|
+
const namedCapturingGroups = [];
|
|
9050
|
+
function scanDisjunction(isInGroup) {
|
|
9051
|
+
while (true) {
|
|
9052
|
+
namedCapturingGroups.push(/* @__PURE__ */ new Set());
|
|
9053
|
+
scanAlternative(isInGroup);
|
|
9054
|
+
namedCapturingGroups.pop();
|
|
9055
|
+
if (text2.charCodeAt(pos) !== 124 /* bar */) {
|
|
9056
|
+
return;
|
|
9057
|
+
}
|
|
9058
|
+
pos++;
|
|
9059
|
+
}
|
|
9060
|
+
}
|
|
9061
|
+
function scanAlternative(isInGroup) {
|
|
9062
|
+
let isPreviousTermQuantifiable = false;
|
|
9063
|
+
while (pos < end2) {
|
|
9064
|
+
const start2 = pos;
|
|
9065
|
+
const ch = text2.charCodeAt(pos);
|
|
9066
|
+
switch (ch) {
|
|
9067
|
+
case 94 /* caret */:
|
|
9068
|
+
case 36 /* $ */:
|
|
9069
|
+
pos++;
|
|
9070
|
+
isPreviousTermQuantifiable = false;
|
|
9071
|
+
break;
|
|
9072
|
+
case 92 /* backslash */:
|
|
9073
|
+
pos++;
|
|
9074
|
+
switch (text2.charCodeAt(pos)) {
|
|
9075
|
+
case 98 /* b */:
|
|
9076
|
+
case 66 /* B */:
|
|
9077
|
+
pos++;
|
|
9078
|
+
isPreviousTermQuantifiable = false;
|
|
9079
|
+
break;
|
|
9080
|
+
default:
|
|
9081
|
+
scanAtomEscape();
|
|
9082
|
+
isPreviousTermQuantifiable = true;
|
|
9083
|
+
break;
|
|
9084
|
+
}
|
|
9085
|
+
break;
|
|
9086
|
+
case 40 /* openParen */:
|
|
9087
|
+
pos++;
|
|
9088
|
+
if (text2.charCodeAt(pos) === 63 /* question */) {
|
|
9089
|
+
pos++;
|
|
9090
|
+
switch (text2.charCodeAt(pos)) {
|
|
9091
|
+
case 61 /* equals */:
|
|
9092
|
+
case 33 /* exclamation */:
|
|
9093
|
+
pos++;
|
|
9094
|
+
isPreviousTermQuantifiable = false;
|
|
9095
|
+
break;
|
|
9096
|
+
case 60 /* lessThan */:
|
|
9097
|
+
const groupNameStart = pos;
|
|
9098
|
+
pos++;
|
|
9099
|
+
switch (text2.charCodeAt(pos)) {
|
|
9100
|
+
case 61 /* equals */:
|
|
9101
|
+
case 33 /* exclamation */:
|
|
9102
|
+
pos++;
|
|
9103
|
+
isPreviousTermQuantifiable = false;
|
|
9104
|
+
break;
|
|
9105
|
+
default:
|
|
9106
|
+
scanGroupName(
|
|
9107
|
+
/*isReference*/
|
|
9108
|
+
false
|
|
9109
|
+
);
|
|
9110
|
+
scanExpectedChar(62 /* greaterThan */);
|
|
9111
|
+
if (languageVersion < 5 /* ES2018 */) {
|
|
9112
|
+
error(Diagnostics.Named_capturing_groups_are_only_available_when_targeting_ES2018_or_later, groupNameStart, pos - groupNameStart);
|
|
9113
|
+
}
|
|
9114
|
+
numberOfCapturingGroups++;
|
|
9115
|
+
isPreviousTermQuantifiable = true;
|
|
9116
|
+
break;
|
|
9117
|
+
}
|
|
9118
|
+
break;
|
|
9119
|
+
default:
|
|
9120
|
+
const start3 = pos;
|
|
9121
|
+
const setFlags = scanPatternModifiers();
|
|
9122
|
+
if (text2.charCodeAt(pos) === 45 /* minus */) {
|
|
9123
|
+
pos++;
|
|
9124
|
+
scanPatternModifiers(setFlags);
|
|
9125
|
+
if (pos === start3 + 1) {
|
|
9126
|
+
error(Diagnostics.Subpattern_flags_must_be_present_when_there_is_a_minus_sign, start3, pos - start3);
|
|
9127
|
+
}
|
|
9128
|
+
}
|
|
9129
|
+
scanExpectedChar(58 /* colon */);
|
|
9130
|
+
isPreviousTermQuantifiable = true;
|
|
9131
|
+
break;
|
|
9132
|
+
}
|
|
9133
|
+
} else {
|
|
9134
|
+
numberOfCapturingGroups++;
|
|
9135
|
+
isPreviousTermQuantifiable = true;
|
|
9136
|
+
}
|
|
9137
|
+
scanDisjunction(
|
|
9138
|
+
/*isInGroup*/
|
|
9139
|
+
true
|
|
9140
|
+
);
|
|
9141
|
+
scanExpectedChar(41 /* closeParen */);
|
|
9142
|
+
break;
|
|
9143
|
+
case 123 /* openBrace */:
|
|
9144
|
+
pos++;
|
|
9145
|
+
const digitsStart = pos;
|
|
9146
|
+
scanDigits();
|
|
9147
|
+
const min2 = tokenValue;
|
|
9148
|
+
if (text2.charCodeAt(pos) === 44 /* comma */) {
|
|
9149
|
+
pos++;
|
|
9150
|
+
scanDigits();
|
|
9151
|
+
const max = tokenValue;
|
|
9152
|
+
if (!min2) {
|
|
9153
|
+
if (max || text2.charCodeAt(pos) === 125 /* closeBrace */) {
|
|
9154
|
+
error(Diagnostics.Incomplete_quantifier_Digit_expected, digitsStart, 0);
|
|
9155
|
+
} else {
|
|
9156
|
+
if (unicodeMode) {
|
|
9157
|
+
error(Diagnostics.Unexpected_0_Did_you_mean_to_escape_it_with_backslash, start2, 1, String.fromCharCode(ch));
|
|
9158
|
+
}
|
|
9159
|
+
isPreviousTermQuantifiable = true;
|
|
9160
|
+
break;
|
|
9161
|
+
}
|
|
9162
|
+
}
|
|
9163
|
+
if (max && Number.parseInt(min2) > Number.parseInt(max)) {
|
|
9164
|
+
error(Diagnostics.Numbers_out_of_order_in_quantifier, digitsStart, pos - digitsStart);
|
|
9165
|
+
}
|
|
9166
|
+
} else if (!min2) {
|
|
9167
|
+
if (unicodeMode) {
|
|
9168
|
+
error(Diagnostics.Unexpected_0_Did_you_mean_to_escape_it_with_backslash, start2, 1, String.fromCharCode(ch));
|
|
9169
|
+
}
|
|
9170
|
+
isPreviousTermQuantifiable = true;
|
|
9171
|
+
break;
|
|
9172
|
+
}
|
|
9173
|
+
scanExpectedChar(125 /* closeBrace */);
|
|
9174
|
+
pos--;
|
|
9175
|
+
case 42 /* asterisk */:
|
|
9176
|
+
case 43 /* plus */:
|
|
9177
|
+
case 63 /* question */:
|
|
9178
|
+
pos++;
|
|
9179
|
+
if (text2.charCodeAt(pos) === 63 /* question */) {
|
|
9180
|
+
pos++;
|
|
9181
|
+
}
|
|
9182
|
+
if (!isPreviousTermQuantifiable) {
|
|
9183
|
+
error(Diagnostics.There_is_nothing_available_for_repetition, start2, pos - start2);
|
|
9184
|
+
}
|
|
9185
|
+
isPreviousTermQuantifiable = false;
|
|
9186
|
+
break;
|
|
9187
|
+
case 46 /* dot */:
|
|
9188
|
+
pos++;
|
|
9189
|
+
isPreviousTermQuantifiable = true;
|
|
9190
|
+
break;
|
|
9191
|
+
case 91 /* openBracket */:
|
|
9192
|
+
pos++;
|
|
9193
|
+
if (unicodeSetsMode) {
|
|
9194
|
+
scanClassSetExpression();
|
|
9195
|
+
} else {
|
|
9196
|
+
scanClassRanges();
|
|
9197
|
+
}
|
|
9198
|
+
scanExpectedChar(93 /* closeBracket */);
|
|
9199
|
+
isPreviousTermQuantifiable = true;
|
|
9200
|
+
break;
|
|
9201
|
+
case 41 /* closeParen */:
|
|
9202
|
+
if (isInGroup) {
|
|
9203
|
+
return;
|
|
9204
|
+
}
|
|
9205
|
+
case 93 /* closeBracket */:
|
|
9206
|
+
case 125 /* closeBrace */:
|
|
9207
|
+
if (isUnterminated && !isInGroup) {
|
|
9208
|
+
return;
|
|
9209
|
+
}
|
|
9210
|
+
if (unicodeMode) {
|
|
9211
|
+
error(Diagnostics.Unexpected_0_Did_you_mean_to_escape_it_with_backslash, pos, 1, String.fromCharCode(ch));
|
|
9212
|
+
}
|
|
9213
|
+
pos++;
|
|
9214
|
+
isPreviousTermQuantifiable = true;
|
|
9215
|
+
break;
|
|
9216
|
+
case 47 /* slash */:
|
|
9217
|
+
case 124 /* bar */:
|
|
9218
|
+
return;
|
|
9219
|
+
default:
|
|
9220
|
+
scanSourceCharacter();
|
|
9221
|
+
isPreviousTermQuantifiable = true;
|
|
9222
|
+
break;
|
|
9223
|
+
}
|
|
9224
|
+
}
|
|
9225
|
+
}
|
|
9226
|
+
function scanPatternModifiers(currFlags = 0 /* None */) {
|
|
9227
|
+
while (pos < end2) {
|
|
9228
|
+
const ch = text2.charCodeAt(pos);
|
|
9229
|
+
if (!isIdentifierPart(ch, languageVersion)) {
|
|
9230
|
+
break;
|
|
9231
|
+
}
|
|
9232
|
+
const flag = characterToRegularExpressionFlag(String.fromCharCode(ch));
|
|
9233
|
+
if (flag === void 0) {
|
|
9234
|
+
error(Diagnostics.Unknown_regular_expression_flag, pos, 1);
|
|
9235
|
+
} else if (currFlags & flag) {
|
|
9236
|
+
error(Diagnostics.Duplicate_regular_expression_flag, pos, 1);
|
|
9237
|
+
} else if (!(flag & 28 /* Modifiers */)) {
|
|
9238
|
+
error(Diagnostics.This_regular_expression_flag_cannot_be_toggled_within_a_subpattern, pos, 1);
|
|
9239
|
+
} else {
|
|
9240
|
+
currFlags |= flag;
|
|
9241
|
+
const availableFrom = regularExpressionFlagToFirstAvailableLanguageVersion(flag);
|
|
9242
|
+
if (languageVersion < availableFrom) {
|
|
9243
|
+
error(Diagnostics.This_regular_expression_flag_is_only_available_when_targeting_0_or_later, pos, 1, ScriptTarget[availableFrom]);
|
|
9244
|
+
}
|
|
9245
|
+
}
|
|
9246
|
+
pos++;
|
|
9247
|
+
}
|
|
9248
|
+
return currFlags;
|
|
9249
|
+
}
|
|
9250
|
+
function scanAtomEscape() {
|
|
9251
|
+
Debug.assertEqual(text2.charCodeAt(pos - 1), 92 /* backslash */);
|
|
9252
|
+
switch (text2.charCodeAt(pos)) {
|
|
9253
|
+
case 107 /* k */:
|
|
9254
|
+
pos++;
|
|
9255
|
+
if (text2.charCodeAt(pos) === 60 /* lessThan */) {
|
|
9256
|
+
pos++;
|
|
9257
|
+
scanGroupName(
|
|
9258
|
+
/*isReference*/
|
|
9259
|
+
true
|
|
9260
|
+
);
|
|
9261
|
+
scanExpectedChar(62 /* greaterThan */);
|
|
9262
|
+
} else if (unicodeMode) {
|
|
9263
|
+
error(Diagnostics.k_must_be_followed_by_a_capturing_group_name_enclosed_in_angle_brackets, pos - 2, 2);
|
|
9264
|
+
}
|
|
9265
|
+
break;
|
|
9266
|
+
case 113 /* q */:
|
|
9267
|
+
if (unicodeSetsMode) {
|
|
9268
|
+
pos++;
|
|
9269
|
+
error(Diagnostics.q_is_only_available_inside_character_class, pos - 2, 2);
|
|
9270
|
+
break;
|
|
9271
|
+
}
|
|
9272
|
+
default:
|
|
9273
|
+
scanCharacterClassEscape() || scanDecimalEscape() || scanCharacterEscape();
|
|
9274
|
+
break;
|
|
9275
|
+
}
|
|
9276
|
+
}
|
|
9277
|
+
function scanDecimalEscape() {
|
|
9278
|
+
Debug.assertEqual(text2.charCodeAt(pos - 1), 92 /* backslash */);
|
|
9279
|
+
const ch = text2.charCodeAt(pos);
|
|
9280
|
+
if (ch >= 49 /* _1 */ && ch <= 57 /* _9 */) {
|
|
9281
|
+
const start2 = pos;
|
|
9282
|
+
scanDigits();
|
|
9283
|
+
decimalEscapes.push({ pos: start2, end: pos, value: +tokenValue });
|
|
9284
|
+
return true;
|
|
9285
|
+
}
|
|
9286
|
+
return false;
|
|
9287
|
+
}
|
|
9288
|
+
function scanCharacterEscape() {
|
|
9289
|
+
Debug.assertEqual(text2.charCodeAt(pos - 1), 92 /* backslash */);
|
|
9290
|
+
let ch = text2.charCodeAt(pos);
|
|
9291
|
+
switch (ch) {
|
|
9292
|
+
case 99 /* c */:
|
|
9293
|
+
pos++;
|
|
9294
|
+
ch = text2.charCodeAt(pos);
|
|
9295
|
+
if (isASCIILetter(ch)) {
|
|
9296
|
+
pos++;
|
|
9297
|
+
return String.fromCharCode(ch & 31);
|
|
9298
|
+
}
|
|
9299
|
+
if (unicodeMode) {
|
|
9300
|
+
error(Diagnostics.c_must_be_followed_by_an_ASCII_letter, pos - 2, 2);
|
|
9301
|
+
}
|
|
9302
|
+
return String.fromCharCode(ch);
|
|
9303
|
+
case 94 /* caret */:
|
|
9304
|
+
case 36 /* $ */:
|
|
9305
|
+
case 47 /* slash */:
|
|
9306
|
+
case 92 /* backslash */:
|
|
9307
|
+
case 46 /* dot */:
|
|
9308
|
+
case 42 /* asterisk */:
|
|
9309
|
+
case 43 /* plus */:
|
|
9310
|
+
case 63 /* question */:
|
|
9311
|
+
case 40 /* openParen */:
|
|
9312
|
+
case 41 /* closeParen */:
|
|
9313
|
+
case 91 /* openBracket */:
|
|
9314
|
+
case 93 /* closeBracket */:
|
|
9315
|
+
case 123 /* openBrace */:
|
|
9316
|
+
case 125 /* closeBrace */:
|
|
9317
|
+
case 124 /* bar */:
|
|
9318
|
+
pos++;
|
|
9319
|
+
return String.fromCharCode(ch);
|
|
9320
|
+
default:
|
|
9321
|
+
if (pos >= end2) {
|
|
9322
|
+
error(Diagnostics.Undetermined_character_escape, pos - 1, 1, ch);
|
|
9323
|
+
return "\\";
|
|
9324
|
+
}
|
|
9325
|
+
pos--;
|
|
9326
|
+
return scanEscapeSequence(
|
|
9327
|
+
/*shouldEmitInvalidEscapeError*/
|
|
9328
|
+
unicodeMode,
|
|
9329
|
+
/*isRegularExpression*/
|
|
9330
|
+
true
|
|
9331
|
+
);
|
|
9332
|
+
}
|
|
9333
|
+
}
|
|
9334
|
+
function scanGroupName(isReference) {
|
|
9335
|
+
Debug.assertEqual(text2.charCodeAt(pos - 1), 60 /* lessThan */);
|
|
9336
|
+
tokenStart = pos;
|
|
9337
|
+
scanIdentifier(codePointAt(text2, pos), languageVersion);
|
|
9338
|
+
if (pos === tokenStart) {
|
|
9339
|
+
error(Diagnostics.Expected_a_capturing_group_name);
|
|
9340
|
+
} else if (isReference) {
|
|
9341
|
+
groupNameReferences.push({ pos: tokenStart, end: pos, name: tokenValue });
|
|
9342
|
+
} else if (namedCapturingGroups.some((group2) => group2.has(tokenValue))) {
|
|
9343
|
+
error(Diagnostics.Named_capturing_groups_with_the_same_name_must_be_mutually_exclusive_to_each_other, tokenStart, pos - tokenStart);
|
|
9344
|
+
} else {
|
|
9345
|
+
last(namedCapturingGroups).add(tokenValue);
|
|
9346
|
+
groupSpecifiers.add(tokenValue);
|
|
9347
|
+
}
|
|
9348
|
+
}
|
|
9349
|
+
function isClassContentExit(ch) {
|
|
9350
|
+
return ch === 93 /* closeBracket */ || pos >= end2;
|
|
9351
|
+
}
|
|
9352
|
+
function scanClassRanges() {
|
|
9353
|
+
Debug.assertEqual(text2.charCodeAt(pos - 1), 91 /* openBracket */);
|
|
9354
|
+
if (text2.charCodeAt(pos) === 94 /* caret */) {
|
|
9355
|
+
pos++;
|
|
9356
|
+
}
|
|
9357
|
+
while (pos < end2) {
|
|
9358
|
+
const ch = text2.charCodeAt(pos);
|
|
9359
|
+
if (isClassContentExit(ch)) {
|
|
9360
|
+
return;
|
|
9361
|
+
}
|
|
9362
|
+
const minStart = pos;
|
|
9363
|
+
const minCharacter = scanClassAtom();
|
|
9364
|
+
if (text2.charCodeAt(pos) === 45 /* minus */) {
|
|
9365
|
+
pos++;
|
|
9366
|
+
const ch2 = text2.charCodeAt(pos);
|
|
9367
|
+
if (isClassContentExit(ch2)) {
|
|
9368
|
+
return;
|
|
9369
|
+
}
|
|
9370
|
+
if (!minCharacter) {
|
|
9371
|
+
error(Diagnostics.A_character_class_range_must_not_be_bounded_by_another_character_class, minStart, pos - 1 - minStart);
|
|
9372
|
+
}
|
|
9373
|
+
const maxStart = pos;
|
|
9374
|
+
const maxCharacter = scanClassAtom();
|
|
9375
|
+
if (!maxCharacter) {
|
|
9376
|
+
error(Diagnostics.A_character_class_range_must_not_be_bounded_by_another_character_class, maxStart, pos - maxStart);
|
|
9377
|
+
continue;
|
|
9378
|
+
}
|
|
9379
|
+
if (!minCharacter) {
|
|
9380
|
+
continue;
|
|
9381
|
+
}
|
|
9382
|
+
const minCharacterValue = codePointAt(minCharacter, 0);
|
|
9383
|
+
const maxCharacterValue = codePointAt(maxCharacter, 0);
|
|
9384
|
+
if (minCharacter.length === charSize(minCharacterValue) && maxCharacter.length === charSize(maxCharacterValue) && minCharacterValue > maxCharacterValue) {
|
|
9385
|
+
error(Diagnostics.Range_out_of_order_in_character_class, minStart, pos - minStart);
|
|
9386
|
+
}
|
|
9387
|
+
}
|
|
9388
|
+
}
|
|
9389
|
+
}
|
|
9390
|
+
function scanClassSetExpression() {
|
|
9391
|
+
Debug.assertEqual(text2.charCodeAt(pos - 1), 91 /* openBracket */);
|
|
9392
|
+
let isCharacterComplement = false;
|
|
9393
|
+
if (text2.charCodeAt(pos) === 94 /* caret */) {
|
|
9394
|
+
pos++;
|
|
9395
|
+
isCharacterComplement = true;
|
|
9396
|
+
}
|
|
9397
|
+
let expressionMayContainStrings = false;
|
|
9398
|
+
let ch = text2.charCodeAt(pos);
|
|
9399
|
+
if (isClassContentExit(ch)) {
|
|
9400
|
+
return;
|
|
9401
|
+
}
|
|
9402
|
+
let start2 = pos;
|
|
9403
|
+
let oprand;
|
|
9404
|
+
switch (text2.slice(pos, pos + 2)) {
|
|
9405
|
+
case "--":
|
|
9406
|
+
case "&&":
|
|
9407
|
+
error(Diagnostics.Expected_a_class_set_oprand);
|
|
9408
|
+
mayContainStrings = false;
|
|
9409
|
+
break;
|
|
9410
|
+
default:
|
|
9411
|
+
oprand = scanClassSetOprand();
|
|
9412
|
+
break;
|
|
9413
|
+
}
|
|
9414
|
+
switch (text2.charCodeAt(pos)) {
|
|
9415
|
+
case 45 /* minus */:
|
|
9416
|
+
if (text2.charCodeAt(pos + 1) === 45 /* minus */) {
|
|
9417
|
+
if (isCharacterComplement && mayContainStrings) {
|
|
9418
|
+
error(Diagnostics.Anything_that_would_possibly_match_more_than_a_single_character_is_invalid_inside_a_negated_character_class, start2, pos - start2);
|
|
9419
|
+
}
|
|
9420
|
+
expressionMayContainStrings = mayContainStrings;
|
|
9421
|
+
scanClassSetSubExpression(3 /* ClassSubtraction */);
|
|
9422
|
+
mayContainStrings = !isCharacterComplement && expressionMayContainStrings;
|
|
9423
|
+
return;
|
|
9424
|
+
}
|
|
9425
|
+
break;
|
|
9426
|
+
case 38 /* ampersand */:
|
|
9427
|
+
if (text2.charCodeAt(pos + 1) === 38 /* ampersand */) {
|
|
9428
|
+
scanClassSetSubExpression(2 /* ClassIntersection */);
|
|
9429
|
+
if (isCharacterComplement && mayContainStrings) {
|
|
9430
|
+
error(Diagnostics.Anything_that_would_possibly_match_more_than_a_single_character_is_invalid_inside_a_negated_character_class, start2, pos - start2);
|
|
9431
|
+
}
|
|
9432
|
+
expressionMayContainStrings = mayContainStrings;
|
|
9433
|
+
mayContainStrings = !isCharacterComplement && expressionMayContainStrings;
|
|
9434
|
+
return;
|
|
9435
|
+
} else {
|
|
9436
|
+
error(Diagnostics.Unexpected_0_Did_you_mean_to_escape_it_with_backslash, pos, 1, String.fromCharCode(ch));
|
|
9437
|
+
}
|
|
9438
|
+
break;
|
|
9439
|
+
default:
|
|
9440
|
+
if (isCharacterComplement && mayContainStrings) {
|
|
9441
|
+
error(Diagnostics.Anything_that_would_possibly_match_more_than_a_single_character_is_invalid_inside_a_negated_character_class, start2, pos - start2);
|
|
9442
|
+
}
|
|
9443
|
+
expressionMayContainStrings = mayContainStrings;
|
|
9444
|
+
break;
|
|
9445
|
+
}
|
|
9446
|
+
while (pos < end2) {
|
|
9447
|
+
ch = text2.charCodeAt(pos);
|
|
9448
|
+
switch (ch) {
|
|
9449
|
+
case 45 /* minus */:
|
|
9450
|
+
pos++;
|
|
9451
|
+
ch = text2.charCodeAt(pos);
|
|
9452
|
+
if (isClassContentExit(ch)) {
|
|
9453
|
+
mayContainStrings = !isCharacterComplement && expressionMayContainStrings;
|
|
9454
|
+
return;
|
|
9455
|
+
}
|
|
9456
|
+
if (ch === 45 /* minus */) {
|
|
9457
|
+
pos++;
|
|
9458
|
+
error(Diagnostics.Operators_must_not_be_mixed_within_a_character_class_Wrap_it_in_a_nested_class_instead, pos - 2, 2);
|
|
9459
|
+
start2 = pos - 2;
|
|
9460
|
+
oprand = text2.slice(start2, pos);
|
|
9461
|
+
continue;
|
|
9462
|
+
} else {
|
|
9463
|
+
if (!oprand) {
|
|
9464
|
+
error(Diagnostics.A_character_class_range_must_not_be_bounded_by_another_character_class, start2, pos - 1 - start2);
|
|
9465
|
+
}
|
|
9466
|
+
const secondStart = pos;
|
|
9467
|
+
const secondOprand = scanClassSetOprand();
|
|
9468
|
+
if (isCharacterComplement && mayContainStrings) {
|
|
9469
|
+
error(Diagnostics.Anything_that_would_possibly_match_more_than_a_single_character_is_invalid_inside_a_negated_character_class, secondStart, pos - secondStart);
|
|
9470
|
+
}
|
|
9471
|
+
expressionMayContainStrings || (expressionMayContainStrings = mayContainStrings);
|
|
9472
|
+
if (!secondOprand) {
|
|
9473
|
+
error(Diagnostics.A_character_class_range_must_not_be_bounded_by_another_character_class, secondStart, pos - secondStart);
|
|
9474
|
+
break;
|
|
9475
|
+
}
|
|
9476
|
+
if (!oprand) {
|
|
9477
|
+
break;
|
|
9478
|
+
}
|
|
9479
|
+
const minCharacterValue = codePointAt(oprand, 0);
|
|
9480
|
+
const maxCharacterValue = codePointAt(secondOprand, 0);
|
|
9481
|
+
if (oprand.length === charSize(minCharacterValue) && secondOprand.length === charSize(maxCharacterValue) && minCharacterValue > maxCharacterValue) {
|
|
9482
|
+
error(Diagnostics.Range_out_of_order_in_character_class, start2, pos - start2);
|
|
9483
|
+
}
|
|
9484
|
+
}
|
|
9485
|
+
break;
|
|
9486
|
+
case 38 /* ampersand */:
|
|
9487
|
+
start2 = pos;
|
|
9488
|
+
pos++;
|
|
9489
|
+
if (text2.charCodeAt(pos) === 38 /* ampersand */) {
|
|
9490
|
+
pos++;
|
|
9491
|
+
error(Diagnostics.Operators_must_not_be_mixed_within_a_character_class_Wrap_it_in_a_nested_class_instead, pos - 2, 2);
|
|
9492
|
+
if (text2.charCodeAt(pos) === 38 /* ampersand */) {
|
|
9493
|
+
error(Diagnostics.Unexpected_0_Did_you_mean_to_escape_it_with_backslash, pos, 1, String.fromCharCode(ch));
|
|
9494
|
+
pos++;
|
|
9495
|
+
}
|
|
9496
|
+
} else {
|
|
9497
|
+
error(Diagnostics.Unexpected_0_Did_you_mean_to_escape_it_with_backslash, pos - 1, 1, String.fromCharCode(ch));
|
|
9498
|
+
}
|
|
9499
|
+
oprand = text2.slice(start2, pos);
|
|
9500
|
+
continue;
|
|
9501
|
+
}
|
|
9502
|
+
if (isClassContentExit(text2.charCodeAt(pos))) {
|
|
9503
|
+
break;
|
|
9504
|
+
}
|
|
9505
|
+
start2 = pos;
|
|
9506
|
+
switch (text2.slice(pos, pos + 2)) {
|
|
9507
|
+
case "--":
|
|
9508
|
+
case "&&":
|
|
9509
|
+
error(Diagnostics.Operators_must_not_be_mixed_within_a_character_class_Wrap_it_in_a_nested_class_instead, pos, 2);
|
|
9510
|
+
pos += 2;
|
|
9511
|
+
oprand = text2.slice(start2, pos);
|
|
9512
|
+
break;
|
|
9513
|
+
default:
|
|
9514
|
+
oprand = scanClassSetOprand();
|
|
9515
|
+
break;
|
|
9516
|
+
}
|
|
9517
|
+
}
|
|
9518
|
+
mayContainStrings = !isCharacterComplement && expressionMayContainStrings;
|
|
9519
|
+
}
|
|
9520
|
+
function scanClassSetSubExpression(expressionType) {
|
|
9521
|
+
let expressionMayContainStrings = mayContainStrings;
|
|
9522
|
+
while (pos < end2) {
|
|
9523
|
+
let ch = text2.charCodeAt(pos);
|
|
9524
|
+
if (isClassContentExit(ch)) {
|
|
9525
|
+
break;
|
|
9526
|
+
}
|
|
9527
|
+
switch (ch) {
|
|
9528
|
+
case 45 /* minus */:
|
|
9529
|
+
pos++;
|
|
9530
|
+
if (text2.charCodeAt(pos) === 45 /* minus */) {
|
|
9531
|
+
pos++;
|
|
9532
|
+
if (expressionType !== 3 /* ClassSubtraction */) {
|
|
9533
|
+
error(Diagnostics.Operators_must_not_be_mixed_within_a_character_class_Wrap_it_in_a_nested_class_instead, pos - 2, 2);
|
|
9534
|
+
}
|
|
9535
|
+
} else {
|
|
9536
|
+
error(Diagnostics.Operators_must_not_be_mixed_within_a_character_class_Wrap_it_in_a_nested_class_instead, pos - 1, 1);
|
|
9537
|
+
}
|
|
9538
|
+
break;
|
|
9539
|
+
case 38 /* ampersand */:
|
|
9540
|
+
pos++;
|
|
9541
|
+
if (text2.charCodeAt(pos) === 38 /* ampersand */) {
|
|
9542
|
+
pos++;
|
|
9543
|
+
if (expressionType !== 2 /* ClassIntersection */) {
|
|
9544
|
+
error(Diagnostics.Operators_must_not_be_mixed_within_a_character_class_Wrap_it_in_a_nested_class_instead, pos - 2, 2);
|
|
9545
|
+
}
|
|
9546
|
+
if (text2.charCodeAt(pos) === 38 /* ampersand */) {
|
|
9547
|
+
error(Diagnostics.Unexpected_0_Did_you_mean_to_escape_it_with_backslash, pos, 1, String.fromCharCode(ch));
|
|
9548
|
+
pos++;
|
|
9549
|
+
}
|
|
9550
|
+
} else {
|
|
9551
|
+
error(Diagnostics.Unexpected_0_Did_you_mean_to_escape_it_with_backslash, pos - 1, 1, String.fromCharCode(ch));
|
|
9552
|
+
}
|
|
9553
|
+
break;
|
|
9554
|
+
default:
|
|
9555
|
+
switch (expressionType) {
|
|
9556
|
+
case 3 /* ClassSubtraction */:
|
|
9557
|
+
error(Diagnostics._0_expected, pos, 0, "--");
|
|
9558
|
+
break;
|
|
9559
|
+
case 2 /* ClassIntersection */:
|
|
9560
|
+
error(Diagnostics._0_expected, pos, 0, "&&");
|
|
9561
|
+
break;
|
|
9562
|
+
default:
|
|
9563
|
+
break;
|
|
9564
|
+
}
|
|
9565
|
+
break;
|
|
9566
|
+
}
|
|
9567
|
+
ch = text2.charCodeAt(pos);
|
|
9568
|
+
if (isClassContentExit(ch)) {
|
|
9569
|
+
error(Diagnostics.Expected_a_class_set_oprand);
|
|
9570
|
+
break;
|
|
9571
|
+
}
|
|
9572
|
+
scanClassSetOprand();
|
|
9573
|
+
expressionMayContainStrings && (expressionMayContainStrings = mayContainStrings);
|
|
9574
|
+
}
|
|
9575
|
+
mayContainStrings = expressionMayContainStrings;
|
|
9576
|
+
}
|
|
9577
|
+
function scanClassSetOprand() {
|
|
9578
|
+
mayContainStrings = false;
|
|
9579
|
+
switch (text2.charCodeAt(pos)) {
|
|
9580
|
+
case 91 /* openBracket */:
|
|
9581
|
+
pos++;
|
|
9582
|
+
scanClassSetExpression();
|
|
9583
|
+
scanExpectedChar(93 /* closeBracket */);
|
|
9584
|
+
return "";
|
|
9585
|
+
case 92 /* backslash */:
|
|
9586
|
+
pos++;
|
|
9587
|
+
if (scanCharacterClassEscape()) {
|
|
9588
|
+
return "";
|
|
9589
|
+
} else if (text2.charCodeAt(pos) === 113 /* q */) {
|
|
9590
|
+
pos++;
|
|
9591
|
+
if (text2.charCodeAt(pos) === 123 /* openBrace */) {
|
|
9592
|
+
pos++;
|
|
9593
|
+
scanClassStringDisjunctionContents();
|
|
9594
|
+
scanExpectedChar(125 /* closeBrace */);
|
|
9595
|
+
return "";
|
|
9596
|
+
} else {
|
|
9597
|
+
error(Diagnostics.q_must_be_followed_by_string_alternatives_enclosed_in_braces, pos - 2, 2);
|
|
9598
|
+
return "q";
|
|
9599
|
+
}
|
|
9600
|
+
}
|
|
9601
|
+
pos--;
|
|
9602
|
+
default:
|
|
9603
|
+
return scanClassSetCharacter();
|
|
9604
|
+
}
|
|
9605
|
+
}
|
|
9606
|
+
function scanClassStringDisjunctionContents() {
|
|
9607
|
+
Debug.assertEqual(text2.charCodeAt(pos - 1), 123 /* openBrace */);
|
|
9608
|
+
let characterCount = 0;
|
|
9609
|
+
while (pos < end2) {
|
|
9610
|
+
const ch = text2.charCodeAt(pos);
|
|
9611
|
+
switch (ch) {
|
|
9612
|
+
case 125 /* closeBrace */:
|
|
9613
|
+
if (characterCount !== 1) {
|
|
9614
|
+
mayContainStrings = true;
|
|
9615
|
+
}
|
|
9616
|
+
return;
|
|
9617
|
+
case 124 /* bar */:
|
|
9618
|
+
if (characterCount !== 1) {
|
|
9619
|
+
mayContainStrings = true;
|
|
9620
|
+
}
|
|
9621
|
+
pos++;
|
|
9622
|
+
start = pos;
|
|
9623
|
+
characterCount = 0;
|
|
9624
|
+
break;
|
|
9625
|
+
default:
|
|
9626
|
+
scanClassSetCharacter();
|
|
9627
|
+
characterCount++;
|
|
9628
|
+
break;
|
|
9629
|
+
}
|
|
9630
|
+
}
|
|
9631
|
+
}
|
|
9632
|
+
function scanClassSetCharacter() {
|
|
9633
|
+
const ch = text2.charCodeAt(pos);
|
|
9634
|
+
if (ch === 92 /* backslash */) {
|
|
9635
|
+
pos++;
|
|
9636
|
+
const ch2 = text2.charCodeAt(pos);
|
|
9637
|
+
switch (ch2) {
|
|
9638
|
+
case 98 /* b */:
|
|
9639
|
+
pos++;
|
|
9640
|
+
return "\b";
|
|
9641
|
+
case 38 /* ampersand */:
|
|
9642
|
+
case 45 /* minus */:
|
|
9643
|
+
case 33 /* exclamation */:
|
|
9644
|
+
case 35 /* hash */:
|
|
9645
|
+
case 37 /* percent */:
|
|
9646
|
+
case 44 /* comma */:
|
|
9647
|
+
case 58 /* colon */:
|
|
9648
|
+
case 59 /* semicolon */:
|
|
9649
|
+
case 60 /* lessThan */:
|
|
9650
|
+
case 61 /* equals */:
|
|
9651
|
+
case 62 /* greaterThan */:
|
|
9652
|
+
case 64 /* at */:
|
|
9653
|
+
case 96 /* backtick */:
|
|
9654
|
+
case 126 /* tilde */:
|
|
9655
|
+
pos++;
|
|
9656
|
+
return String.fromCharCode(ch2);
|
|
9657
|
+
default:
|
|
9658
|
+
return scanCharacterEscape();
|
|
9659
|
+
}
|
|
9660
|
+
} else if (ch === text2.charCodeAt(pos + 1)) {
|
|
9661
|
+
switch (ch) {
|
|
9662
|
+
case 38 /* ampersand */:
|
|
9663
|
+
case 33 /* exclamation */:
|
|
9664
|
+
case 35 /* hash */:
|
|
9665
|
+
case 37 /* percent */:
|
|
9666
|
+
case 42 /* asterisk */:
|
|
9667
|
+
case 43 /* plus */:
|
|
9668
|
+
case 44 /* comma */:
|
|
9669
|
+
case 46 /* dot */:
|
|
9670
|
+
case 58 /* colon */:
|
|
9671
|
+
case 59 /* semicolon */:
|
|
9672
|
+
case 60 /* lessThan */:
|
|
9673
|
+
case 61 /* equals */:
|
|
9674
|
+
case 62 /* greaterThan */:
|
|
9675
|
+
case 63 /* question */:
|
|
9676
|
+
case 64 /* at */:
|
|
9677
|
+
case 96 /* backtick */:
|
|
9678
|
+
case 126 /* tilde */:
|
|
9679
|
+
error(Diagnostics.A_character_class_must_not_contain_a_reserved_double_punctuator_Did_you_mean_to_escape_it_with_backslash, pos, 2);
|
|
9680
|
+
pos += 2;
|
|
9681
|
+
return text2.substring(pos - 2, pos);
|
|
9682
|
+
}
|
|
9683
|
+
}
|
|
9684
|
+
switch (ch) {
|
|
9685
|
+
case 47 /* slash */:
|
|
9686
|
+
case 40 /* openParen */:
|
|
9687
|
+
case 41 /* closeParen */:
|
|
9688
|
+
case 91 /* openBracket */:
|
|
9689
|
+
case 93 /* closeBracket */:
|
|
9690
|
+
case 123 /* openBrace */:
|
|
9691
|
+
case 125 /* closeBrace */:
|
|
9692
|
+
case 45 /* minus */:
|
|
9693
|
+
case 124 /* bar */:
|
|
9694
|
+
error(Diagnostics.Unexpected_0_Did_you_mean_to_escape_it_with_backslash, pos, 1, String.fromCharCode(ch));
|
|
9695
|
+
pos++;
|
|
9696
|
+
return String.fromCharCode(ch);
|
|
9697
|
+
}
|
|
9698
|
+
return scanSourceCharacter();
|
|
9699
|
+
}
|
|
9700
|
+
function scanClassAtom() {
|
|
9701
|
+
if (text2.charCodeAt(pos) === 92 /* backslash */) {
|
|
9702
|
+
pos++;
|
|
9703
|
+
const ch = text2.charCodeAt(pos);
|
|
9704
|
+
switch (ch) {
|
|
9705
|
+
case 98 /* b */:
|
|
9706
|
+
pos++;
|
|
9707
|
+
return "\b";
|
|
9708
|
+
case 45 /* minus */:
|
|
9709
|
+
pos++;
|
|
9710
|
+
return String.fromCharCode(ch);
|
|
9711
|
+
default:
|
|
9712
|
+
if (scanCharacterClassEscape()) {
|
|
9713
|
+
return "";
|
|
9714
|
+
}
|
|
9715
|
+
return scanCharacterEscape();
|
|
9716
|
+
}
|
|
9717
|
+
} else {
|
|
9718
|
+
return scanSourceCharacter();
|
|
9719
|
+
}
|
|
9720
|
+
}
|
|
9721
|
+
function scanCharacterClassEscape() {
|
|
9722
|
+
Debug.assertEqual(text2.charCodeAt(pos - 1), 92 /* backslash */);
|
|
9723
|
+
let isCharacterComplement = false;
|
|
9724
|
+
const start2 = pos - 1;
|
|
9725
|
+
const ch = text2.charCodeAt(pos);
|
|
9726
|
+
switch (ch) {
|
|
9727
|
+
case 100 /* d */:
|
|
9728
|
+
case 68 /* D */:
|
|
9729
|
+
case 115 /* s */:
|
|
9730
|
+
case 83 /* S */:
|
|
9731
|
+
case 119 /* w */:
|
|
9732
|
+
case 87 /* W */:
|
|
9733
|
+
pos++;
|
|
9734
|
+
return true;
|
|
9735
|
+
case 80 /* P */:
|
|
9736
|
+
isCharacterComplement = true;
|
|
9737
|
+
case 112 /* p */:
|
|
9738
|
+
pos++;
|
|
9739
|
+
if (text2.charCodeAt(pos) === 123 /* openBrace */) {
|
|
9740
|
+
pos++;
|
|
9741
|
+
const propertyNameOrValueStart = pos;
|
|
9742
|
+
const propertyNameOrValue = scanWordCharacters();
|
|
9743
|
+
if (text2.charCodeAt(pos) === 61 /* equals */) {
|
|
9744
|
+
const propertyName = nonBinaryUnicodeProperties.get(propertyNameOrValue);
|
|
9745
|
+
if (pos === propertyNameOrValueStart) {
|
|
9746
|
+
error(Diagnostics.Expected_a_Unicode_property_name);
|
|
9747
|
+
} else if (propertyName === void 0) {
|
|
9748
|
+
error(Diagnostics.Unknown_Unicode_property_name, propertyNameOrValueStart, pos - propertyNameOrValueStart);
|
|
9749
|
+
const suggestion = getSpellingSuggestion(propertyNameOrValue, nonBinaryUnicodeProperties.keys(), identity);
|
|
9750
|
+
if (suggestion) {
|
|
9751
|
+
error(Diagnostics.Did_you_mean_0, propertyNameOrValueStart, pos - propertyNameOrValueStart, suggestion);
|
|
9752
|
+
}
|
|
9753
|
+
}
|
|
9754
|
+
pos++;
|
|
9755
|
+
const propertyValueStart = pos;
|
|
9756
|
+
const propertyValue = scanWordCharacters();
|
|
9757
|
+
if (pos === propertyValueStart) {
|
|
9758
|
+
error(Diagnostics.Expected_a_Unicode_property_value);
|
|
9759
|
+
} else if (propertyName !== void 0 && !valuesOfNonBinaryUnicodeProperties[propertyName].has(propertyValue)) {
|
|
9760
|
+
error(Diagnostics.Unknown_Unicode_property_value, propertyValueStart, pos - propertyValueStart);
|
|
9761
|
+
const suggestion = getSpellingSuggestion(propertyValue, valuesOfNonBinaryUnicodeProperties[propertyName], identity);
|
|
9762
|
+
if (suggestion) {
|
|
9763
|
+
error(Diagnostics.Did_you_mean_0, propertyValueStart, pos - propertyValueStart, suggestion);
|
|
9764
|
+
}
|
|
9765
|
+
}
|
|
9766
|
+
} else {
|
|
9767
|
+
if (pos === propertyNameOrValueStart) {
|
|
9768
|
+
error(Diagnostics.Expected_a_Unicode_property_name_or_value);
|
|
9769
|
+
} else if (binaryUnicodePropertiesOfStrings.has(propertyNameOrValue)) {
|
|
9770
|
+
if (!unicodeSetsMode) {
|
|
9771
|
+
error(Diagnostics.Any_Unicode_property_that_would_possibly_match_more_than_a_single_character_is_only_available_when_the_Unicode_Sets_v_flag_is_set, propertyNameOrValueStart, pos - propertyNameOrValueStart);
|
|
9772
|
+
} else if (isCharacterComplement) {
|
|
9773
|
+
error(Diagnostics.Anything_that_would_possibly_match_more_than_a_single_character_is_invalid_inside_a_negated_character_class, propertyNameOrValueStart, pos - propertyNameOrValueStart);
|
|
9774
|
+
} else {
|
|
9775
|
+
mayContainStrings = true;
|
|
9776
|
+
}
|
|
9777
|
+
} else if (!valuesOfNonBinaryUnicodeProperties.General_Category.has(propertyNameOrValue) && !binaryUnicodeProperties.has(propertyNameOrValue)) {
|
|
9778
|
+
error(Diagnostics.Unknown_Unicode_property_name_or_value, propertyNameOrValueStart, pos - propertyNameOrValueStart);
|
|
9779
|
+
const suggestion = getSpellingSuggestion(propertyNameOrValue, [...valuesOfNonBinaryUnicodeProperties.General_Category, ...binaryUnicodeProperties, ...binaryUnicodePropertiesOfStrings], identity);
|
|
9780
|
+
if (suggestion) {
|
|
9781
|
+
error(Diagnostics.Did_you_mean_0, propertyNameOrValueStart, pos - propertyNameOrValueStart, suggestion);
|
|
9782
|
+
}
|
|
9783
|
+
}
|
|
9784
|
+
}
|
|
9785
|
+
scanExpectedChar(125 /* closeBrace */);
|
|
9786
|
+
if (!unicodeMode) {
|
|
9787
|
+
error(Diagnostics.Unicode_property_value_expressions_are_only_available_when_the_Unicode_u_flag_or_the_Unicode_Sets_v_flag_is_set, start2, pos - start2);
|
|
9788
|
+
}
|
|
9789
|
+
} else if (unicodeMode) {
|
|
9790
|
+
error(Diagnostics._0_must_be_followed_by_a_Unicode_property_value_expression_enclosed_in_braces, pos - 2, 2, String.fromCharCode(ch));
|
|
9791
|
+
}
|
|
9792
|
+
return true;
|
|
9793
|
+
}
|
|
9794
|
+
return false;
|
|
9795
|
+
}
|
|
9796
|
+
function scanWordCharacters() {
|
|
9797
|
+
let value = "";
|
|
9798
|
+
while (pos < end2) {
|
|
9799
|
+
const ch = text2.charCodeAt(pos);
|
|
9800
|
+
if (!isWordCharacter(ch)) {
|
|
9801
|
+
break;
|
|
9802
|
+
}
|
|
9803
|
+
value += String.fromCharCode(ch);
|
|
9804
|
+
pos++;
|
|
9805
|
+
}
|
|
9806
|
+
return value;
|
|
9807
|
+
}
|
|
9808
|
+
function scanSourceCharacter() {
|
|
9809
|
+
const size = unicodeMode ? charSize(codePointAt(text2, pos)) : 1;
|
|
9810
|
+
pos += size;
|
|
9811
|
+
return text2.substring(pos - size, pos);
|
|
9812
|
+
}
|
|
9813
|
+
function scanExpectedChar(ch) {
|
|
9814
|
+
if (text2.charCodeAt(pos) === ch) {
|
|
9815
|
+
pos++;
|
|
9816
|
+
} else {
|
|
9817
|
+
error(Diagnostics._0_expected, pos, 0, String.fromCharCode(ch));
|
|
9818
|
+
}
|
|
9819
|
+
}
|
|
9820
|
+
scanDisjunction(
|
|
9821
|
+
/*isInGroup*/
|
|
9822
|
+
false
|
|
9823
|
+
);
|
|
9824
|
+
forEach(groupNameReferences, (reference) => {
|
|
9825
|
+
if (!groupSpecifiers.has(reference.name)) {
|
|
9826
|
+
error(Diagnostics.There_is_no_capturing_group_named_0_in_this_regular_expression, reference.pos, reference.end - reference.pos, reference.name);
|
|
9827
|
+
}
|
|
9828
|
+
});
|
|
9829
|
+
forEach(decimalEscapes, (escape) => {
|
|
9830
|
+
if (escape.value > numberOfCapturingGroups) {
|
|
9831
|
+
if (numberOfCapturingGroups) {
|
|
9832
|
+
error(Diagnostics.A_decimal_escape_must_refer_to_an_existent_capturing_group_There_are_only_0_capturing_groups_in_this_regular_expression, escape.pos, escape.end - escape.pos, numberOfCapturingGroups);
|
|
9833
|
+
} else {
|
|
9834
|
+
error(Diagnostics.Decimal_escapes_are_invalid_when_there_are_no_capturing_groups_in_a_regular_expression, escape.pos, escape.end - escape.pos);
|
|
9835
|
+
}
|
|
9836
|
+
}
|
|
9837
|
+
});
|
|
9838
|
+
}
|
|
8931
9839
|
}
|
|
8932
9840
|
function appendIfCommentDirective(commentDirectives2, text2, commentDirectiveRegEx, lineStart) {
|
|
8933
9841
|
const type = getDirectiveFromComment(text2.trimStart(), commentDirectiveRegEx);
|
|
@@ -9150,8 +10058,6 @@ function createScanner(languageVersion, skipTrivia2, languageVariant = 0 /* Stan
|
|
|
9150
10058
|
pos--;
|
|
9151
10059
|
const extendedCookedChar = peekExtendedUnicodeEscape();
|
|
9152
10060
|
if (extendedCookedChar >= 0 && isIdentifierStart(extendedCookedChar, languageVersion)) {
|
|
9153
|
-
pos += 3;
|
|
9154
|
-
tokenFlags |= 8 /* ExtendedUnicodeEscape */;
|
|
9155
10061
|
tokenValue = scanExtendedUnicodeEscape() + scanIdentifierParts();
|
|
9156
10062
|
return token = getIdentifierToken();
|
|
9157
10063
|
}
|
|
@@ -9289,6 +10195,22 @@ var utf16EncodeAsStringWorker = String.fromCodePoint ? (codePoint) => String.fro
|
|
|
9289
10195
|
function utf16EncodeAsString(codePoint) {
|
|
9290
10196
|
return utf16EncodeAsStringWorker(codePoint);
|
|
9291
10197
|
}
|
|
10198
|
+
var nonBinaryUnicodeProperties = new Map(Object.entries({
|
|
10199
|
+
General_Category: "General_Category",
|
|
10200
|
+
gc: "General_Category",
|
|
10201
|
+
Script: "Script",
|
|
10202
|
+
sc: "Script",
|
|
10203
|
+
Script_Extensions: "Script_Extensions",
|
|
10204
|
+
scx: "Script_Extensions"
|
|
10205
|
+
}));
|
|
10206
|
+
var binaryUnicodeProperties = /* @__PURE__ */ new Set(["ASCII", "ASCII_Hex_Digit", "AHex", "Alphabetic", "Alpha", "Any", "Assigned", "Bidi_Control", "Bidi_C", "Bidi_Mirrored", "Bidi_M", "Case_Ignorable", "CI", "Cased", "Changes_When_Casefolded", "CWCF", "Changes_When_Casemapped", "CWCM", "Changes_When_Lowercased", "CWL", "Changes_When_NFKC_Casefolded", "CWKCF", "Changes_When_Titlecased", "CWT", "Changes_When_Uppercased", "CWU", "Dash", "Default_Ignorable_Code_Point", "DI", "Deprecated", "Dep", "Diacritic", "Dia", "Emoji", "Emoji_Component", "EComp", "Emoji_Modifier", "EMod", "Emoji_Modifier_Base", "EBase", "Emoji_Presentation", "EPres", "Extended_Pictographic", "ExtPict", "Extender", "Ext", "Grapheme_Base", "Gr_Base", "Grapheme_Extend", "Gr_Ext", "Hex_Digit", "Hex", "IDS_Binary_Operator", "IDSB", "IDS_Trinary_Operator", "IDST", "ID_Continue", "IDC", "ID_Start", "IDS", "Ideographic", "Ideo", "Join_Control", "Join_C", "Logical_Order_Exception", "LOE", "Lowercase", "Lower", "Math", "Noncharacter_Code_Point", "NChar", "Pattern_Syntax", "Pat_Syn", "Pattern_White_Space", "Pat_WS", "Quotation_Mark", "QMark", "Radical", "Regional_Indicator", "RI", "Sentence_Terminal", "STerm", "Soft_Dotted", "SD", "Terminal_Punctuation", "Term", "Unified_Ideograph", "UIdeo", "Uppercase", "Upper", "Variation_Selector", "VS", "White_Space", "space", "XID_Continue", "XIDC", "XID_Start", "XIDS"]);
|
|
10207
|
+
var binaryUnicodePropertiesOfStrings = /* @__PURE__ */ new Set(["Basic_Emoji", "Emoji_Keycap_Sequence", "RGI_Emoji_Modifier_Sequence", "RGI_Emoji_Flag_Sequence", "RGI_Emoji_Tag_Sequence", "RGI_Emoji_ZWJ_Sequence", "RGI_Emoji"]);
|
|
10208
|
+
var valuesOfNonBinaryUnicodeProperties = {
|
|
10209
|
+
General_Category: /* @__PURE__ */ new Set(["C", "Other", "Cc", "Control", "cntrl", "Cf", "Format", "Cn", "Unassigned", "Co", "Private_Use", "Cs", "Surrogate", "L", "Letter", "LC", "Cased_Letter", "Ll", "Lowercase_Letter", "Lm", "Modifier_Letter", "Lo", "Other_Letter", "Lt", "Titlecase_Letter", "Lu", "Uppercase_Letter", "M", "Mark", "Combining_Mark", "Mc", "Spacing_Mark", "Me", "Enclosing_Mark", "Mn", "Nonspacing_Mark", "N", "Number", "Nd", "Decimal_Number", "digit", "Nl", "Letter_Number", "No", "Other_Number", "P", "Punctuation", "punct", "Pc", "Connector_Punctuation", "Pd", "Dash_Punctuation", "Pe", "Close_Punctuation", "Pf", "Final_Punctuation", "Pi", "Initial_Punctuation", "Po", "Other_Punctuation", "Ps", "Open_Punctuation", "S", "Symbol", "Sc", "Currency_Symbol", "Sk", "Modifier_Symbol", "Sm", "Math_Symbol", "So", "Other_Symbol", "Z", "Separator", "Zl", "Line_Separator", "Zp", "Paragraph_Separator", "Zs", "Space_Separator"]),
|
|
10210
|
+
Script: /* @__PURE__ */ new Set(["Adlm", "Adlam", "Aghb", "Caucasian_Albanian", "Ahom", "Ahom", "Arab", "Arabic", "Armi", "Imperial_Aramaic", "Armn", "Armenian", "Avst", "Avestan", "Bali", "Balinese", "Bamu", "Bamum", "Bass", "Bassa_Vah", "Batk", "Batak", "Beng", "Bengali", "Bhks", "Bhaiksuki", "Bopo", "Bopomofo", "Brah", "Brahmi", "Brai", "Braille", "Bugi", "Buginese", "Buhd", "Buhid", "Cakm", "Chakma", "Cans", "Canadian_Aboriginal", "Cari", "Carian", "Cham", "Cham", "Cher", "Cherokee", "Chrs", "Chorasmian", "Copt", "Coptic", "Qaac", "Cpmn", "Cypro_Minoan", "Cprt", "Cypriot", "Cyrl", "Cyrillic", "Deva", "Devanagari", "Diak", "Dives_Akuru", "Dogr", "Dogra", "Dsrt", "Deseret", "Dupl", "Duployan", "Egyp", "Egyptian_Hieroglyphs", "Elba", "Elbasan", "Elym", "Elymaic", "Ethi", "Ethiopic", "Geor", "Georgian", "Glag", "Glagolitic", "Gong", "Gunjala_Gondi", "Gonm", "Masaram_Gondi", "Goth", "Gothic", "Gran", "Grantha", "Grek", "Greek", "Gujr", "Gujarati", "Guru", "Gurmukhi", "Hang", "Hangul", "Hani", "Han", "Hano", "Hanunoo", "Hatr", "Hatran", "Hebr", "Hebrew", "Hira", "Hiragana", "Hluw", "Anatolian_Hieroglyphs", "Hmng", "Pahawh_Hmong", "Hmnp", "Nyiakeng_Puachue_Hmong", "Hrkt", "Katakana_Or_Hiragana", "Hung", "Old_Hungarian", "Ital", "Old_Italic", "Java", "Javanese", "Kali", "Kayah_Li", "Kana", "Katakana", "Kawi", "Kawi", "Khar", "Kharoshthi", "Khmr", "Khmer", "Khoj", "Khojki", "Kits", "Khitan_Small_Script", "Knda", "Kannada", "Kthi", "Kaithi", "Lana", "Tai_Tham", "Laoo", "Lao", "Latn", "Latin", "Lepc", "Lepcha", "Limb", "Limbu", "Lina", "Linear_A", "Linb", "Linear_B", "Lisu", "Lisu", "Lyci", "Lycian", "Lydi", "Lydian", "Mahj", "Mahajani", "Maka", "Makasar", "Mand", "Mandaic", "Mani", "Manichaean", "Marc", "Marchen", "Medf", "Medefaidrin", "Mend", "Mende_Kikakui", "Merc", "Meroitic_Cursive", "Mero", "Meroitic_Hieroglyphs", "Mlym", "Malayalam", "Modi", "Modi", "Mong", "Mongolian", "Mroo", "Mro", "Mtei", "Meetei_Mayek", "Mult", "Multani", "Mymr", "Myanmar", "Nagm", "Nag_Mundari", "Nand", "Nandinagari", "Narb", "Old_North_Arabian", "Nbat", "Nabataean", "Newa", "Newa", "Nkoo", "Nko", "Nshu", "Nushu", "Ogam", "Ogham", "Olck", "Ol_Chiki", "Orkh", "Old_Turkic", "Orya", "Oriya", "Osge", "Osage", "Osma", "Osmanya", "Ougr", "Old_Uyghur", "Palm", "Palmyrene", "Pauc", "Pau_Cin_Hau", "Perm", "Old_Permic", "Phag", "Phags_Pa", "Phli", "Inscriptional_Pahlavi", "Phlp", "Psalter_Pahlavi", "Phnx", "Phoenician", "Plrd", "Miao", "Prti", "Inscriptional_Parthian", "Rjng", "Rejang", "Rohg", "Hanifi_Rohingya", "Runr", "Runic", "Samr", "Samaritan", "Sarb", "Old_South_Arabian", "Saur", "Saurashtra", "Sgnw", "SignWriting", "Shaw", "Shavian", "Shrd", "Sharada", "Sidd", "Siddham", "Sind", "Khudawadi", "Sinh", "Sinhala", "Sogd", "Sogdian", "Sogo", "Old_Sogdian", "Sora", "Sora_Sompeng", "Soyo", "Soyombo", "Sund", "Sundanese", "Sylo", "Syloti_Nagri", "Syrc", "Syriac", "Tagb", "Tagbanwa", "Takr", "Takri", "Tale", "Tai_Le", "Talu", "New_Tai_Lue", "Taml", "Tamil", "Tang", "Tangut", "Tavt", "Tai_Viet", "Telu", "Telugu", "Tfng", "Tifinagh", "Tglg", "Tagalog", "Thaa", "Thaana", "Thai", "Thai", "Tibt", "Tibetan", "Tirh", "Tirhuta", "Tnsa", "Tangsa", "Toto", "Toto", "Ugar", "Ugaritic", "Vaii", "Vai", "Vith", "Vithkuqi", "Wara", "Warang_Citi", "Wcho", "Wancho", "Xpeo", "Old_Persian", "Xsux", "Cuneiform", "Yezi", "Yezidi", "Yiii", "Yi", "Zanb", "Zanabazar_Square", "Zinh", "Inherited", "Qaai", "Zyyy", "Common", "Zzzz", "Unknown"]),
|
|
10211
|
+
Script_Extensions: /* @__PURE__ */ new Set()
|
|
10212
|
+
// Currently empty
|
|
10213
|
+
};
|
|
9292
10214
|
|
|
9293
10215
|
// src/compiler/utilitiesPublic.ts
|
|
9294
10216
|
function isExternalModuleNameRelative(moduleName) {
|
|
@@ -18740,7 +19662,10 @@ var Parser;
|
|
|
18740
19662
|
function parseErrorAtPosition(start, length2, message, ...args) {
|
|
18741
19663
|
const lastError = lastOrUndefined(parseDiagnostics);
|
|
18742
19664
|
let result;
|
|
18743
|
-
if (
|
|
19665
|
+
if (message.category === 3 /* Message */ && lastError && start === lastError.start && length2 === lastError.length) {
|
|
19666
|
+
result = createDetachedDiagnostic(fileName, sourceText, start, length2, message, ...args);
|
|
19667
|
+
addRelatedInfo(lastError, result);
|
|
19668
|
+
} else if (!lastError || start !== lastError.start) {
|
|
18744
19669
|
result = createDetachedDiagnostic(fileName, sourceText, start, length2, message, ...args);
|
|
18745
19670
|
parseDiagnostics.push(result);
|
|
18746
19671
|
}
|
|
@@ -18896,7 +19821,7 @@ var Parser;
|
|
|
18896
19821
|
parseErrorForInvalidName(Diagnostics.Type_alias_name_cannot_be_0, Diagnostics.Type_alias_must_be_given_a_name, 64 /* EqualsToken */);
|
|
18897
19822
|
return;
|
|
18898
19823
|
}
|
|
18899
|
-
const suggestion = getSpellingSuggestion(expressionText, viableKeywordSuggestions,
|
|
19824
|
+
const suggestion = getSpellingSuggestion(expressionText, viableKeywordSuggestions, identity) ?? getSpaceSuggestion(expressionText);
|
|
18900
19825
|
if (suggestion) {
|
|
18901
19826
|
parseErrorAt(pos, node.end, Diagnostics.Unknown_keyword_or_identifier_Did_you_mean_0, suggestion);
|
|
18902
19827
|
return;
|