source: imaps-frontend/node_modules/@eslint-community/regexpp/index.mjs@ 0c6b92a

main
Last change on this file since 0c6b92a was 0c6b92a, checked in by stefan toskovski <stefantoska84@…>, 5 weeks ago

Pred finalna verzija

  • Property mode set to 100644
File size: 106.6 KB
Line 
1var ast = /*#__PURE__*/Object.freeze({
2 __proto__: null
3});
4
5const latestEcmaVersion = 2025;
6
7let largeIdStartRanges = undefined;
8let largeIdContinueRanges = undefined;
9function isIdStart(cp) {
10 if (cp < 0x41)
11 return false;
12 if (cp < 0x5b)
13 return true;
14 if (cp < 0x61)
15 return false;
16 if (cp < 0x7b)
17 return true;
18 return isLargeIdStart(cp);
19}
20function isIdContinue(cp) {
21 if (cp < 0x30)
22 return false;
23 if (cp < 0x3a)
24 return true;
25 if (cp < 0x41)
26 return false;
27 if (cp < 0x5b)
28 return true;
29 if (cp === 0x5f)
30 return true;
31 if (cp < 0x61)
32 return false;
33 if (cp < 0x7b)
34 return true;
35 return isLargeIdStart(cp) || isLargeIdContinue(cp);
36}
37function isLargeIdStart(cp) {
38 return isInRange(cp, largeIdStartRanges !== null && largeIdStartRanges !== void 0 ? largeIdStartRanges : (largeIdStartRanges = initLargeIdStartRanges()));
39}
40function isLargeIdContinue(cp) {
41 return isInRange(cp, largeIdContinueRanges !== null && largeIdContinueRanges !== void 0 ? largeIdContinueRanges : (largeIdContinueRanges = initLargeIdContinueRanges()));
42}
43function initLargeIdStartRanges() {
44 return restoreRanges("4q 0 b 0 5 0 6 m 2 u 2 cp 5 b f 4 8 0 2 0 3m 4 2 1 3 3 2 0 7 0 2 2 2 0 2 j 2 2a 2 3u 9 4l 2 11 3 0 7 14 20 q 5 3 1a 16 10 1 2 2q 2 0 g 1 8 1 b 2 3 0 h 0 2 t u 2g c 0 p w a 1 5 0 6 l 5 0 a 0 4 0 o o 8 a 6 n 2 5 i 15 1n 1h 4 0 j 0 8 9 g f 5 7 3 1 3 l 2 6 2 0 4 3 4 0 h 0 e 1 2 2 f 1 b 0 9 5 5 1 3 l 2 6 2 1 2 1 2 1 w 3 2 0 k 2 h 8 2 2 2 l 2 6 2 1 2 4 4 0 j 0 g 1 o 0 c 7 3 1 3 l 2 6 2 1 2 4 4 0 v 1 2 2 g 0 i 0 2 5 4 2 2 3 4 1 2 0 2 1 4 1 4 2 4 b n 0 1h 7 2 2 2 m 2 f 4 0 r 2 3 0 3 1 v 0 5 7 2 2 2 m 2 9 2 4 4 0 w 1 2 1 g 1 i 8 2 2 2 14 3 0 h 0 6 2 9 2 p 5 6 h 4 n 2 8 2 0 3 6 1n 1b 2 1 d 6 1n 1 2 0 2 4 2 n 2 0 2 9 2 1 a 0 3 4 2 0 m 3 x 0 1s 7 2 z s 4 38 16 l 0 h 5 5 3 4 0 4 1 8 2 5 c d 0 i 11 2 0 6 0 3 16 2 98 2 3 3 6 2 0 2 3 3 14 2 3 3 w 2 3 3 6 2 0 2 3 3 e 2 1k 2 3 3 1u 12 f h 2d 3 5 4 h7 3 g 2 p 6 22 4 a 8 h e i f h f c 2 2 g 1f 10 0 5 0 1w 2g 8 14 2 0 6 1x b u 1e t 3 4 c 17 5 p 1j m a 1g 2b 0 2m 1a i 7 1j t e 1 b 17 r z 16 2 b z 3 a 6 16 3 2 16 3 2 5 2 1 4 0 6 5b 1t 7p 3 5 3 11 3 5 3 7 2 0 2 0 2 0 2 u 3 1g 2 6 2 0 4 2 2 6 4 3 3 5 5 c 6 2 2 6 39 0 e 0 h c 2u 0 5 0 3 9 2 0 3 5 7 0 2 0 2 0 2 f 3 3 6 4 5 0 i 14 22g 6c 7 3 4 1 d 11 2 0 6 0 3 1j 8 0 h m a 6 2 6 2 6 2 6 2 6 2 6 2 6 2 6 fb 2 q 8 8 4 3 4 5 2d 5 4 2 2h 2 3 6 16 2 2l i v 1d f e9 533 1t h3g 1w 19 3 7g 4 f b 1 l 1a h u 3 27 14 8 3 2u 3 1u 3 1 2 0 2 7 m f 2 2 2 3 2 m u 1f f 1d 1r 5 4 0 2 1 c r b m q s 8 1a t 0 h 4 2 9 b 4 2 14 o 2 2 7 l m 4 0 4 1d 2 0 4 1 3 4 3 0 2 0 p 2 3 a 8 2 d 5 3 5 3 5 a 6 2 6 2 16 2 d 7 36 u 8mb d m 5 1c 6it a5 3 2x 13 6 d 4 6 0 2 9 2 c 2 4 2 0 2 1 2 1 2 2z y a2 j 1r 3 1h 15 b 39 4 2 3q 11 p 7 p c 2g 4 5 3 5 3 5 3 2 10 b 2 p 2 i 2 1 2 e 3 d z 3e 1y 1g 7g s 4 1c 1c v e t 6 11 b t 3 z 5 7 2 4 17 4d j z 5 z 5 13 9 1f d a 2 e 2 6 2 1 2 a 2 e 2 6 2 1 4 1f d 8m a l b 7 p 5 2 15 2 8 1y 5 3 0 2 17 2 1 4 0 3 m b m a u 1u i 2 1 b l b p 1z 1j 7 1 1t 0 g 3 2 2 2 s 17 s 4 s 10 7 2 r s 1h b l b i e h 33 20 1k 1e e 1e e z 13 r a m 6z 15 7 1 h 2 1o s b 0 9 l 17 h 1b k s m d 1g 1m 1 3 0 e 18 x o r z u 0 3 0 9 y 4 0 d 1b f 3 m 0 2 0 10 h 2 o k 1 1s 6 2 0 2 3 2 e 2 9 8 1a 13 7 3 1 3 l 2 6 2 1 2 4 4 0 j 0 d 4 v 9 2 0 3 0 2 11 2 0 q 0 2 0 19 1g j 3 l 2 v 1b l 1 2 0 55 1a 16 3 11 1b l 0 1o 16 e 0 20 q 12 6 56 17 39 1r w 7 3 0 3 7 2 1 2 n g 0 2 0 2n 7 3 12 h 0 2 0 t 0 b 13 8 0 m 0 c 19 k 0 j 20 5k w w 8 2 10 i 0 1e t 35 6 2 1 2 11 m 0 q 5 2 1 2 v f 0 94 i g 0 2 c 2 x 3h 0 28 pl 2v 32 i 5f 219 2o g tr i 5 q 32y 6 g6 5a2 t 1cz fs 8 u i 26 i t j 1b h 3 w k 6 i c1 18 5w 1r 3l 22 6 0 1v c 1t 1 2 0 t 4qf 9 yd 16 9 6w8 3 2 6 2 1 2 82 g 0 u 2 3 0 f 3 9 az 1s5 2y 6 c 4 8 8 9 4mf 2c 2 1y 2 1 3 0 3 1 3 3 2 b 2 0 2 6 2 1s 2 3 3 7 2 6 2 r 2 3 2 4 2 0 4 6 2 9f 3 o 2 o 2 u 2 o 2 u 2 o 2 u 2 o 2 u 2 o 2 7 1f9 u 7 5 7a 1p 43 18 b 6 h 0 8y t j 17 dh r 6d t 3 0 ds 6 2 3 2 1 2 e 2 5g 1o 1v 8 0 xh 3 2 q 2 1 2 0 3 0 2 9 2 3 2 0 2 0 7 0 5 0 2 0 2 0 2 2 2 1 2 0 3 0 2 0 2 0 2 0 2 0 2 1 2 0 3 3 2 6 2 3 2 3 2 0 2 9 2 g 6 2 2 4 2 g 3et wyn x 37d 7 65 3 4g1 f 5rk g h9 1wj f1 15v 3t6 6 38f");
45}
46function initLargeIdContinueRanges() {
47 return restoreRanges("53 0 g9 33 o 0 70 4 7e 18 2 0 2 1 2 1 2 0 21 a 1d u 7 0 2u 6 3 5 3 1 2 3 3 9 o 0 v q 2k a g 9 y 8 a 0 p 3 2 8 2 2 2 4 18 2 1o 8 17 n 2 w 1j 2 2 h 2 6 b 1 3 9 i 2 1l 0 2 6 3 1 3 2 a 0 b 1 3 9 f 0 3 2 1l 0 2 4 5 1 3 2 4 0 l b 4 0 c 2 1l 0 2 7 2 2 2 2 l 1 3 9 b 5 2 2 1l 0 2 6 3 1 3 2 8 2 b 1 3 9 j 0 1o 4 4 2 2 3 a 0 f 9 h 4 1k 0 2 6 2 2 2 3 8 1 c 1 3 9 i 2 1l 0 2 6 2 2 2 3 8 1 c 1 3 9 4 0 d 3 1k 1 2 6 2 2 2 3 a 0 b 1 3 9 i 2 1z 0 5 5 2 0 2 7 7 9 3 1 1q 0 3 6 d 7 2 9 2g 0 3 8 c 6 2 9 1r 1 7 9 c 0 2 0 2 0 5 1 1e j 2 1 6 a 2 z a 0 2t j 2 9 d 3 5 2 2 2 3 6 4 3 e b 2 e jk 2 a 8 pt 3 t 2 u 1 v 1 1t v a 0 3 9 y 2 2 a 40 0 3b b 5 b b 9 3l a 1p 4 1m 9 2 s 3 a 7 9 n d 2 f 1e 4 1c g c 9 i 8 d 2 v c 3 9 19 d 1d j 9 9 7 9 3b 2 2 k 5 0 7 0 3 2 5j 1r el 1 1e 1 k 0 3g c 5 0 4 b 2db 2 3y 0 2p v ff 5 2y 1 2p 0 n51 9 1y 0 5 9 x 1 29 1 7l 0 4 0 5 0 o 4 5 0 2c 1 1f h b 9 7 h e a t 7 q c 19 3 1c d g 9 c 0 b 9 1c d d 0 9 1 3 9 y 2 1f 0 2 2 3 1 6 1 2 0 16 4 6 1 6l 7 2 1 3 9 fmt 0 ki f h f 4 1 p 2 5d 9 12 0 12 0 ig 0 6b 0 46 4 86 9 120 2 2 1 6 3 15 2 5 0 4m 1 fy 3 9 9 7 9 w 4 8u 1 28 3 1z a 1e 3 3f 2 1i e w a 3 1 b 3 1a a 8 0 1a 9 7 2 11 d 2 9 6 1 19 0 d 2 1d d 9 3 2 b 2b b 7 0 3 0 4e b 6 9 7 3 1k 1 2 6 3 1 3 2 a 0 b 1 3 6 4 4 1w 8 2 0 3 0 2 3 2 4 2 0 f 1 2b h a 9 5 0 2a j d 9 5y 6 3 8 s 1 2b g g 9 2a c 9 9 7 j 1m e 5 9 6r e 4m 9 1z 5 2 1 3 3 2 0 2 1 d 9 3c 6 3 6 4 0 t 9 15 6 2 3 9 0 a a 1b f 9j 9 1i 7 2 7 h 9 1l l 2 d 3f 5 4 0 2 1 2 6 2 0 9 9 1d 4 2 1 2 4 9 9 96 3 a 1 2 0 1d 6 4 4 e a 44m 0 7 e 8uh r 1t3 9 2f 9 13 4 1o 6 q 9 ev 9 d2 0 2 1i 8 3 2a 0 c 1 f58 1 382 9 ef 19 3 m f3 4 4 5 9 7 3 6 v 3 45 2 13e 1d e9 1i 5 1d 9 0 f 0 n 4 2 e 11t 6 2 g 3 6 2 1 2 4 2t 0 4h 6 a 9 9x 0 1q d dv d 6t 1 2 9 k6 6 32 6 6 9 3o7 9 gvt3 6n");
48}
49function isInRange(cp, ranges) {
50 let l = 0, r = (ranges.length / 2) | 0, i = 0, min = 0, max = 0;
51 while (l < r) {
52 i = ((l + r) / 2) | 0;
53 min = ranges[2 * i];
54 max = ranges[2 * i + 1];
55 if (cp < min) {
56 r = i;
57 }
58 else if (cp > max) {
59 l = i + 1;
60 }
61 else {
62 return true;
63 }
64 }
65 return false;
66}
67function restoreRanges(data) {
68 let last = 0;
69 return data.split(" ").map((s) => (last += parseInt(s, 36) | 0));
70}
71
72class DataSet {
73 constructor(raw2018, raw2019, raw2020, raw2021, raw2022, raw2023, raw2024, raw2025) {
74 this._raw2018 = raw2018;
75 this._raw2019 = raw2019;
76 this._raw2020 = raw2020;
77 this._raw2021 = raw2021;
78 this._raw2022 = raw2022;
79 this._raw2023 = raw2023;
80 this._raw2024 = raw2024;
81 this._raw2025 = raw2025;
82 }
83 get es2018() {
84 var _a;
85 return ((_a = this._set2018) !== null && _a !== void 0 ? _a : (this._set2018 = new Set(this._raw2018.split(" "))));
86 }
87 get es2019() {
88 var _a;
89 return ((_a = this._set2019) !== null && _a !== void 0 ? _a : (this._set2019 = new Set(this._raw2019.split(" "))));
90 }
91 get es2020() {
92 var _a;
93 return ((_a = this._set2020) !== null && _a !== void 0 ? _a : (this._set2020 = new Set(this._raw2020.split(" "))));
94 }
95 get es2021() {
96 var _a;
97 return ((_a = this._set2021) !== null && _a !== void 0 ? _a : (this._set2021 = new Set(this._raw2021.split(" "))));
98 }
99 get es2022() {
100 var _a;
101 return ((_a = this._set2022) !== null && _a !== void 0 ? _a : (this._set2022 = new Set(this._raw2022.split(" "))));
102 }
103 get es2023() {
104 var _a;
105 return ((_a = this._set2023) !== null && _a !== void 0 ? _a : (this._set2023 = new Set(this._raw2023.split(" "))));
106 }
107 get es2024() {
108 var _a;
109 return ((_a = this._set2024) !== null && _a !== void 0 ? _a : (this._set2024 = new Set(this._raw2024.split(" "))));
110 }
111 get es2025() {
112 var _a;
113 return ((_a = this._set2025) !== null && _a !== void 0 ? _a : (this._set2025 = new Set(this._raw2025.split(" "))));
114 }
115}
116const gcNameSet = new Set(["General_Category", "gc"]);
117const scNameSet = new Set(["Script", "Script_Extensions", "sc", "scx"]);
118const gcValueSets = new DataSet("C Cased_Letter Cc Cf Close_Punctuation Cn Co Combining_Mark Connector_Punctuation Control Cs Currency_Symbol Dash_Punctuation Decimal_Number Enclosing_Mark Final_Punctuation Format Initial_Punctuation L LC Letter Letter_Number Line_Separator Ll Lm Lo Lowercase_Letter Lt Lu M Mark Math_Symbol Mc Me Mn Modifier_Letter Modifier_Symbol N Nd Nl No Nonspacing_Mark Number Open_Punctuation Other Other_Letter Other_Number Other_Punctuation Other_Symbol P Paragraph_Separator Pc Pd Pe Pf Pi Po Private_Use Ps Punctuation S Sc Separator Sk Sm So Space_Separator Spacing_Mark Surrogate Symbol Titlecase_Letter Unassigned Uppercase_Letter Z Zl Zp Zs cntrl digit punct", "", "", "", "", "", "", "");
119const scValueSets = new DataSet("Adlam Adlm Aghb Ahom Anatolian_Hieroglyphs Arab Arabic Armenian Armi Armn Avestan Avst Bali Balinese Bamu Bamum Bass Bassa_Vah Batak Batk Beng Bengali Bhaiksuki Bhks Bopo Bopomofo Brah Brahmi Brai Braille Bugi Buginese Buhd Buhid Cakm Canadian_Aboriginal Cans Cari Carian Caucasian_Albanian Chakma Cham Cher Cherokee Common Copt Coptic Cprt Cuneiform Cypriot Cyrillic Cyrl Deseret Deva Devanagari Dsrt Dupl Duployan Egyp Egyptian_Hieroglyphs Elba Elbasan Ethi Ethiopic Geor Georgian Glag Glagolitic Gonm Goth Gothic Gran Grantha Greek Grek Gujarati Gujr Gurmukhi Guru Han Hang Hangul Hani Hano Hanunoo Hatr Hatran Hebr Hebrew Hira Hiragana Hluw Hmng Hung Imperial_Aramaic Inherited Inscriptional_Pahlavi Inscriptional_Parthian Ital Java Javanese Kaithi Kali Kana Kannada Katakana Kayah_Li Khar Kharoshthi Khmer Khmr Khoj Khojki Khudawadi Knda Kthi Lana Lao Laoo Latin Latn Lepc Lepcha Limb Limbu Lina Linb Linear_A Linear_B Lisu Lyci Lycian Lydi Lydian Mahajani Mahj Malayalam Mand Mandaic Mani Manichaean Marc Marchen Masaram_Gondi Meetei_Mayek Mend Mende_Kikakui Merc Mero Meroitic_Cursive Meroitic_Hieroglyphs Miao Mlym Modi Mong Mongolian Mro Mroo Mtei Mult Multani Myanmar Mymr Nabataean Narb Nbat New_Tai_Lue Newa Nko Nkoo Nshu Nushu Ogam Ogham Ol_Chiki Olck Old_Hungarian Old_Italic Old_North_Arabian Old_Permic Old_Persian Old_South_Arabian Old_Turkic Oriya Orkh Orya Osage Osge Osma Osmanya Pahawh_Hmong Palm Palmyrene Pau_Cin_Hau Pauc Perm Phag Phags_Pa Phli Phlp Phnx Phoenician Plrd Prti Psalter_Pahlavi Qaac Qaai Rejang Rjng Runic Runr Samaritan Samr Sarb Saur Saurashtra Sgnw Sharada Shavian Shaw Shrd Sidd Siddham SignWriting Sind Sinh Sinhala Sora Sora_Sompeng Soyo Soyombo Sund Sundanese Sylo Syloti_Nagri Syrc Syriac Tagalog Tagb Tagbanwa Tai_Le Tai_Tham Tai_Viet Takr Takri Tale Talu Tamil Taml Tang Tangut Tavt Telu Telugu Tfng Tglg Thaa Thaana Thai Tibetan Tibt Tifinagh Tirh Tirhuta Ugar Ugaritic Vai Vaii Wara Warang_Citi Xpeo Xsux Yi Yiii Zanabazar_Square Zanb Zinh Zyyy", "Dogr Dogra Gong Gunjala_Gondi Hanifi_Rohingya Maka Makasar Medefaidrin Medf Old_Sogdian Rohg Sogd Sogdian Sogo", "Elym Elymaic Hmnp Nand Nandinagari Nyiakeng_Puachue_Hmong Wancho Wcho", "Chorasmian Chrs Diak Dives_Akuru Khitan_Small_Script Kits Yezi Yezidi", "Cpmn Cypro_Minoan Old_Uyghur Ougr Tangsa Tnsa Toto Vith Vithkuqi", "Gara Garay Gukh Gurung_Khema Hrkt Katakana_Or_Hiragana Kawi Kirat_Rai Krai Nag_Mundari Nagm Ol_Onal Onao Sunu Sunuwar Todhri Todr Tulu_Tigalari Tutg Unknown Zzzz", "", "");
120const binPropertySets = new DataSet("AHex ASCII ASCII_Hex_Digit Alpha Alphabetic Any Assigned Bidi_C Bidi_Control Bidi_M Bidi_Mirrored CI CWCF CWCM CWKCF CWL CWT CWU Case_Ignorable Cased Changes_When_Casefolded Changes_When_Casemapped Changes_When_Lowercased Changes_When_NFKC_Casefolded Changes_When_Titlecased Changes_When_Uppercased DI Dash Default_Ignorable_Code_Point Dep Deprecated Dia Diacritic Emoji Emoji_Component Emoji_Modifier Emoji_Modifier_Base Emoji_Presentation Ext Extender Gr_Base Gr_Ext Grapheme_Base Grapheme_Extend Hex Hex_Digit IDC IDS IDSB IDST IDS_Binary_Operator IDS_Trinary_Operator ID_Continue ID_Start Ideo Ideographic Join_C Join_Control LOE Logical_Order_Exception Lower Lowercase Math NChar Noncharacter_Code_Point Pat_Syn Pat_WS Pattern_Syntax Pattern_White_Space QMark Quotation_Mark RI Radical Regional_Indicator SD STerm Sentence_Terminal Soft_Dotted Term Terminal_Punctuation UIdeo Unified_Ideograph Upper Uppercase VS Variation_Selector White_Space XIDC XIDS XID_Continue XID_Start space", "Extended_Pictographic", "", "EBase EComp EMod EPres ExtPict", "", "", "", "");
121const binPropertyOfStringsSets = new DataSet("", "", "", "", "", "", "Basic_Emoji Emoji_Keycap_Sequence RGI_Emoji RGI_Emoji_Flag_Sequence RGI_Emoji_Modifier_Sequence RGI_Emoji_Tag_Sequence RGI_Emoji_ZWJ_Sequence", "");
122function isValidUnicodeProperty(version, name, value) {
123 if (gcNameSet.has(name)) {
124 return version >= 2018 && gcValueSets.es2018.has(value);
125 }
126 if (scNameSet.has(name)) {
127 return ((version >= 2018 && scValueSets.es2018.has(value)) ||
128 (version >= 2019 && scValueSets.es2019.has(value)) ||
129 (version >= 2020 && scValueSets.es2020.has(value)) ||
130 (version >= 2021 && scValueSets.es2021.has(value)) ||
131 (version >= 2022 && scValueSets.es2022.has(value)) ||
132 (version >= 2023 && scValueSets.es2023.has(value)));
133 }
134 return false;
135}
136function isValidLoneUnicodeProperty(version, value) {
137 return ((version >= 2018 && binPropertySets.es2018.has(value)) ||
138 (version >= 2019 && binPropertySets.es2019.has(value)) ||
139 (version >= 2021 && binPropertySets.es2021.has(value)));
140}
141function isValidLoneUnicodePropertyOfString(version, value) {
142 return version >= 2024 && binPropertyOfStringsSets.es2024.has(value);
143}
144
145const BACKSPACE = 0x08;
146const CHARACTER_TABULATION = 0x09;
147const LINE_FEED = 0x0a;
148const LINE_TABULATION = 0x0b;
149const FORM_FEED = 0x0c;
150const CARRIAGE_RETURN = 0x0d;
151const EXCLAMATION_MARK = 0x21;
152const NUMBER_SIGN = 0x23;
153const DOLLAR_SIGN = 0x24;
154const PERCENT_SIGN = 0x25;
155const AMPERSAND = 0x26;
156const LEFT_PARENTHESIS = 0x28;
157const RIGHT_PARENTHESIS = 0x29;
158const ASTERISK = 0x2a;
159const PLUS_SIGN = 0x2b;
160const COMMA = 0x2c;
161const HYPHEN_MINUS = 0x2d;
162const FULL_STOP = 0x2e;
163const SOLIDUS = 0x2f;
164const DIGIT_ZERO = 0x30;
165const DIGIT_ONE = 0x31;
166const DIGIT_SEVEN = 0x37;
167const DIGIT_NINE = 0x39;
168const COLON = 0x3a;
169const SEMICOLON = 0x3b;
170const LESS_THAN_SIGN = 0x3c;
171const EQUALS_SIGN = 0x3d;
172const GREATER_THAN_SIGN = 0x3e;
173const QUESTION_MARK = 0x3f;
174const COMMERCIAL_AT = 0x40;
175const LATIN_CAPITAL_LETTER_A = 0x41;
176const LATIN_CAPITAL_LETTER_B = 0x42;
177const LATIN_CAPITAL_LETTER_D = 0x44;
178const LATIN_CAPITAL_LETTER_F = 0x46;
179const LATIN_CAPITAL_LETTER_P = 0x50;
180const LATIN_CAPITAL_LETTER_S = 0x53;
181const LATIN_CAPITAL_LETTER_W = 0x57;
182const LATIN_CAPITAL_LETTER_Z = 0x5a;
183const LOW_LINE = 0x5f;
184const LATIN_SMALL_LETTER_A = 0x61;
185const LATIN_SMALL_LETTER_B = 0x62;
186const LATIN_SMALL_LETTER_C = 0x63;
187const LATIN_SMALL_LETTER_D = 0x64;
188const LATIN_SMALL_LETTER_F = 0x66;
189const LATIN_SMALL_LETTER_G = 0x67;
190const LATIN_SMALL_LETTER_I = 0x69;
191const LATIN_SMALL_LETTER_K = 0x6b;
192const LATIN_SMALL_LETTER_M = 0x6d;
193const LATIN_SMALL_LETTER_N = 0x6e;
194const LATIN_SMALL_LETTER_P = 0x70;
195const LATIN_SMALL_LETTER_Q = 0x71;
196const LATIN_SMALL_LETTER_R = 0x72;
197const LATIN_SMALL_LETTER_S = 0x73;
198const LATIN_SMALL_LETTER_T = 0x74;
199const LATIN_SMALL_LETTER_U = 0x75;
200const LATIN_SMALL_LETTER_V = 0x76;
201const LATIN_SMALL_LETTER_W = 0x77;
202const LATIN_SMALL_LETTER_X = 0x78;
203const LATIN_SMALL_LETTER_Y = 0x79;
204const LATIN_SMALL_LETTER_Z = 0x7a;
205const LEFT_SQUARE_BRACKET = 0x5b;
206const REVERSE_SOLIDUS = 0x5c;
207const RIGHT_SQUARE_BRACKET = 0x5d;
208const CIRCUMFLEX_ACCENT = 0x5e;
209const GRAVE_ACCENT = 0x60;
210const LEFT_CURLY_BRACKET = 0x7b;
211const VERTICAL_LINE = 0x7c;
212const RIGHT_CURLY_BRACKET = 0x7d;
213const TILDE = 0x7e;
214const ZERO_WIDTH_NON_JOINER = 0x200c;
215const ZERO_WIDTH_JOINER = 0x200d;
216const LINE_SEPARATOR = 0x2028;
217const PARAGRAPH_SEPARATOR = 0x2029;
218const MIN_CODE_POINT = 0x00;
219const MAX_CODE_POINT = 0x10ffff;
220function isLatinLetter(code) {
221 return ((code >= LATIN_CAPITAL_LETTER_A && code <= LATIN_CAPITAL_LETTER_Z) ||
222 (code >= LATIN_SMALL_LETTER_A && code <= LATIN_SMALL_LETTER_Z));
223}
224function isDecimalDigit(code) {
225 return code >= DIGIT_ZERO && code <= DIGIT_NINE;
226}
227function isOctalDigit(code) {
228 return code >= DIGIT_ZERO && code <= DIGIT_SEVEN;
229}
230function isHexDigit(code) {
231 return ((code >= DIGIT_ZERO && code <= DIGIT_NINE) ||
232 (code >= LATIN_CAPITAL_LETTER_A && code <= LATIN_CAPITAL_LETTER_F) ||
233 (code >= LATIN_SMALL_LETTER_A && code <= LATIN_SMALL_LETTER_F));
234}
235function isLineTerminator(code) {
236 return (code === LINE_FEED ||
237 code === CARRIAGE_RETURN ||
238 code === LINE_SEPARATOR ||
239 code === PARAGRAPH_SEPARATOR);
240}
241function isValidUnicode(code) {
242 return code >= MIN_CODE_POINT && code <= MAX_CODE_POINT;
243}
244function digitToInt(code) {
245 if (code >= LATIN_SMALL_LETTER_A && code <= LATIN_SMALL_LETTER_F) {
246 return code - LATIN_SMALL_LETTER_A + 10;
247 }
248 if (code >= LATIN_CAPITAL_LETTER_A && code <= LATIN_CAPITAL_LETTER_F) {
249 return code - LATIN_CAPITAL_LETTER_A + 10;
250 }
251 return code - DIGIT_ZERO;
252}
253function isLeadSurrogate(code) {
254 return code >= 0xd800 && code <= 0xdbff;
255}
256function isTrailSurrogate(code) {
257 return code >= 0xdc00 && code <= 0xdfff;
258}
259function combineSurrogatePair(lead, trail) {
260 return (lead - 0xd800) * 0x400 + (trail - 0xdc00) + 0x10000;
261}
262
263class GroupSpecifiersAsES2018 {
264 constructor() {
265 this.groupName = new Set();
266 }
267 clear() {
268 this.groupName.clear();
269 }
270 isEmpty() {
271 return !this.groupName.size;
272 }
273 hasInPattern(name) {
274 return this.groupName.has(name);
275 }
276 hasInScope(name) {
277 return this.hasInPattern(name);
278 }
279 addToScope(name) {
280 this.groupName.add(name);
281 }
282 enterDisjunction() {
283 }
284 enterAlternative() {
285 }
286 leaveDisjunction() {
287 }
288}
289class BranchID {
290 constructor(parent, base) {
291 this.parent = parent;
292 this.base = base !== null && base !== void 0 ? base : this;
293 }
294 separatedFrom(other) {
295 var _a, _b;
296 if (this.base === other.base && this !== other) {
297 return true;
298 }
299 if (other.parent && this.separatedFrom(other.parent)) {
300 return true;
301 }
302 return (_b = (_a = this.parent) === null || _a === void 0 ? void 0 : _a.separatedFrom(other)) !== null && _b !== void 0 ? _b : false;
303 }
304 child() {
305 return new BranchID(this, null);
306 }
307 sibling() {
308 return new BranchID(this.parent, this.base);
309 }
310}
311class GroupSpecifiersAsES2025 {
312 constructor() {
313 this.branchID = new BranchID(null, null);
314 this.groupNames = new Map();
315 }
316 clear() {
317 this.branchID = new BranchID(null, null);
318 this.groupNames.clear();
319 }
320 isEmpty() {
321 return !this.groupNames.size;
322 }
323 enterDisjunction() {
324 this.branchID = this.branchID.child();
325 }
326 enterAlternative(index) {
327 if (index === 0) {
328 return;
329 }
330 this.branchID = this.branchID.sibling();
331 }
332 leaveDisjunction() {
333 this.branchID = this.branchID.parent;
334 }
335 hasInPattern(name) {
336 return this.groupNames.has(name);
337 }
338 hasInScope(name) {
339 const branches = this.groupNames.get(name);
340 if (!branches) {
341 return false;
342 }
343 for (const branch of branches) {
344 if (!branch.separatedFrom(this.branchID)) {
345 return true;
346 }
347 }
348 return false;
349 }
350 addToScope(name) {
351 const branches = this.groupNames.get(name);
352 if (branches) {
353 branches.push(this.branchID);
354 return;
355 }
356 this.groupNames.set(name, [this.branchID]);
357 }
358}
359
360const legacyImpl = {
361 at(s, end, i) {
362 return i < end ? s.charCodeAt(i) : -1;
363 },
364 width(c) {
365 return 1;
366 },
367};
368const unicodeImpl = {
369 at(s, end, i) {
370 return i < end ? s.codePointAt(i) : -1;
371 },
372 width(c) {
373 return c > 0xffff ? 2 : 1;
374 },
375};
376class Reader {
377 constructor() {
378 this._impl = legacyImpl;
379 this._s = "";
380 this._i = 0;
381 this._end = 0;
382 this._cp1 = -1;
383 this._w1 = 1;
384 this._cp2 = -1;
385 this._w2 = 1;
386 this._cp3 = -1;
387 this._w3 = 1;
388 this._cp4 = -1;
389 }
390 get source() {
391 return this._s;
392 }
393 get index() {
394 return this._i;
395 }
396 get currentCodePoint() {
397 return this._cp1;
398 }
399 get nextCodePoint() {
400 return this._cp2;
401 }
402 get nextCodePoint2() {
403 return this._cp3;
404 }
405 get nextCodePoint3() {
406 return this._cp4;
407 }
408 reset(source, start, end, uFlag) {
409 this._impl = uFlag ? unicodeImpl : legacyImpl;
410 this._s = source;
411 this._end = end;
412 this.rewind(start);
413 }
414 rewind(index) {
415 const impl = this._impl;
416 this._i = index;
417 this._cp1 = impl.at(this._s, this._end, index);
418 this._w1 = impl.width(this._cp1);
419 this._cp2 = impl.at(this._s, this._end, index + this._w1);
420 this._w2 = impl.width(this._cp2);
421 this._cp3 = impl.at(this._s, this._end, index + this._w1 + this._w2);
422 this._w3 = impl.width(this._cp3);
423 this._cp4 = impl.at(this._s, this._end, index + this._w1 + this._w2 + this._w3);
424 }
425 advance() {
426 if (this._cp1 !== -1) {
427 const impl = this._impl;
428 this._i += this._w1;
429 this._cp1 = this._cp2;
430 this._w1 = this._w2;
431 this._cp2 = this._cp3;
432 this._w2 = impl.width(this._cp2);
433 this._cp3 = this._cp4;
434 this._w3 = impl.width(this._cp3);
435 this._cp4 = impl.at(this._s, this._end, this._i + this._w1 + this._w2 + this._w3);
436 }
437 }
438 eat(cp) {
439 if (this._cp1 === cp) {
440 this.advance();
441 return true;
442 }
443 return false;
444 }
445 eat2(cp1, cp2) {
446 if (this._cp1 === cp1 && this._cp2 === cp2) {
447 this.advance();
448 this.advance();
449 return true;
450 }
451 return false;
452 }
453 eat3(cp1, cp2, cp3) {
454 if (this._cp1 === cp1 && this._cp2 === cp2 && this._cp3 === cp3) {
455 this.advance();
456 this.advance();
457 this.advance();
458 return true;
459 }
460 return false;
461 }
462}
463
464class RegExpSyntaxError extends SyntaxError {
465 constructor(message, index) {
466 super(message);
467 this.index = index;
468 }
469}
470function newRegExpSyntaxError(srcCtx, flags, index, message) {
471 let source = "";
472 if (srcCtx.kind === "literal") {
473 const literal = srcCtx.source.slice(srcCtx.start, srcCtx.end);
474 if (literal) {
475 source = `: ${literal}`;
476 }
477 }
478 else if (srcCtx.kind === "pattern") {
479 const pattern = srcCtx.source.slice(srcCtx.start, srcCtx.end);
480 const flagsText = `${flags.unicode ? "u" : ""}${flags.unicodeSets ? "v" : ""}`;
481 source = `: /${pattern}/${flagsText}`;
482 }
483 return new RegExpSyntaxError(`Invalid regular expression${source}: ${message}`, index);
484}
485
486const SYNTAX_CHARACTER = new Set([
487 CIRCUMFLEX_ACCENT,
488 DOLLAR_SIGN,
489 REVERSE_SOLIDUS,
490 FULL_STOP,
491 ASTERISK,
492 PLUS_SIGN,
493 QUESTION_MARK,
494 LEFT_PARENTHESIS,
495 RIGHT_PARENTHESIS,
496 LEFT_SQUARE_BRACKET,
497 RIGHT_SQUARE_BRACKET,
498 LEFT_CURLY_BRACKET,
499 RIGHT_CURLY_BRACKET,
500 VERTICAL_LINE,
501]);
502const CLASS_SET_RESERVED_DOUBLE_PUNCTUATOR_CHARACTER = new Set([
503 AMPERSAND,
504 EXCLAMATION_MARK,
505 NUMBER_SIGN,
506 DOLLAR_SIGN,
507 PERCENT_SIGN,
508 ASTERISK,
509 PLUS_SIGN,
510 COMMA,
511 FULL_STOP,
512 COLON,
513 SEMICOLON,
514 LESS_THAN_SIGN,
515 EQUALS_SIGN,
516 GREATER_THAN_SIGN,
517 QUESTION_MARK,
518 COMMERCIAL_AT,
519 CIRCUMFLEX_ACCENT,
520 GRAVE_ACCENT,
521 TILDE,
522]);
523const CLASS_SET_SYNTAX_CHARACTER = new Set([
524 LEFT_PARENTHESIS,
525 RIGHT_PARENTHESIS,
526 LEFT_SQUARE_BRACKET,
527 RIGHT_SQUARE_BRACKET,
528 LEFT_CURLY_BRACKET,
529 RIGHT_CURLY_BRACKET,
530 SOLIDUS,
531 HYPHEN_MINUS,
532 REVERSE_SOLIDUS,
533 VERTICAL_LINE,
534]);
535const CLASS_SET_RESERVED_PUNCTUATOR = new Set([
536 AMPERSAND,
537 HYPHEN_MINUS,
538 EXCLAMATION_MARK,
539 NUMBER_SIGN,
540 PERCENT_SIGN,
541 COMMA,
542 COLON,
543 SEMICOLON,
544 LESS_THAN_SIGN,
545 EQUALS_SIGN,
546 GREATER_THAN_SIGN,
547 COMMERCIAL_AT,
548 GRAVE_ACCENT,
549 TILDE,
550]);
551const FLAG_PROP_TO_CODEPOINT = {
552 global: LATIN_SMALL_LETTER_G,
553 ignoreCase: LATIN_SMALL_LETTER_I,
554 multiline: LATIN_SMALL_LETTER_M,
555 unicode: LATIN_SMALL_LETTER_U,
556 sticky: LATIN_SMALL_LETTER_Y,
557 dotAll: LATIN_SMALL_LETTER_S,
558 hasIndices: LATIN_SMALL_LETTER_D,
559 unicodeSets: LATIN_SMALL_LETTER_V,
560};
561const FLAG_CODEPOINT_TO_PROP = Object.fromEntries(Object.entries(FLAG_PROP_TO_CODEPOINT).map(([k, v]) => [v, k]));
562function isSyntaxCharacter(cp) {
563 return SYNTAX_CHARACTER.has(cp);
564}
565function isClassSetReservedDoublePunctuatorCharacter(cp) {
566 return CLASS_SET_RESERVED_DOUBLE_PUNCTUATOR_CHARACTER.has(cp);
567}
568function isClassSetSyntaxCharacter(cp) {
569 return CLASS_SET_SYNTAX_CHARACTER.has(cp);
570}
571function isClassSetReservedPunctuator(cp) {
572 return CLASS_SET_RESERVED_PUNCTUATOR.has(cp);
573}
574function isIdentifierStartChar(cp) {
575 return isIdStart(cp) || cp === DOLLAR_SIGN || cp === LOW_LINE;
576}
577function isIdentifierPartChar(cp) {
578 return (isIdContinue(cp) ||
579 cp === DOLLAR_SIGN ||
580 cp === ZERO_WIDTH_NON_JOINER ||
581 cp === ZERO_WIDTH_JOINER);
582}
583function isUnicodePropertyNameCharacter(cp) {
584 return isLatinLetter(cp) || cp === LOW_LINE;
585}
586function isUnicodePropertyValueCharacter(cp) {
587 return isUnicodePropertyNameCharacter(cp) || isDecimalDigit(cp);
588}
589function isRegularExpressionModifier(ch) {
590 return (ch === LATIN_SMALL_LETTER_I ||
591 ch === LATIN_SMALL_LETTER_M ||
592 ch === LATIN_SMALL_LETTER_S);
593}
594class RegExpValidator {
595 constructor(options) {
596 this._reader = new Reader();
597 this._unicodeMode = false;
598 this._unicodeSetsMode = false;
599 this._nFlag = false;
600 this._lastIntValue = 0;
601 this._lastRange = {
602 min: 0,
603 max: Number.POSITIVE_INFINITY,
604 };
605 this._lastStrValue = "";
606 this._lastAssertionIsQuantifiable = false;
607 this._numCapturingParens = 0;
608 this._backreferenceNames = new Set();
609 this._srcCtx = null;
610 this._options = options !== null && options !== void 0 ? options : {};
611 this._groupSpecifiers =
612 this.ecmaVersion >= 2025
613 ? new GroupSpecifiersAsES2025()
614 : new GroupSpecifiersAsES2018();
615 }
616 validateLiteral(source, start = 0, end = source.length) {
617 this._srcCtx = { source, start, end, kind: "literal" };
618 this._unicodeSetsMode = this._unicodeMode = this._nFlag = false;
619 this.reset(source, start, end);
620 this.onLiteralEnter(start);
621 if (this.eat(SOLIDUS) && this.eatRegExpBody() && this.eat(SOLIDUS)) {
622 const flagStart = this.index;
623 const unicode = source.includes("u", flagStart);
624 const unicodeSets = source.includes("v", flagStart);
625 this.validateFlagsInternal(source, flagStart, end);
626 this.validatePatternInternal(source, start + 1, flagStart - 1, {
627 unicode,
628 unicodeSets,
629 });
630 }
631 else if (start >= end) {
632 this.raise("Empty");
633 }
634 else {
635 const c = String.fromCodePoint(this.currentCodePoint);
636 this.raise(`Unexpected character '${c}'`);
637 }
638 this.onLiteralLeave(start, end);
639 }
640 validateFlags(source, start = 0, end = source.length) {
641 this._srcCtx = { source, start, end, kind: "flags" };
642 this.validateFlagsInternal(source, start, end);
643 }
644 validatePattern(source, start = 0, end = source.length, uFlagOrFlags = undefined) {
645 this._srcCtx = { source, start, end, kind: "pattern" };
646 this.validatePatternInternal(source, start, end, uFlagOrFlags);
647 }
648 validatePatternInternal(source, start = 0, end = source.length, uFlagOrFlags = undefined) {
649 const mode = this._parseFlagsOptionToMode(uFlagOrFlags, end);
650 this._unicodeMode = mode.unicodeMode;
651 this._nFlag = mode.nFlag;
652 this._unicodeSetsMode = mode.unicodeSetsMode;
653 this.reset(source, start, end);
654 this.consumePattern();
655 if (!this._nFlag &&
656 this.ecmaVersion >= 2018 &&
657 !this._groupSpecifiers.isEmpty()) {
658 this._nFlag = true;
659 this.rewind(start);
660 this.consumePattern();
661 }
662 }
663 validateFlagsInternal(source, start, end) {
664 const flags = this.parseFlags(source, start, end);
665 this.onRegExpFlags(start, end, flags);
666 }
667 _parseFlagsOptionToMode(uFlagOrFlags, sourceEnd) {
668 let unicode = false;
669 let unicodeSets = false;
670 if (uFlagOrFlags && this.ecmaVersion >= 2015) {
671 if (typeof uFlagOrFlags === "object") {
672 unicode = Boolean(uFlagOrFlags.unicode);
673 if (this.ecmaVersion >= 2024) {
674 unicodeSets = Boolean(uFlagOrFlags.unicodeSets);
675 }
676 }
677 else {
678 unicode = uFlagOrFlags;
679 }
680 }
681 if (unicode && unicodeSets) {
682 this.raise("Invalid regular expression flags", {
683 index: sourceEnd + 1,
684 unicode,
685 unicodeSets,
686 });
687 }
688 const unicodeMode = unicode || unicodeSets;
689 const nFlag = (unicode && this.ecmaVersion >= 2018) ||
690 unicodeSets ||
691 Boolean(this._options.strict && this.ecmaVersion >= 2023);
692 const unicodeSetsMode = unicodeSets;
693 return { unicodeMode, nFlag, unicodeSetsMode };
694 }
695 get strict() {
696 return Boolean(this._options.strict) || this._unicodeMode;
697 }
698 get ecmaVersion() {
699 var _a;
700 return (_a = this._options.ecmaVersion) !== null && _a !== void 0 ? _a : latestEcmaVersion;
701 }
702 onLiteralEnter(start) {
703 if (this._options.onLiteralEnter) {
704 this._options.onLiteralEnter(start);
705 }
706 }
707 onLiteralLeave(start, end) {
708 if (this._options.onLiteralLeave) {
709 this._options.onLiteralLeave(start, end);
710 }
711 }
712 onRegExpFlags(start, end, flags) {
713 if (this._options.onRegExpFlags) {
714 this._options.onRegExpFlags(start, end, flags);
715 }
716 if (this._options.onFlags) {
717 this._options.onFlags(start, end, flags.global, flags.ignoreCase, flags.multiline, flags.unicode, flags.sticky, flags.dotAll, flags.hasIndices);
718 }
719 }
720 onPatternEnter(start) {
721 if (this._options.onPatternEnter) {
722 this._options.onPatternEnter(start);
723 }
724 }
725 onPatternLeave(start, end) {
726 if (this._options.onPatternLeave) {
727 this._options.onPatternLeave(start, end);
728 }
729 }
730 onDisjunctionEnter(start) {
731 if (this._options.onDisjunctionEnter) {
732 this._options.onDisjunctionEnter(start);
733 }
734 }
735 onDisjunctionLeave(start, end) {
736 if (this._options.onDisjunctionLeave) {
737 this._options.onDisjunctionLeave(start, end);
738 }
739 }
740 onAlternativeEnter(start, index) {
741 if (this._options.onAlternativeEnter) {
742 this._options.onAlternativeEnter(start, index);
743 }
744 }
745 onAlternativeLeave(start, end, index) {
746 if (this._options.onAlternativeLeave) {
747 this._options.onAlternativeLeave(start, end, index);
748 }
749 }
750 onGroupEnter(start) {
751 if (this._options.onGroupEnter) {
752 this._options.onGroupEnter(start);
753 }
754 }
755 onGroupLeave(start, end) {
756 if (this._options.onGroupLeave) {
757 this._options.onGroupLeave(start, end);
758 }
759 }
760 onModifiersEnter(start) {
761 if (this._options.onModifiersEnter) {
762 this._options.onModifiersEnter(start);
763 }
764 }
765 onModifiersLeave(start, end) {
766 if (this._options.onModifiersLeave) {
767 this._options.onModifiersLeave(start, end);
768 }
769 }
770 onAddModifiers(start, end, flags) {
771 if (this._options.onAddModifiers) {
772 this._options.onAddModifiers(start, end, flags);
773 }
774 }
775 onRemoveModifiers(start, end, flags) {
776 if (this._options.onRemoveModifiers) {
777 this._options.onRemoveModifiers(start, end, flags);
778 }
779 }
780 onCapturingGroupEnter(start, name) {
781 if (this._options.onCapturingGroupEnter) {
782 this._options.onCapturingGroupEnter(start, name);
783 }
784 }
785 onCapturingGroupLeave(start, end, name) {
786 if (this._options.onCapturingGroupLeave) {
787 this._options.onCapturingGroupLeave(start, end, name);
788 }
789 }
790 onQuantifier(start, end, min, max, greedy) {
791 if (this._options.onQuantifier) {
792 this._options.onQuantifier(start, end, min, max, greedy);
793 }
794 }
795 onLookaroundAssertionEnter(start, kind, negate) {
796 if (this._options.onLookaroundAssertionEnter) {
797 this._options.onLookaroundAssertionEnter(start, kind, negate);
798 }
799 }
800 onLookaroundAssertionLeave(start, end, kind, negate) {
801 if (this._options.onLookaroundAssertionLeave) {
802 this._options.onLookaroundAssertionLeave(start, end, kind, negate);
803 }
804 }
805 onEdgeAssertion(start, end, kind) {
806 if (this._options.onEdgeAssertion) {
807 this._options.onEdgeAssertion(start, end, kind);
808 }
809 }
810 onWordBoundaryAssertion(start, end, kind, negate) {
811 if (this._options.onWordBoundaryAssertion) {
812 this._options.onWordBoundaryAssertion(start, end, kind, negate);
813 }
814 }
815 onAnyCharacterSet(start, end, kind) {
816 if (this._options.onAnyCharacterSet) {
817 this._options.onAnyCharacterSet(start, end, kind);
818 }
819 }
820 onEscapeCharacterSet(start, end, kind, negate) {
821 if (this._options.onEscapeCharacterSet) {
822 this._options.onEscapeCharacterSet(start, end, kind, negate);
823 }
824 }
825 onUnicodePropertyCharacterSet(start, end, kind, key, value, negate, strings) {
826 if (this._options.onUnicodePropertyCharacterSet) {
827 this._options.onUnicodePropertyCharacterSet(start, end, kind, key, value, negate, strings);
828 }
829 }
830 onCharacter(start, end, value) {
831 if (this._options.onCharacter) {
832 this._options.onCharacter(start, end, value);
833 }
834 }
835 onBackreference(start, end, ref) {
836 if (this._options.onBackreference) {
837 this._options.onBackreference(start, end, ref);
838 }
839 }
840 onCharacterClassEnter(start, negate, unicodeSets) {
841 if (this._options.onCharacterClassEnter) {
842 this._options.onCharacterClassEnter(start, negate, unicodeSets);
843 }
844 }
845 onCharacterClassLeave(start, end, negate) {
846 if (this._options.onCharacterClassLeave) {
847 this._options.onCharacterClassLeave(start, end, negate);
848 }
849 }
850 onCharacterClassRange(start, end, min, max) {
851 if (this._options.onCharacterClassRange) {
852 this._options.onCharacterClassRange(start, end, min, max);
853 }
854 }
855 onClassIntersection(start, end) {
856 if (this._options.onClassIntersection) {
857 this._options.onClassIntersection(start, end);
858 }
859 }
860 onClassSubtraction(start, end) {
861 if (this._options.onClassSubtraction) {
862 this._options.onClassSubtraction(start, end);
863 }
864 }
865 onClassStringDisjunctionEnter(start) {
866 if (this._options.onClassStringDisjunctionEnter) {
867 this._options.onClassStringDisjunctionEnter(start);
868 }
869 }
870 onClassStringDisjunctionLeave(start, end) {
871 if (this._options.onClassStringDisjunctionLeave) {
872 this._options.onClassStringDisjunctionLeave(start, end);
873 }
874 }
875 onStringAlternativeEnter(start, index) {
876 if (this._options.onStringAlternativeEnter) {
877 this._options.onStringAlternativeEnter(start, index);
878 }
879 }
880 onStringAlternativeLeave(start, end, index) {
881 if (this._options.onStringAlternativeLeave) {
882 this._options.onStringAlternativeLeave(start, end, index);
883 }
884 }
885 get index() {
886 return this._reader.index;
887 }
888 get currentCodePoint() {
889 return this._reader.currentCodePoint;
890 }
891 get nextCodePoint() {
892 return this._reader.nextCodePoint;
893 }
894 get nextCodePoint2() {
895 return this._reader.nextCodePoint2;
896 }
897 get nextCodePoint3() {
898 return this._reader.nextCodePoint3;
899 }
900 reset(source, start, end) {
901 this._reader.reset(source, start, end, this._unicodeMode);
902 }
903 rewind(index) {
904 this._reader.rewind(index);
905 }
906 advance() {
907 this._reader.advance();
908 }
909 eat(cp) {
910 return this._reader.eat(cp);
911 }
912 eat2(cp1, cp2) {
913 return this._reader.eat2(cp1, cp2);
914 }
915 eat3(cp1, cp2, cp3) {
916 return this._reader.eat3(cp1, cp2, cp3);
917 }
918 raise(message, context) {
919 var _a, _b, _c;
920 throw newRegExpSyntaxError(this._srcCtx, {
921 unicode: (_a = context === null || context === void 0 ? void 0 : context.unicode) !== null && _a !== void 0 ? _a : (this._unicodeMode && !this._unicodeSetsMode),
922 unicodeSets: (_b = context === null || context === void 0 ? void 0 : context.unicodeSets) !== null && _b !== void 0 ? _b : this._unicodeSetsMode,
923 }, (_c = context === null || context === void 0 ? void 0 : context.index) !== null && _c !== void 0 ? _c : this.index, message);
924 }
925 eatRegExpBody() {
926 const start = this.index;
927 let inClass = false;
928 let escaped = false;
929 for (;;) {
930 const cp = this.currentCodePoint;
931 if (cp === -1 || isLineTerminator(cp)) {
932 const kind = inClass ? "character class" : "regular expression";
933 this.raise(`Unterminated ${kind}`);
934 }
935 if (escaped) {
936 escaped = false;
937 }
938 else if (cp === REVERSE_SOLIDUS) {
939 escaped = true;
940 }
941 else if (cp === LEFT_SQUARE_BRACKET) {
942 inClass = true;
943 }
944 else if (cp === RIGHT_SQUARE_BRACKET) {
945 inClass = false;
946 }
947 else if ((cp === SOLIDUS && !inClass) ||
948 (cp === ASTERISK && this.index === start)) {
949 break;
950 }
951 this.advance();
952 }
953 return this.index !== start;
954 }
955 consumePattern() {
956 const start = this.index;
957 this._numCapturingParens = this.countCapturingParens();
958 this._groupSpecifiers.clear();
959 this._backreferenceNames.clear();
960 this.onPatternEnter(start);
961 this.consumeDisjunction();
962 const cp = this.currentCodePoint;
963 if (this.currentCodePoint !== -1) {
964 if (cp === RIGHT_PARENTHESIS) {
965 this.raise("Unmatched ')'");
966 }
967 if (cp === REVERSE_SOLIDUS) {
968 this.raise("\\ at end of pattern");
969 }
970 if (cp === RIGHT_SQUARE_BRACKET || cp === RIGHT_CURLY_BRACKET) {
971 this.raise("Lone quantifier brackets");
972 }
973 const c = String.fromCodePoint(cp);
974 this.raise(`Unexpected character '${c}'`);
975 }
976 for (const name of this._backreferenceNames) {
977 if (!this._groupSpecifiers.hasInPattern(name)) {
978 this.raise("Invalid named capture referenced");
979 }
980 }
981 this.onPatternLeave(start, this.index);
982 }
983 countCapturingParens() {
984 const start = this.index;
985 let inClass = false;
986 let escaped = false;
987 let count = 0;
988 let cp = 0;
989 while ((cp = this.currentCodePoint) !== -1) {
990 if (escaped) {
991 escaped = false;
992 }
993 else if (cp === REVERSE_SOLIDUS) {
994 escaped = true;
995 }
996 else if (cp === LEFT_SQUARE_BRACKET) {
997 inClass = true;
998 }
999 else if (cp === RIGHT_SQUARE_BRACKET) {
1000 inClass = false;
1001 }
1002 else if (cp === LEFT_PARENTHESIS &&
1003 !inClass &&
1004 (this.nextCodePoint !== QUESTION_MARK ||
1005 (this.nextCodePoint2 === LESS_THAN_SIGN &&
1006 this.nextCodePoint3 !== EQUALS_SIGN &&
1007 this.nextCodePoint3 !== EXCLAMATION_MARK))) {
1008 count += 1;
1009 }
1010 this.advance();
1011 }
1012 this.rewind(start);
1013 return count;
1014 }
1015 consumeDisjunction() {
1016 const start = this.index;
1017 let i = 0;
1018 this._groupSpecifiers.enterDisjunction();
1019 this.onDisjunctionEnter(start);
1020 do {
1021 this.consumeAlternative(i++);
1022 } while (this.eat(VERTICAL_LINE));
1023 if (this.consumeQuantifier(true)) {
1024 this.raise("Nothing to repeat");
1025 }
1026 if (this.eat(LEFT_CURLY_BRACKET)) {
1027 this.raise("Lone quantifier brackets");
1028 }
1029 this.onDisjunctionLeave(start, this.index);
1030 this._groupSpecifiers.leaveDisjunction();
1031 }
1032 consumeAlternative(i) {
1033 const start = this.index;
1034 this._groupSpecifiers.enterAlternative(i);
1035 this.onAlternativeEnter(start, i);
1036 while (this.currentCodePoint !== -1 && this.consumeTerm()) {
1037 }
1038 this.onAlternativeLeave(start, this.index, i);
1039 }
1040 consumeTerm() {
1041 if (this._unicodeMode || this.strict) {
1042 return (this.consumeAssertion() ||
1043 (this.consumeAtom() && this.consumeOptionalQuantifier()));
1044 }
1045 return ((this.consumeAssertion() &&
1046 (!this._lastAssertionIsQuantifiable ||
1047 this.consumeOptionalQuantifier())) ||
1048 (this.consumeExtendedAtom() && this.consumeOptionalQuantifier()));
1049 }
1050 consumeOptionalQuantifier() {
1051 this.consumeQuantifier();
1052 return true;
1053 }
1054 consumeAssertion() {
1055 const start = this.index;
1056 this._lastAssertionIsQuantifiable = false;
1057 if (this.eat(CIRCUMFLEX_ACCENT)) {
1058 this.onEdgeAssertion(start, this.index, "start");
1059 return true;
1060 }
1061 if (this.eat(DOLLAR_SIGN)) {
1062 this.onEdgeAssertion(start, this.index, "end");
1063 return true;
1064 }
1065 if (this.eat2(REVERSE_SOLIDUS, LATIN_CAPITAL_LETTER_B)) {
1066 this.onWordBoundaryAssertion(start, this.index, "word", true);
1067 return true;
1068 }
1069 if (this.eat2(REVERSE_SOLIDUS, LATIN_SMALL_LETTER_B)) {
1070 this.onWordBoundaryAssertion(start, this.index, "word", false);
1071 return true;
1072 }
1073 if (this.eat2(LEFT_PARENTHESIS, QUESTION_MARK)) {
1074 const lookbehind = this.ecmaVersion >= 2018 && this.eat(LESS_THAN_SIGN);
1075 let negate = false;
1076 if (this.eat(EQUALS_SIGN) ||
1077 (negate = this.eat(EXCLAMATION_MARK))) {
1078 const kind = lookbehind ? "lookbehind" : "lookahead";
1079 this.onLookaroundAssertionEnter(start, kind, negate);
1080 this.consumeDisjunction();
1081 if (!this.eat(RIGHT_PARENTHESIS)) {
1082 this.raise("Unterminated group");
1083 }
1084 this._lastAssertionIsQuantifiable = !lookbehind && !this.strict;
1085 this.onLookaroundAssertionLeave(start, this.index, kind, negate);
1086 return true;
1087 }
1088 this.rewind(start);
1089 }
1090 return false;
1091 }
1092 consumeQuantifier(noConsume = false) {
1093 const start = this.index;
1094 let min = 0;
1095 let max = 0;
1096 let greedy = false;
1097 if (this.eat(ASTERISK)) {
1098 min = 0;
1099 max = Number.POSITIVE_INFINITY;
1100 }
1101 else if (this.eat(PLUS_SIGN)) {
1102 min = 1;
1103 max = Number.POSITIVE_INFINITY;
1104 }
1105 else if (this.eat(QUESTION_MARK)) {
1106 min = 0;
1107 max = 1;
1108 }
1109 else if (this.eatBracedQuantifier(noConsume)) {
1110 ({ min, max } = this._lastRange);
1111 }
1112 else {
1113 return false;
1114 }
1115 greedy = !this.eat(QUESTION_MARK);
1116 if (!noConsume) {
1117 this.onQuantifier(start, this.index, min, max, greedy);
1118 }
1119 return true;
1120 }
1121 eatBracedQuantifier(noError) {
1122 const start = this.index;
1123 if (this.eat(LEFT_CURLY_BRACKET)) {
1124 if (this.eatDecimalDigits()) {
1125 const min = this._lastIntValue;
1126 let max = min;
1127 if (this.eat(COMMA)) {
1128 max = this.eatDecimalDigits()
1129 ? this._lastIntValue
1130 : Number.POSITIVE_INFINITY;
1131 }
1132 if (this.eat(RIGHT_CURLY_BRACKET)) {
1133 if (!noError && max < min) {
1134 this.raise("numbers out of order in {} quantifier");
1135 }
1136 this._lastRange = { min, max };
1137 return true;
1138 }
1139 }
1140 if (!noError && (this._unicodeMode || this.strict)) {
1141 this.raise("Incomplete quantifier");
1142 }
1143 this.rewind(start);
1144 }
1145 return false;
1146 }
1147 consumeAtom() {
1148 return (this.consumePatternCharacter() ||
1149 this.consumeDot() ||
1150 this.consumeReverseSolidusAtomEscape() ||
1151 Boolean(this.consumeCharacterClass()) ||
1152 this.consumeCapturingGroup() ||
1153 this.consumeUncapturingGroup());
1154 }
1155 consumeDot() {
1156 if (this.eat(FULL_STOP)) {
1157 this.onAnyCharacterSet(this.index - 1, this.index, "any");
1158 return true;
1159 }
1160 return false;
1161 }
1162 consumeReverseSolidusAtomEscape() {
1163 const start = this.index;
1164 if (this.eat(REVERSE_SOLIDUS)) {
1165 if (this.consumeAtomEscape()) {
1166 return true;
1167 }
1168 this.rewind(start);
1169 }
1170 return false;
1171 }
1172 consumeUncapturingGroup() {
1173 const start = this.index;
1174 if (this.eat2(LEFT_PARENTHESIS, QUESTION_MARK)) {
1175 this.onGroupEnter(start);
1176 if (this.ecmaVersion >= 2025) {
1177 this.consumeModifiers();
1178 }
1179 if (!this.eat(COLON)) {
1180 this.rewind(start + 1);
1181 this.raise("Invalid group");
1182 }
1183 this.consumeDisjunction();
1184 if (!this.eat(RIGHT_PARENTHESIS)) {
1185 this.raise("Unterminated group");
1186 }
1187 this.onGroupLeave(start, this.index);
1188 return true;
1189 }
1190 return false;
1191 }
1192 consumeModifiers() {
1193 const start = this.index;
1194 const hasAddModifiers = this.eatModifiers();
1195 const addModifiersEnd = this.index;
1196 const hasHyphen = this.eat(HYPHEN_MINUS);
1197 if (!hasAddModifiers && !hasHyphen) {
1198 return false;
1199 }
1200 this.onModifiersEnter(start);
1201 const addModifiers = this.parseModifiers(start, addModifiersEnd);
1202 this.onAddModifiers(start, addModifiersEnd, addModifiers);
1203 if (hasHyphen) {
1204 const modifiersStart = this.index;
1205 if (!this.eatModifiers() &&
1206 !hasAddModifiers &&
1207 this.currentCodePoint === COLON) {
1208 this.raise("Invalid empty flags");
1209 }
1210 const modifiers = this.parseModifiers(modifiersStart, this.index);
1211 for (const [flagName] of Object.entries(modifiers).filter(([, enable]) => enable)) {
1212 if (addModifiers[flagName]) {
1213 this.raise(`Duplicated flag '${String.fromCodePoint(FLAG_PROP_TO_CODEPOINT[flagName])}'`);
1214 }
1215 }
1216 this.onRemoveModifiers(modifiersStart, this.index, modifiers);
1217 }
1218 this.onModifiersLeave(start, this.index);
1219 return true;
1220 }
1221 consumeCapturingGroup() {
1222 const start = this.index;
1223 if (this.eat(LEFT_PARENTHESIS)) {
1224 let name = null;
1225 if (this.ecmaVersion >= 2018) {
1226 if (this.consumeGroupSpecifier()) {
1227 name = this._lastStrValue;
1228 }
1229 else if (this.currentCodePoint === QUESTION_MARK) {
1230 this.rewind(start);
1231 return false;
1232 }
1233 }
1234 else if (this.currentCodePoint === QUESTION_MARK) {
1235 this.rewind(start);
1236 return false;
1237 }
1238 this.onCapturingGroupEnter(start, name);
1239 this.consumeDisjunction();
1240 if (!this.eat(RIGHT_PARENTHESIS)) {
1241 this.raise("Unterminated group");
1242 }
1243 this.onCapturingGroupLeave(start, this.index, name);
1244 return true;
1245 }
1246 return false;
1247 }
1248 consumeExtendedAtom() {
1249 return (this.consumeDot() ||
1250 this.consumeReverseSolidusAtomEscape() ||
1251 this.consumeReverseSolidusFollowedByC() ||
1252 Boolean(this.consumeCharacterClass()) ||
1253 this.consumeCapturingGroup() ||
1254 this.consumeUncapturingGroup() ||
1255 this.consumeInvalidBracedQuantifier() ||
1256 this.consumeExtendedPatternCharacter());
1257 }
1258 consumeReverseSolidusFollowedByC() {
1259 const start = this.index;
1260 if (this.currentCodePoint === REVERSE_SOLIDUS &&
1261 this.nextCodePoint === LATIN_SMALL_LETTER_C) {
1262 this._lastIntValue = this.currentCodePoint;
1263 this.advance();
1264 this.onCharacter(start, this.index, REVERSE_SOLIDUS);
1265 return true;
1266 }
1267 return false;
1268 }
1269 consumeInvalidBracedQuantifier() {
1270 if (this.eatBracedQuantifier(true)) {
1271 this.raise("Nothing to repeat");
1272 }
1273 return false;
1274 }
1275 consumePatternCharacter() {
1276 const start = this.index;
1277 const cp = this.currentCodePoint;
1278 if (cp !== -1 && !isSyntaxCharacter(cp)) {
1279 this.advance();
1280 this.onCharacter(start, this.index, cp);
1281 return true;
1282 }
1283 return false;
1284 }
1285 consumeExtendedPatternCharacter() {
1286 const start = this.index;
1287 const cp = this.currentCodePoint;
1288 if (cp !== -1 &&
1289 cp !== CIRCUMFLEX_ACCENT &&
1290 cp !== DOLLAR_SIGN &&
1291 cp !== REVERSE_SOLIDUS &&
1292 cp !== FULL_STOP &&
1293 cp !== ASTERISK &&
1294 cp !== PLUS_SIGN &&
1295 cp !== QUESTION_MARK &&
1296 cp !== LEFT_PARENTHESIS &&
1297 cp !== RIGHT_PARENTHESIS &&
1298 cp !== LEFT_SQUARE_BRACKET &&
1299 cp !== VERTICAL_LINE) {
1300 this.advance();
1301 this.onCharacter(start, this.index, cp);
1302 return true;
1303 }
1304 return false;
1305 }
1306 consumeGroupSpecifier() {
1307 const start = this.index;
1308 if (this.eat(QUESTION_MARK)) {
1309 if (this.eatGroupName()) {
1310 if (!this._groupSpecifiers.hasInScope(this._lastStrValue)) {
1311 this._groupSpecifiers.addToScope(this._lastStrValue);
1312 return true;
1313 }
1314 this.raise("Duplicate capture group name");
1315 }
1316 this.rewind(start);
1317 }
1318 return false;
1319 }
1320 consumeAtomEscape() {
1321 if (this.consumeBackreference() ||
1322 this.consumeCharacterClassEscape() ||
1323 this.consumeCharacterEscape() ||
1324 (this._nFlag && this.consumeKGroupName())) {
1325 return true;
1326 }
1327 if (this.strict || this._unicodeMode) {
1328 this.raise("Invalid escape");
1329 }
1330 return false;
1331 }
1332 consumeBackreference() {
1333 const start = this.index;
1334 if (this.eatDecimalEscape()) {
1335 const n = this._lastIntValue;
1336 if (n <= this._numCapturingParens) {
1337 this.onBackreference(start - 1, this.index, n);
1338 return true;
1339 }
1340 if (this.strict || this._unicodeMode) {
1341 this.raise("Invalid escape");
1342 }
1343 this.rewind(start);
1344 }
1345 return false;
1346 }
1347 consumeCharacterClassEscape() {
1348 var _a;
1349 const start = this.index;
1350 if (this.eat(LATIN_SMALL_LETTER_D)) {
1351 this._lastIntValue = -1;
1352 this.onEscapeCharacterSet(start - 1, this.index, "digit", false);
1353 return {};
1354 }
1355 if (this.eat(LATIN_CAPITAL_LETTER_D)) {
1356 this._lastIntValue = -1;
1357 this.onEscapeCharacterSet(start - 1, this.index, "digit", true);
1358 return {};
1359 }
1360 if (this.eat(LATIN_SMALL_LETTER_S)) {
1361 this._lastIntValue = -1;
1362 this.onEscapeCharacterSet(start - 1, this.index, "space", false);
1363 return {};
1364 }
1365 if (this.eat(LATIN_CAPITAL_LETTER_S)) {
1366 this._lastIntValue = -1;
1367 this.onEscapeCharacterSet(start - 1, this.index, "space", true);
1368 return {};
1369 }
1370 if (this.eat(LATIN_SMALL_LETTER_W)) {
1371 this._lastIntValue = -1;
1372 this.onEscapeCharacterSet(start - 1, this.index, "word", false);
1373 return {};
1374 }
1375 if (this.eat(LATIN_CAPITAL_LETTER_W)) {
1376 this._lastIntValue = -1;
1377 this.onEscapeCharacterSet(start - 1, this.index, "word", true);
1378 return {};
1379 }
1380 let negate = false;
1381 if (this._unicodeMode &&
1382 this.ecmaVersion >= 2018 &&
1383 (this.eat(LATIN_SMALL_LETTER_P) ||
1384 (negate = this.eat(LATIN_CAPITAL_LETTER_P)))) {
1385 this._lastIntValue = -1;
1386 let result = null;
1387 if (this.eat(LEFT_CURLY_BRACKET) &&
1388 (result = this.eatUnicodePropertyValueExpression()) &&
1389 this.eat(RIGHT_CURLY_BRACKET)) {
1390 if (negate && result.strings) {
1391 this.raise("Invalid property name");
1392 }
1393 this.onUnicodePropertyCharacterSet(start - 1, this.index, "property", result.key, result.value, negate, (_a = result.strings) !== null && _a !== void 0 ? _a : false);
1394 return { mayContainStrings: result.strings };
1395 }
1396 this.raise("Invalid property name");
1397 }
1398 return null;
1399 }
1400 consumeCharacterEscape() {
1401 const start = this.index;
1402 if (this.eatControlEscape() ||
1403 this.eatCControlLetter() ||
1404 this.eatZero() ||
1405 this.eatHexEscapeSequence() ||
1406 this.eatRegExpUnicodeEscapeSequence() ||
1407 (!this.strict &&
1408 !this._unicodeMode &&
1409 this.eatLegacyOctalEscapeSequence()) ||
1410 this.eatIdentityEscape()) {
1411 this.onCharacter(start - 1, this.index, this._lastIntValue);
1412 return true;
1413 }
1414 return false;
1415 }
1416 consumeKGroupName() {
1417 const start = this.index;
1418 if (this.eat(LATIN_SMALL_LETTER_K)) {
1419 if (this.eatGroupName()) {
1420 const groupName = this._lastStrValue;
1421 this._backreferenceNames.add(groupName);
1422 this.onBackreference(start - 1, this.index, groupName);
1423 return true;
1424 }
1425 this.raise("Invalid named reference");
1426 }
1427 return false;
1428 }
1429 consumeCharacterClass() {
1430 const start = this.index;
1431 if (this.eat(LEFT_SQUARE_BRACKET)) {
1432 const negate = this.eat(CIRCUMFLEX_ACCENT);
1433 this.onCharacterClassEnter(start, negate, this._unicodeSetsMode);
1434 const result = this.consumeClassContents();
1435 if (!this.eat(RIGHT_SQUARE_BRACKET)) {
1436 if (this.currentCodePoint === -1) {
1437 this.raise("Unterminated character class");
1438 }
1439 this.raise("Invalid character in character class");
1440 }
1441 if (negate && result.mayContainStrings) {
1442 this.raise("Negated character class may contain strings");
1443 }
1444 this.onCharacterClassLeave(start, this.index, negate);
1445 return result;
1446 }
1447 return null;
1448 }
1449 consumeClassContents() {
1450 if (this._unicodeSetsMode) {
1451 if (this.currentCodePoint === RIGHT_SQUARE_BRACKET) {
1452 return {};
1453 }
1454 const result = this.consumeClassSetExpression();
1455 return result;
1456 }
1457 const strict = this.strict || this._unicodeMode;
1458 for (;;) {
1459 const rangeStart = this.index;
1460 if (!this.consumeClassAtom()) {
1461 break;
1462 }
1463 const min = this._lastIntValue;
1464 if (!this.eat(HYPHEN_MINUS)) {
1465 continue;
1466 }
1467 this.onCharacter(this.index - 1, this.index, HYPHEN_MINUS);
1468 if (!this.consumeClassAtom()) {
1469 break;
1470 }
1471 const max = this._lastIntValue;
1472 if (min === -1 || max === -1) {
1473 if (strict) {
1474 this.raise("Invalid character class");
1475 }
1476 continue;
1477 }
1478 if (min > max) {
1479 this.raise("Range out of order in character class");
1480 }
1481 this.onCharacterClassRange(rangeStart, this.index, min, max);
1482 }
1483 return {};
1484 }
1485 consumeClassAtom() {
1486 const start = this.index;
1487 const cp = this.currentCodePoint;
1488 if (cp !== -1 &&
1489 cp !== REVERSE_SOLIDUS &&
1490 cp !== RIGHT_SQUARE_BRACKET) {
1491 this.advance();
1492 this._lastIntValue = cp;
1493 this.onCharacter(start, this.index, this._lastIntValue);
1494 return true;
1495 }
1496 if (this.eat(REVERSE_SOLIDUS)) {
1497 if (this.consumeClassEscape()) {
1498 return true;
1499 }
1500 if (!this.strict &&
1501 this.currentCodePoint === LATIN_SMALL_LETTER_C) {
1502 this._lastIntValue = REVERSE_SOLIDUS;
1503 this.onCharacter(start, this.index, this._lastIntValue);
1504 return true;
1505 }
1506 if (this.strict || this._unicodeMode) {
1507 this.raise("Invalid escape");
1508 }
1509 this.rewind(start);
1510 }
1511 return false;
1512 }
1513 consumeClassEscape() {
1514 const start = this.index;
1515 if (this.eat(LATIN_SMALL_LETTER_B)) {
1516 this._lastIntValue = BACKSPACE;
1517 this.onCharacter(start - 1, this.index, this._lastIntValue);
1518 return true;
1519 }
1520 if (this._unicodeMode && this.eat(HYPHEN_MINUS)) {
1521 this._lastIntValue = HYPHEN_MINUS;
1522 this.onCharacter(start - 1, this.index, this._lastIntValue);
1523 return true;
1524 }
1525 let cp = 0;
1526 if (!this.strict &&
1527 !this._unicodeMode &&
1528 this.currentCodePoint === LATIN_SMALL_LETTER_C &&
1529 (isDecimalDigit((cp = this.nextCodePoint)) || cp === LOW_LINE)) {
1530 this.advance();
1531 this.advance();
1532 this._lastIntValue = cp % 0x20;
1533 this.onCharacter(start - 1, this.index, this._lastIntValue);
1534 return true;
1535 }
1536 return (Boolean(this.consumeCharacterClassEscape()) ||
1537 this.consumeCharacterEscape());
1538 }
1539 consumeClassSetExpression() {
1540 const start = this.index;
1541 let mayContainStrings = false;
1542 let result = null;
1543 if (this.consumeClassSetCharacter()) {
1544 if (this.consumeClassSetRangeFromOperator(start)) {
1545 this.consumeClassUnionRight({});
1546 return {};
1547 }
1548 mayContainStrings = false;
1549 }
1550 else if ((result = this.consumeClassSetOperand())) {
1551 mayContainStrings = result.mayContainStrings;
1552 }
1553 else {
1554 const cp = this.currentCodePoint;
1555 if (cp === REVERSE_SOLIDUS) {
1556 this.advance();
1557 this.raise("Invalid escape");
1558 }
1559 if (cp === this.nextCodePoint &&
1560 isClassSetReservedDoublePunctuatorCharacter(cp)) {
1561 this.raise("Invalid set operation in character class");
1562 }
1563 this.raise("Invalid character in character class");
1564 }
1565 if (this.eat2(AMPERSAND, AMPERSAND)) {
1566 while (this.currentCodePoint !== AMPERSAND &&
1567 (result = this.consumeClassSetOperand())) {
1568 this.onClassIntersection(start, this.index);
1569 if (!result.mayContainStrings) {
1570 mayContainStrings = false;
1571 }
1572 if (this.eat2(AMPERSAND, AMPERSAND)) {
1573 continue;
1574 }
1575 return { mayContainStrings };
1576 }
1577 this.raise("Invalid character in character class");
1578 }
1579 if (this.eat2(HYPHEN_MINUS, HYPHEN_MINUS)) {
1580 while (this.consumeClassSetOperand()) {
1581 this.onClassSubtraction(start, this.index);
1582 if (this.eat2(HYPHEN_MINUS, HYPHEN_MINUS)) {
1583 continue;
1584 }
1585 return { mayContainStrings };
1586 }
1587 this.raise("Invalid character in character class");
1588 }
1589 return this.consumeClassUnionRight({ mayContainStrings });
1590 }
1591 consumeClassUnionRight(leftResult) {
1592 let mayContainStrings = leftResult.mayContainStrings;
1593 for (;;) {
1594 const start = this.index;
1595 if (this.consumeClassSetCharacter()) {
1596 this.consumeClassSetRangeFromOperator(start);
1597 continue;
1598 }
1599 const result = this.consumeClassSetOperand();
1600 if (result) {
1601 if (result.mayContainStrings) {
1602 mayContainStrings = true;
1603 }
1604 continue;
1605 }
1606 break;
1607 }
1608 return { mayContainStrings };
1609 }
1610 consumeClassSetRangeFromOperator(start) {
1611 const currentStart = this.index;
1612 const min = this._lastIntValue;
1613 if (this.eat(HYPHEN_MINUS)) {
1614 if (this.consumeClassSetCharacter()) {
1615 const max = this._lastIntValue;
1616 if (min === -1 || max === -1) {
1617 this.raise("Invalid character class");
1618 }
1619 if (min > max) {
1620 this.raise("Range out of order in character class");
1621 }
1622 this.onCharacterClassRange(start, this.index, min, max);
1623 return true;
1624 }
1625 this.rewind(currentStart);
1626 }
1627 return false;
1628 }
1629 consumeClassSetOperand() {
1630 let result = null;
1631 if ((result = this.consumeNestedClass())) {
1632 return result;
1633 }
1634 if ((result = this.consumeClassStringDisjunction())) {
1635 return result;
1636 }
1637 if (this.consumeClassSetCharacter()) {
1638 return {};
1639 }
1640 return null;
1641 }
1642 consumeNestedClass() {
1643 const start = this.index;
1644 if (this.eat(LEFT_SQUARE_BRACKET)) {
1645 const negate = this.eat(CIRCUMFLEX_ACCENT);
1646 this.onCharacterClassEnter(start, negate, true);
1647 const result = this.consumeClassContents();
1648 if (!this.eat(RIGHT_SQUARE_BRACKET)) {
1649 this.raise("Unterminated character class");
1650 }
1651 if (negate && result.mayContainStrings) {
1652 this.raise("Negated character class may contain strings");
1653 }
1654 this.onCharacterClassLeave(start, this.index, negate);
1655 return result;
1656 }
1657 if (this.eat(REVERSE_SOLIDUS)) {
1658 const result = this.consumeCharacterClassEscape();
1659 if (result) {
1660 return result;
1661 }
1662 this.rewind(start);
1663 }
1664 return null;
1665 }
1666 consumeClassStringDisjunction() {
1667 const start = this.index;
1668 if (this.eat3(REVERSE_SOLIDUS, LATIN_SMALL_LETTER_Q, LEFT_CURLY_BRACKET)) {
1669 this.onClassStringDisjunctionEnter(start);
1670 let i = 0;
1671 let mayContainStrings = false;
1672 do {
1673 if (this.consumeClassString(i++).mayContainStrings) {
1674 mayContainStrings = true;
1675 }
1676 } while (this.eat(VERTICAL_LINE));
1677 if (this.eat(RIGHT_CURLY_BRACKET)) {
1678 this.onClassStringDisjunctionLeave(start, this.index);
1679 return { mayContainStrings };
1680 }
1681 this.raise("Unterminated class string disjunction");
1682 }
1683 return null;
1684 }
1685 consumeClassString(i) {
1686 const start = this.index;
1687 let count = 0;
1688 this.onStringAlternativeEnter(start, i);
1689 while (this.currentCodePoint !== -1 &&
1690 this.consumeClassSetCharacter()) {
1691 count++;
1692 }
1693 this.onStringAlternativeLeave(start, this.index, i);
1694 return { mayContainStrings: count !== 1 };
1695 }
1696 consumeClassSetCharacter() {
1697 const start = this.index;
1698 const cp = this.currentCodePoint;
1699 if (cp !== this.nextCodePoint ||
1700 !isClassSetReservedDoublePunctuatorCharacter(cp)) {
1701 if (cp !== -1 && !isClassSetSyntaxCharacter(cp)) {
1702 this._lastIntValue = cp;
1703 this.advance();
1704 this.onCharacter(start, this.index, this._lastIntValue);
1705 return true;
1706 }
1707 }
1708 if (this.eat(REVERSE_SOLIDUS)) {
1709 if (this.consumeCharacterEscape()) {
1710 return true;
1711 }
1712 if (isClassSetReservedPunctuator(this.currentCodePoint)) {
1713 this._lastIntValue = this.currentCodePoint;
1714 this.advance();
1715 this.onCharacter(start, this.index, this._lastIntValue);
1716 return true;
1717 }
1718 if (this.eat(LATIN_SMALL_LETTER_B)) {
1719 this._lastIntValue = BACKSPACE;
1720 this.onCharacter(start, this.index, this._lastIntValue);
1721 return true;
1722 }
1723 this.rewind(start);
1724 }
1725 return false;
1726 }
1727 eatGroupName() {
1728 if (this.eat(LESS_THAN_SIGN)) {
1729 if (this.eatRegExpIdentifierName() && this.eat(GREATER_THAN_SIGN)) {
1730 return true;
1731 }
1732 this.raise("Invalid capture group name");
1733 }
1734 return false;
1735 }
1736 eatRegExpIdentifierName() {
1737 if (this.eatRegExpIdentifierStart()) {
1738 this._lastStrValue = String.fromCodePoint(this._lastIntValue);
1739 while (this.eatRegExpIdentifierPart()) {
1740 this._lastStrValue += String.fromCodePoint(this._lastIntValue);
1741 }
1742 return true;
1743 }
1744 return false;
1745 }
1746 eatRegExpIdentifierStart() {
1747 const start = this.index;
1748 const forceUFlag = !this._unicodeMode && this.ecmaVersion >= 2020;
1749 let cp = this.currentCodePoint;
1750 this.advance();
1751 if (cp === REVERSE_SOLIDUS &&
1752 this.eatRegExpUnicodeEscapeSequence(forceUFlag)) {
1753 cp = this._lastIntValue;
1754 }
1755 else if (forceUFlag &&
1756 isLeadSurrogate(cp) &&
1757 isTrailSurrogate(this.currentCodePoint)) {
1758 cp = combineSurrogatePair(cp, this.currentCodePoint);
1759 this.advance();
1760 }
1761 if (isIdentifierStartChar(cp)) {
1762 this._lastIntValue = cp;
1763 return true;
1764 }
1765 if (this.index !== start) {
1766 this.rewind(start);
1767 }
1768 return false;
1769 }
1770 eatRegExpIdentifierPart() {
1771 const start = this.index;
1772 const forceUFlag = !this._unicodeMode && this.ecmaVersion >= 2020;
1773 let cp = this.currentCodePoint;
1774 this.advance();
1775 if (cp === REVERSE_SOLIDUS &&
1776 this.eatRegExpUnicodeEscapeSequence(forceUFlag)) {
1777 cp = this._lastIntValue;
1778 }
1779 else if (forceUFlag &&
1780 isLeadSurrogate(cp) &&
1781 isTrailSurrogate(this.currentCodePoint)) {
1782 cp = combineSurrogatePair(cp, this.currentCodePoint);
1783 this.advance();
1784 }
1785 if (isIdentifierPartChar(cp)) {
1786 this._lastIntValue = cp;
1787 return true;
1788 }
1789 if (this.index !== start) {
1790 this.rewind(start);
1791 }
1792 return false;
1793 }
1794 eatCControlLetter() {
1795 const start = this.index;
1796 if (this.eat(LATIN_SMALL_LETTER_C)) {
1797 if (this.eatControlLetter()) {
1798 return true;
1799 }
1800 this.rewind(start);
1801 }
1802 return false;
1803 }
1804 eatZero() {
1805 if (this.currentCodePoint === DIGIT_ZERO &&
1806 !isDecimalDigit(this.nextCodePoint)) {
1807 this._lastIntValue = 0;
1808 this.advance();
1809 return true;
1810 }
1811 return false;
1812 }
1813 eatControlEscape() {
1814 if (this.eat(LATIN_SMALL_LETTER_F)) {
1815 this._lastIntValue = FORM_FEED;
1816 return true;
1817 }
1818 if (this.eat(LATIN_SMALL_LETTER_N)) {
1819 this._lastIntValue = LINE_FEED;
1820 return true;
1821 }
1822 if (this.eat(LATIN_SMALL_LETTER_R)) {
1823 this._lastIntValue = CARRIAGE_RETURN;
1824 return true;
1825 }
1826 if (this.eat(LATIN_SMALL_LETTER_T)) {
1827 this._lastIntValue = CHARACTER_TABULATION;
1828 return true;
1829 }
1830 if (this.eat(LATIN_SMALL_LETTER_V)) {
1831 this._lastIntValue = LINE_TABULATION;
1832 return true;
1833 }
1834 return false;
1835 }
1836 eatControlLetter() {
1837 const cp = this.currentCodePoint;
1838 if (isLatinLetter(cp)) {
1839 this.advance();
1840 this._lastIntValue = cp % 0x20;
1841 return true;
1842 }
1843 return false;
1844 }
1845 eatRegExpUnicodeEscapeSequence(forceUFlag = false) {
1846 const start = this.index;
1847 const uFlag = forceUFlag || this._unicodeMode;
1848 if (this.eat(LATIN_SMALL_LETTER_U)) {
1849 if ((uFlag && this.eatRegExpUnicodeSurrogatePairEscape()) ||
1850 this.eatFixedHexDigits(4) ||
1851 (uFlag && this.eatRegExpUnicodeCodePointEscape())) {
1852 return true;
1853 }
1854 if (this.strict || uFlag) {
1855 this.raise("Invalid unicode escape");
1856 }
1857 this.rewind(start);
1858 }
1859 return false;
1860 }
1861 eatRegExpUnicodeSurrogatePairEscape() {
1862 const start = this.index;
1863 if (this.eatFixedHexDigits(4)) {
1864 const lead = this._lastIntValue;
1865 if (isLeadSurrogate(lead) &&
1866 this.eat(REVERSE_SOLIDUS) &&
1867 this.eat(LATIN_SMALL_LETTER_U) &&
1868 this.eatFixedHexDigits(4)) {
1869 const trail = this._lastIntValue;
1870 if (isTrailSurrogate(trail)) {
1871 this._lastIntValue = combineSurrogatePair(lead, trail);
1872 return true;
1873 }
1874 }
1875 this.rewind(start);
1876 }
1877 return false;
1878 }
1879 eatRegExpUnicodeCodePointEscape() {
1880 const start = this.index;
1881 if (this.eat(LEFT_CURLY_BRACKET) &&
1882 this.eatHexDigits() &&
1883 this.eat(RIGHT_CURLY_BRACKET) &&
1884 isValidUnicode(this._lastIntValue)) {
1885 return true;
1886 }
1887 this.rewind(start);
1888 return false;
1889 }
1890 eatIdentityEscape() {
1891 const cp = this.currentCodePoint;
1892 if (this.isValidIdentityEscape(cp)) {
1893 this._lastIntValue = cp;
1894 this.advance();
1895 return true;
1896 }
1897 return false;
1898 }
1899 isValidIdentityEscape(cp) {
1900 if (cp === -1) {
1901 return false;
1902 }
1903 if (this._unicodeMode) {
1904 return isSyntaxCharacter(cp) || cp === SOLIDUS;
1905 }
1906 if (this.strict) {
1907 return !isIdContinue(cp);
1908 }
1909 if (this._nFlag) {
1910 return !(cp === LATIN_SMALL_LETTER_C || cp === LATIN_SMALL_LETTER_K);
1911 }
1912 return cp !== LATIN_SMALL_LETTER_C;
1913 }
1914 eatDecimalEscape() {
1915 this._lastIntValue = 0;
1916 let cp = this.currentCodePoint;
1917 if (cp >= DIGIT_ONE && cp <= DIGIT_NINE) {
1918 do {
1919 this._lastIntValue = 10 * this._lastIntValue + (cp - DIGIT_ZERO);
1920 this.advance();
1921 } while ((cp = this.currentCodePoint) >= DIGIT_ZERO &&
1922 cp <= DIGIT_NINE);
1923 return true;
1924 }
1925 return false;
1926 }
1927 eatUnicodePropertyValueExpression() {
1928 const start = this.index;
1929 if (this.eatUnicodePropertyName() && this.eat(EQUALS_SIGN)) {
1930 const key = this._lastStrValue;
1931 if (this.eatUnicodePropertyValue()) {
1932 const value = this._lastStrValue;
1933 if (isValidUnicodeProperty(this.ecmaVersion, key, value)) {
1934 return {
1935 key,
1936 value: value || null,
1937 };
1938 }
1939 this.raise("Invalid property name");
1940 }
1941 }
1942 this.rewind(start);
1943 if (this.eatLoneUnicodePropertyNameOrValue()) {
1944 const nameOrValue = this._lastStrValue;
1945 if (isValidUnicodeProperty(this.ecmaVersion, "General_Category", nameOrValue)) {
1946 return {
1947 key: "General_Category",
1948 value: nameOrValue || null,
1949 };
1950 }
1951 if (isValidLoneUnicodeProperty(this.ecmaVersion, nameOrValue)) {
1952 return {
1953 key: nameOrValue,
1954 value: null,
1955 };
1956 }
1957 if (this._unicodeSetsMode &&
1958 isValidLoneUnicodePropertyOfString(this.ecmaVersion, nameOrValue)) {
1959 return {
1960 key: nameOrValue,
1961 value: null,
1962 strings: true,
1963 };
1964 }
1965 this.raise("Invalid property name");
1966 }
1967 return null;
1968 }
1969 eatUnicodePropertyName() {
1970 this._lastStrValue = "";
1971 while (isUnicodePropertyNameCharacter(this.currentCodePoint)) {
1972 this._lastStrValue += String.fromCodePoint(this.currentCodePoint);
1973 this.advance();
1974 }
1975 return this._lastStrValue !== "";
1976 }
1977 eatUnicodePropertyValue() {
1978 this._lastStrValue = "";
1979 while (isUnicodePropertyValueCharacter(this.currentCodePoint)) {
1980 this._lastStrValue += String.fromCodePoint(this.currentCodePoint);
1981 this.advance();
1982 }
1983 return this._lastStrValue !== "";
1984 }
1985 eatLoneUnicodePropertyNameOrValue() {
1986 return this.eatUnicodePropertyValue();
1987 }
1988 eatHexEscapeSequence() {
1989 const start = this.index;
1990 if (this.eat(LATIN_SMALL_LETTER_X)) {
1991 if (this.eatFixedHexDigits(2)) {
1992 return true;
1993 }
1994 if (this._unicodeMode || this.strict) {
1995 this.raise("Invalid escape");
1996 }
1997 this.rewind(start);
1998 }
1999 return false;
2000 }
2001 eatDecimalDigits() {
2002 const start = this.index;
2003 this._lastIntValue = 0;
2004 while (isDecimalDigit(this.currentCodePoint)) {
2005 this._lastIntValue =
2006 10 * this._lastIntValue + digitToInt(this.currentCodePoint);
2007 this.advance();
2008 }
2009 return this.index !== start;
2010 }
2011 eatHexDigits() {
2012 const start = this.index;
2013 this._lastIntValue = 0;
2014 while (isHexDigit(this.currentCodePoint)) {
2015 this._lastIntValue =
2016 16 * this._lastIntValue + digitToInt(this.currentCodePoint);
2017 this.advance();
2018 }
2019 return this.index !== start;
2020 }
2021 eatLegacyOctalEscapeSequence() {
2022 if (this.eatOctalDigit()) {
2023 const n1 = this._lastIntValue;
2024 if (this.eatOctalDigit()) {
2025 const n2 = this._lastIntValue;
2026 if (n1 <= 3 && this.eatOctalDigit()) {
2027 this._lastIntValue = n1 * 64 + n2 * 8 + this._lastIntValue;
2028 }
2029 else {
2030 this._lastIntValue = n1 * 8 + n2;
2031 }
2032 }
2033 else {
2034 this._lastIntValue = n1;
2035 }
2036 return true;
2037 }
2038 return false;
2039 }
2040 eatOctalDigit() {
2041 const cp = this.currentCodePoint;
2042 if (isOctalDigit(cp)) {
2043 this.advance();
2044 this._lastIntValue = cp - DIGIT_ZERO;
2045 return true;
2046 }
2047 this._lastIntValue = 0;
2048 return false;
2049 }
2050 eatFixedHexDigits(length) {
2051 const start = this.index;
2052 this._lastIntValue = 0;
2053 for (let i = 0; i < length; ++i) {
2054 const cp = this.currentCodePoint;
2055 if (!isHexDigit(cp)) {
2056 this.rewind(start);
2057 return false;
2058 }
2059 this._lastIntValue = 16 * this._lastIntValue + digitToInt(cp);
2060 this.advance();
2061 }
2062 return true;
2063 }
2064 eatModifiers() {
2065 let ate = false;
2066 while (isRegularExpressionModifier(this.currentCodePoint)) {
2067 this.advance();
2068 ate = true;
2069 }
2070 return ate;
2071 }
2072 parseModifiers(start, end) {
2073 const { ignoreCase, multiline, dotAll } = this.parseFlags(this._reader.source, start, end);
2074 return { ignoreCase, multiline, dotAll };
2075 }
2076 parseFlags(source, start, end) {
2077 const flags = {
2078 global: false,
2079 ignoreCase: false,
2080 multiline: false,
2081 unicode: false,
2082 sticky: false,
2083 dotAll: false,
2084 hasIndices: false,
2085 unicodeSets: false,
2086 };
2087 const validFlags = new Set();
2088 validFlags.add(LATIN_SMALL_LETTER_G);
2089 validFlags.add(LATIN_SMALL_LETTER_I);
2090 validFlags.add(LATIN_SMALL_LETTER_M);
2091 if (this.ecmaVersion >= 2015) {
2092 validFlags.add(LATIN_SMALL_LETTER_U);
2093 validFlags.add(LATIN_SMALL_LETTER_Y);
2094 if (this.ecmaVersion >= 2018) {
2095 validFlags.add(LATIN_SMALL_LETTER_S);
2096 if (this.ecmaVersion >= 2022) {
2097 validFlags.add(LATIN_SMALL_LETTER_D);
2098 if (this.ecmaVersion >= 2024) {
2099 validFlags.add(LATIN_SMALL_LETTER_V);
2100 }
2101 }
2102 }
2103 }
2104 for (let i = start; i < end; ++i) {
2105 const flag = source.charCodeAt(i);
2106 if (validFlags.has(flag)) {
2107 const prop = FLAG_CODEPOINT_TO_PROP[flag];
2108 if (flags[prop]) {
2109 this.raise(`Duplicated flag '${source[i]}'`, {
2110 index: start,
2111 });
2112 }
2113 flags[prop] = true;
2114 }
2115 else {
2116 this.raise(`Invalid flag '${source[i]}'`, { index: start });
2117 }
2118 }
2119 return flags;
2120 }
2121}
2122
2123const DUMMY_PATTERN = {};
2124const DUMMY_FLAGS = {};
2125const DUMMY_CAPTURING_GROUP = {};
2126function isClassSetOperand(node) {
2127 return (node.type === "Character" ||
2128 node.type === "CharacterSet" ||
2129 node.type === "CharacterClass" ||
2130 node.type === "ExpressionCharacterClass" ||
2131 node.type === "ClassStringDisjunction");
2132}
2133class RegExpParserState {
2134 constructor(options) {
2135 var _a;
2136 this._node = DUMMY_PATTERN;
2137 this._expressionBufferMap = new Map();
2138 this._flags = DUMMY_FLAGS;
2139 this._backreferences = [];
2140 this._capturingGroups = [];
2141 this.source = "";
2142 this.strict = Boolean(options === null || options === void 0 ? void 0 : options.strict);
2143 this.ecmaVersion = (_a = options === null || options === void 0 ? void 0 : options.ecmaVersion) !== null && _a !== void 0 ? _a : latestEcmaVersion;
2144 }
2145 get pattern() {
2146 if (this._node.type !== "Pattern") {
2147 throw new Error("UnknownError");
2148 }
2149 return this._node;
2150 }
2151 get flags() {
2152 if (this._flags.type !== "Flags") {
2153 throw new Error("UnknownError");
2154 }
2155 return this._flags;
2156 }
2157 onRegExpFlags(start, end, { global, ignoreCase, multiline, unicode, sticky, dotAll, hasIndices, unicodeSets, }) {
2158 this._flags = {
2159 type: "Flags",
2160 parent: null,
2161 start,
2162 end,
2163 raw: this.source.slice(start, end),
2164 global,
2165 ignoreCase,
2166 multiline,
2167 unicode,
2168 sticky,
2169 dotAll,
2170 hasIndices,
2171 unicodeSets,
2172 };
2173 }
2174 onPatternEnter(start) {
2175 this._node = {
2176 type: "Pattern",
2177 parent: null,
2178 start,
2179 end: start,
2180 raw: "",
2181 alternatives: [],
2182 };
2183 this._backreferences.length = 0;
2184 this._capturingGroups.length = 0;
2185 }
2186 onPatternLeave(start, end) {
2187 this._node.end = end;
2188 this._node.raw = this.source.slice(start, end);
2189 for (const reference of this._backreferences) {
2190 const ref = reference.ref;
2191 const groups = typeof ref === "number"
2192 ? [this._capturingGroups[ref - 1]]
2193 : this._capturingGroups.filter((g) => g.name === ref);
2194 if (groups.length === 1) {
2195 const group = groups[0];
2196 reference.ambiguous = false;
2197 reference.resolved = group;
2198 }
2199 else {
2200 reference.ambiguous = true;
2201 reference.resolved = groups;
2202 }
2203 for (const group of groups) {
2204 group.references.push(reference);
2205 }
2206 }
2207 }
2208 onAlternativeEnter(start) {
2209 const parent = this._node;
2210 if (parent.type !== "Assertion" &&
2211 parent.type !== "CapturingGroup" &&
2212 parent.type !== "Group" &&
2213 parent.type !== "Pattern") {
2214 throw new Error("UnknownError");
2215 }
2216 this._node = {
2217 type: "Alternative",
2218 parent,
2219 start,
2220 end: start,
2221 raw: "",
2222 elements: [],
2223 };
2224 parent.alternatives.push(this._node);
2225 }
2226 onAlternativeLeave(start, end) {
2227 const node = this._node;
2228 if (node.type !== "Alternative") {
2229 throw new Error("UnknownError");
2230 }
2231 node.end = end;
2232 node.raw = this.source.slice(start, end);
2233 this._node = node.parent;
2234 }
2235 onGroupEnter(start) {
2236 const parent = this._node;
2237 if (parent.type !== "Alternative") {
2238 throw new Error("UnknownError");
2239 }
2240 const group = {
2241 type: "Group",
2242 parent,
2243 start,
2244 end: start,
2245 raw: "",
2246 modifiers: null,
2247 alternatives: [],
2248 };
2249 this._node = group;
2250 parent.elements.push(this._node);
2251 }
2252 onGroupLeave(start, end) {
2253 const node = this._node;
2254 if (node.type !== "Group" || node.parent.type !== "Alternative") {
2255 throw new Error("UnknownError");
2256 }
2257 node.end = end;
2258 node.raw = this.source.slice(start, end);
2259 this._node = node.parent;
2260 }
2261 onModifiersEnter(start) {
2262 const parent = this._node;
2263 if (parent.type !== "Group") {
2264 throw new Error("UnknownError");
2265 }
2266 this._node = {
2267 type: "Modifiers",
2268 parent,
2269 start,
2270 end: start,
2271 raw: "",
2272 add: null,
2273 remove: null,
2274 };
2275 parent.modifiers = this._node;
2276 }
2277 onModifiersLeave(start, end) {
2278 const node = this._node;
2279 if (node.type !== "Modifiers" || node.parent.type !== "Group") {
2280 throw new Error("UnknownError");
2281 }
2282 node.end = end;
2283 node.raw = this.source.slice(start, end);
2284 this._node = node.parent;
2285 }
2286 onAddModifiers(start, end, { ignoreCase, multiline, dotAll, }) {
2287 const parent = this._node;
2288 if (parent.type !== "Modifiers") {
2289 throw new Error("UnknownError");
2290 }
2291 parent.add = {
2292 type: "ModifierFlags",
2293 parent,
2294 start,
2295 end,
2296 raw: this.source.slice(start, end),
2297 ignoreCase,
2298 multiline,
2299 dotAll,
2300 };
2301 }
2302 onRemoveModifiers(start, end, { ignoreCase, multiline, dotAll, }) {
2303 const parent = this._node;
2304 if (parent.type !== "Modifiers") {
2305 throw new Error("UnknownError");
2306 }
2307 parent.remove = {
2308 type: "ModifierFlags",
2309 parent,
2310 start,
2311 end,
2312 raw: this.source.slice(start, end),
2313 ignoreCase,
2314 multiline,
2315 dotAll,
2316 };
2317 }
2318 onCapturingGroupEnter(start, name) {
2319 const parent = this._node;
2320 if (parent.type !== "Alternative") {
2321 throw new Error("UnknownError");
2322 }
2323 this._node = {
2324 type: "CapturingGroup",
2325 parent,
2326 start,
2327 end: start,
2328 raw: "",
2329 name,
2330 alternatives: [],
2331 references: [],
2332 };
2333 parent.elements.push(this._node);
2334 this._capturingGroups.push(this._node);
2335 }
2336 onCapturingGroupLeave(start, end) {
2337 const node = this._node;
2338 if (node.type !== "CapturingGroup" ||
2339 node.parent.type !== "Alternative") {
2340 throw new Error("UnknownError");
2341 }
2342 node.end = end;
2343 node.raw = this.source.slice(start, end);
2344 this._node = node.parent;
2345 }
2346 onQuantifier(start, end, min, max, greedy) {
2347 const parent = this._node;
2348 if (parent.type !== "Alternative") {
2349 throw new Error("UnknownError");
2350 }
2351 const element = parent.elements.pop();
2352 if (element == null ||
2353 element.type === "Quantifier" ||
2354 (element.type === "Assertion" && element.kind !== "lookahead")) {
2355 throw new Error("UnknownError");
2356 }
2357 const node = {
2358 type: "Quantifier",
2359 parent,
2360 start: element.start,
2361 end,
2362 raw: this.source.slice(element.start, end),
2363 min,
2364 max,
2365 greedy,
2366 element,
2367 };
2368 parent.elements.push(node);
2369 element.parent = node;
2370 }
2371 onLookaroundAssertionEnter(start, kind, negate) {
2372 const parent = this._node;
2373 if (parent.type !== "Alternative") {
2374 throw new Error("UnknownError");
2375 }
2376 const node = (this._node = {
2377 type: "Assertion",
2378 parent,
2379 start,
2380 end: start,
2381 raw: "",
2382 kind,
2383 negate,
2384 alternatives: [],
2385 });
2386 parent.elements.push(node);
2387 }
2388 onLookaroundAssertionLeave(start, end) {
2389 const node = this._node;
2390 if (node.type !== "Assertion" || node.parent.type !== "Alternative") {
2391 throw new Error("UnknownError");
2392 }
2393 node.end = end;
2394 node.raw = this.source.slice(start, end);
2395 this._node = node.parent;
2396 }
2397 onEdgeAssertion(start, end, kind) {
2398 const parent = this._node;
2399 if (parent.type !== "Alternative") {
2400 throw new Error("UnknownError");
2401 }
2402 parent.elements.push({
2403 type: "Assertion",
2404 parent,
2405 start,
2406 end,
2407 raw: this.source.slice(start, end),
2408 kind,
2409 });
2410 }
2411 onWordBoundaryAssertion(start, end, kind, negate) {
2412 const parent = this._node;
2413 if (parent.type !== "Alternative") {
2414 throw new Error("UnknownError");
2415 }
2416 parent.elements.push({
2417 type: "Assertion",
2418 parent,
2419 start,
2420 end,
2421 raw: this.source.slice(start, end),
2422 kind,
2423 negate,
2424 });
2425 }
2426 onAnyCharacterSet(start, end, kind) {
2427 const parent = this._node;
2428 if (parent.type !== "Alternative") {
2429 throw new Error("UnknownError");
2430 }
2431 parent.elements.push({
2432 type: "CharacterSet",
2433 parent,
2434 start,
2435 end,
2436 raw: this.source.slice(start, end),
2437 kind,
2438 });
2439 }
2440 onEscapeCharacterSet(start, end, kind, negate) {
2441 const parent = this._node;
2442 if (parent.type !== "Alternative" && parent.type !== "CharacterClass") {
2443 throw new Error("UnknownError");
2444 }
2445 parent.elements.push({
2446 type: "CharacterSet",
2447 parent,
2448 start,
2449 end,
2450 raw: this.source.slice(start, end),
2451 kind,
2452 negate,
2453 });
2454 }
2455 onUnicodePropertyCharacterSet(start, end, kind, key, value, negate, strings) {
2456 const parent = this._node;
2457 if (parent.type !== "Alternative" && parent.type !== "CharacterClass") {
2458 throw new Error("UnknownError");
2459 }
2460 const base = {
2461 type: "CharacterSet",
2462 parent: null,
2463 start,
2464 end,
2465 raw: this.source.slice(start, end),
2466 kind,
2467 strings: null,
2468 key,
2469 };
2470 if (strings) {
2471 if ((parent.type === "CharacterClass" && !parent.unicodeSets) ||
2472 negate ||
2473 value !== null) {
2474 throw new Error("UnknownError");
2475 }
2476 parent.elements.push(Object.assign(Object.assign({}, base), { parent, strings, value, negate }));
2477 }
2478 else {
2479 parent.elements.push(Object.assign(Object.assign({}, base), { parent, strings, value, negate }));
2480 }
2481 }
2482 onCharacter(start, end, value) {
2483 const parent = this._node;
2484 if (parent.type !== "Alternative" &&
2485 parent.type !== "CharacterClass" &&
2486 parent.type !== "StringAlternative") {
2487 throw new Error("UnknownError");
2488 }
2489 parent.elements.push({
2490 type: "Character",
2491 parent,
2492 start,
2493 end,
2494 raw: this.source.slice(start, end),
2495 value,
2496 });
2497 }
2498 onBackreference(start, end, ref) {
2499 const parent = this._node;
2500 if (parent.type !== "Alternative") {
2501 throw new Error("UnknownError");
2502 }
2503 const node = {
2504 type: "Backreference",
2505 parent,
2506 start,
2507 end,
2508 raw: this.source.slice(start, end),
2509 ref,
2510 ambiguous: false,
2511 resolved: DUMMY_CAPTURING_GROUP,
2512 };
2513 parent.elements.push(node);
2514 this._backreferences.push(node);
2515 }
2516 onCharacterClassEnter(start, negate, unicodeSets) {
2517 const parent = this._node;
2518 const base = {
2519 type: "CharacterClass",
2520 parent,
2521 start,
2522 end: start,
2523 raw: "",
2524 unicodeSets,
2525 negate,
2526 elements: [],
2527 };
2528 if (parent.type === "Alternative") {
2529 const node = Object.assign(Object.assign({}, base), { parent });
2530 this._node = node;
2531 parent.elements.push(node);
2532 }
2533 else if (parent.type === "CharacterClass" &&
2534 parent.unicodeSets &&
2535 unicodeSets) {
2536 const node = Object.assign(Object.assign({}, base), { parent,
2537 unicodeSets });
2538 this._node = node;
2539 parent.elements.push(node);
2540 }
2541 else {
2542 throw new Error("UnknownError");
2543 }
2544 }
2545 onCharacterClassLeave(start, end) {
2546 const node = this._node;
2547 if (node.type !== "CharacterClass" ||
2548 (node.parent.type !== "Alternative" &&
2549 node.parent.type !== "CharacterClass")) {
2550 throw new Error("UnknownError");
2551 }
2552 const parent = node.parent;
2553 node.end = end;
2554 node.raw = this.source.slice(start, end);
2555 this._node = parent;
2556 const expression = this._expressionBufferMap.get(node);
2557 if (!expression) {
2558 return;
2559 }
2560 if (node.elements.length > 0) {
2561 throw new Error("UnknownError");
2562 }
2563 this._expressionBufferMap.delete(node);
2564 const newNode = {
2565 type: "ExpressionCharacterClass",
2566 parent,
2567 start: node.start,
2568 end: node.end,
2569 raw: node.raw,
2570 negate: node.negate,
2571 expression,
2572 };
2573 expression.parent = newNode;
2574 if (node !== parent.elements.pop()) {
2575 throw new Error("UnknownError");
2576 }
2577 parent.elements.push(newNode);
2578 }
2579 onCharacterClassRange(start, end) {
2580 const parent = this._node;
2581 if (parent.type !== "CharacterClass") {
2582 throw new Error("UnknownError");
2583 }
2584 const elements = parent.elements;
2585 const max = elements.pop();
2586 if (!max || max.type !== "Character") {
2587 throw new Error("UnknownError");
2588 }
2589 if (!parent.unicodeSets) {
2590 const hyphen = elements.pop();
2591 if (!hyphen ||
2592 hyphen.type !== "Character" ||
2593 hyphen.value !== HYPHEN_MINUS) {
2594 throw new Error("UnknownError");
2595 }
2596 }
2597 const min = elements.pop();
2598 if (!min || min.type !== "Character") {
2599 throw new Error("UnknownError");
2600 }
2601 const node = {
2602 type: "CharacterClassRange",
2603 parent,
2604 start,
2605 end,
2606 raw: this.source.slice(start, end),
2607 min,
2608 max,
2609 };
2610 min.parent = node;
2611 max.parent = node;
2612 elements.push(node);
2613 }
2614 onClassIntersection(start, end) {
2615 var _a;
2616 const parent = this._node;
2617 if (parent.type !== "CharacterClass" || !parent.unicodeSets) {
2618 throw new Error("UnknownError");
2619 }
2620 const right = parent.elements.pop();
2621 const left = (_a = this._expressionBufferMap.get(parent)) !== null && _a !== void 0 ? _a : parent.elements.pop();
2622 if (!left ||
2623 !right ||
2624 left.type === "ClassSubtraction" ||
2625 (left.type !== "ClassIntersection" && !isClassSetOperand(left)) ||
2626 !isClassSetOperand(right)) {
2627 throw new Error("UnknownError");
2628 }
2629 const node = {
2630 type: "ClassIntersection",
2631 parent: parent,
2632 start,
2633 end,
2634 raw: this.source.slice(start, end),
2635 left,
2636 right,
2637 };
2638 left.parent = node;
2639 right.parent = node;
2640 this._expressionBufferMap.set(parent, node);
2641 }
2642 onClassSubtraction(start, end) {
2643 var _a;
2644 const parent = this._node;
2645 if (parent.type !== "CharacterClass" || !parent.unicodeSets) {
2646 throw new Error("UnknownError");
2647 }
2648 const right = parent.elements.pop();
2649 const left = (_a = this._expressionBufferMap.get(parent)) !== null && _a !== void 0 ? _a : parent.elements.pop();
2650 if (!left ||
2651 !right ||
2652 left.type === "ClassIntersection" ||
2653 (left.type !== "ClassSubtraction" && !isClassSetOperand(left)) ||
2654 !isClassSetOperand(right)) {
2655 throw new Error("UnknownError");
2656 }
2657 const node = {
2658 type: "ClassSubtraction",
2659 parent: parent,
2660 start,
2661 end,
2662 raw: this.source.slice(start, end),
2663 left,
2664 right,
2665 };
2666 left.parent = node;
2667 right.parent = node;
2668 this._expressionBufferMap.set(parent, node);
2669 }
2670 onClassStringDisjunctionEnter(start) {
2671 const parent = this._node;
2672 if (parent.type !== "CharacterClass" || !parent.unicodeSets) {
2673 throw new Error("UnknownError");
2674 }
2675 this._node = {
2676 type: "ClassStringDisjunction",
2677 parent,
2678 start,
2679 end: start,
2680 raw: "",
2681 alternatives: [],
2682 };
2683 parent.elements.push(this._node);
2684 }
2685 onClassStringDisjunctionLeave(start, end) {
2686 const node = this._node;
2687 if (node.type !== "ClassStringDisjunction" ||
2688 node.parent.type !== "CharacterClass") {
2689 throw new Error("UnknownError");
2690 }
2691 node.end = end;
2692 node.raw = this.source.slice(start, end);
2693 this._node = node.parent;
2694 }
2695 onStringAlternativeEnter(start) {
2696 const parent = this._node;
2697 if (parent.type !== "ClassStringDisjunction") {
2698 throw new Error("UnknownError");
2699 }
2700 this._node = {
2701 type: "StringAlternative",
2702 parent,
2703 start,
2704 end: start,
2705 raw: "",
2706 elements: [],
2707 };
2708 parent.alternatives.push(this._node);
2709 }
2710 onStringAlternativeLeave(start, end) {
2711 const node = this._node;
2712 if (node.type !== "StringAlternative") {
2713 throw new Error("UnknownError");
2714 }
2715 node.end = end;
2716 node.raw = this.source.slice(start, end);
2717 this._node = node.parent;
2718 }
2719}
2720class RegExpParser {
2721 constructor(options) {
2722 this._state = new RegExpParserState(options);
2723 this._validator = new RegExpValidator(this._state);
2724 }
2725 parseLiteral(source, start = 0, end = source.length) {
2726 this._state.source = source;
2727 this._validator.validateLiteral(source, start, end);
2728 const pattern = this._state.pattern;
2729 const flags = this._state.flags;
2730 const literal = {
2731 type: "RegExpLiteral",
2732 parent: null,
2733 start,
2734 end,
2735 raw: source,
2736 pattern,
2737 flags,
2738 };
2739 pattern.parent = literal;
2740 flags.parent = literal;
2741 return literal;
2742 }
2743 parseFlags(source, start = 0, end = source.length) {
2744 this._state.source = source;
2745 this._validator.validateFlags(source, start, end);
2746 return this._state.flags;
2747 }
2748 parsePattern(source, start = 0, end = source.length, uFlagOrFlags = undefined) {
2749 this._state.source = source;
2750 this._validator.validatePattern(source, start, end, uFlagOrFlags);
2751 return this._state.pattern;
2752 }
2753}
2754
2755class RegExpVisitor {
2756 constructor(handlers) {
2757 this._handlers = handlers;
2758 }
2759 visit(node) {
2760 switch (node.type) {
2761 case "Alternative":
2762 this.visitAlternative(node);
2763 break;
2764 case "Assertion":
2765 this.visitAssertion(node);
2766 break;
2767 case "Backreference":
2768 this.visitBackreference(node);
2769 break;
2770 case "CapturingGroup":
2771 this.visitCapturingGroup(node);
2772 break;
2773 case "Character":
2774 this.visitCharacter(node);
2775 break;
2776 case "CharacterClass":
2777 this.visitCharacterClass(node);
2778 break;
2779 case "CharacterClassRange":
2780 this.visitCharacterClassRange(node);
2781 break;
2782 case "CharacterSet":
2783 this.visitCharacterSet(node);
2784 break;
2785 case "ClassIntersection":
2786 this.visitClassIntersection(node);
2787 break;
2788 case "ClassStringDisjunction":
2789 this.visitClassStringDisjunction(node);
2790 break;
2791 case "ClassSubtraction":
2792 this.visitClassSubtraction(node);
2793 break;
2794 case "ExpressionCharacterClass":
2795 this.visitExpressionCharacterClass(node);
2796 break;
2797 case "Flags":
2798 this.visitFlags(node);
2799 break;
2800 case "Group":
2801 this.visitGroup(node);
2802 break;
2803 case "Modifiers":
2804 this.visitModifiers(node);
2805 break;
2806 case "ModifierFlags":
2807 this.visitModifierFlags(node);
2808 break;
2809 case "Pattern":
2810 this.visitPattern(node);
2811 break;
2812 case "Quantifier":
2813 this.visitQuantifier(node);
2814 break;
2815 case "RegExpLiteral":
2816 this.visitRegExpLiteral(node);
2817 break;
2818 case "StringAlternative":
2819 this.visitStringAlternative(node);
2820 break;
2821 default:
2822 throw new Error(`Unknown type: ${node.type}`);
2823 }
2824 }
2825 visitAlternative(node) {
2826 if (this._handlers.onAlternativeEnter) {
2827 this._handlers.onAlternativeEnter(node);
2828 }
2829 node.elements.forEach(this.visit, this);
2830 if (this._handlers.onAlternativeLeave) {
2831 this._handlers.onAlternativeLeave(node);
2832 }
2833 }
2834 visitAssertion(node) {
2835 if (this._handlers.onAssertionEnter) {
2836 this._handlers.onAssertionEnter(node);
2837 }
2838 if (node.kind === "lookahead" || node.kind === "lookbehind") {
2839 node.alternatives.forEach(this.visit, this);
2840 }
2841 if (this._handlers.onAssertionLeave) {
2842 this._handlers.onAssertionLeave(node);
2843 }
2844 }
2845 visitBackreference(node) {
2846 if (this._handlers.onBackreferenceEnter) {
2847 this._handlers.onBackreferenceEnter(node);
2848 }
2849 if (this._handlers.onBackreferenceLeave) {
2850 this._handlers.onBackreferenceLeave(node);
2851 }
2852 }
2853 visitCapturingGroup(node) {
2854 if (this._handlers.onCapturingGroupEnter) {
2855 this._handlers.onCapturingGroupEnter(node);
2856 }
2857 node.alternatives.forEach(this.visit, this);
2858 if (this._handlers.onCapturingGroupLeave) {
2859 this._handlers.onCapturingGroupLeave(node);
2860 }
2861 }
2862 visitCharacter(node) {
2863 if (this._handlers.onCharacterEnter) {
2864 this._handlers.onCharacterEnter(node);
2865 }
2866 if (this._handlers.onCharacterLeave) {
2867 this._handlers.onCharacterLeave(node);
2868 }
2869 }
2870 visitCharacterClass(node) {
2871 if (this._handlers.onCharacterClassEnter) {
2872 this._handlers.onCharacterClassEnter(node);
2873 }
2874 node.elements.forEach(this.visit, this);
2875 if (this._handlers.onCharacterClassLeave) {
2876 this._handlers.onCharacterClassLeave(node);
2877 }
2878 }
2879 visitCharacterClassRange(node) {
2880 if (this._handlers.onCharacterClassRangeEnter) {
2881 this._handlers.onCharacterClassRangeEnter(node);
2882 }
2883 this.visitCharacter(node.min);
2884 this.visitCharacter(node.max);
2885 if (this._handlers.onCharacterClassRangeLeave) {
2886 this._handlers.onCharacterClassRangeLeave(node);
2887 }
2888 }
2889 visitCharacterSet(node) {
2890 if (this._handlers.onCharacterSetEnter) {
2891 this._handlers.onCharacterSetEnter(node);
2892 }
2893 if (this._handlers.onCharacterSetLeave) {
2894 this._handlers.onCharacterSetLeave(node);
2895 }
2896 }
2897 visitClassIntersection(node) {
2898 if (this._handlers.onClassIntersectionEnter) {
2899 this._handlers.onClassIntersectionEnter(node);
2900 }
2901 this.visit(node.left);
2902 this.visit(node.right);
2903 if (this._handlers.onClassIntersectionLeave) {
2904 this._handlers.onClassIntersectionLeave(node);
2905 }
2906 }
2907 visitClassStringDisjunction(node) {
2908 if (this._handlers.onClassStringDisjunctionEnter) {
2909 this._handlers.onClassStringDisjunctionEnter(node);
2910 }
2911 node.alternatives.forEach(this.visit, this);
2912 if (this._handlers.onClassStringDisjunctionLeave) {
2913 this._handlers.onClassStringDisjunctionLeave(node);
2914 }
2915 }
2916 visitClassSubtraction(node) {
2917 if (this._handlers.onClassSubtractionEnter) {
2918 this._handlers.onClassSubtractionEnter(node);
2919 }
2920 this.visit(node.left);
2921 this.visit(node.right);
2922 if (this._handlers.onClassSubtractionLeave) {
2923 this._handlers.onClassSubtractionLeave(node);
2924 }
2925 }
2926 visitExpressionCharacterClass(node) {
2927 if (this._handlers.onExpressionCharacterClassEnter) {
2928 this._handlers.onExpressionCharacterClassEnter(node);
2929 }
2930 this.visit(node.expression);
2931 if (this._handlers.onExpressionCharacterClassLeave) {
2932 this._handlers.onExpressionCharacterClassLeave(node);
2933 }
2934 }
2935 visitFlags(node) {
2936 if (this._handlers.onFlagsEnter) {
2937 this._handlers.onFlagsEnter(node);
2938 }
2939 if (this._handlers.onFlagsLeave) {
2940 this._handlers.onFlagsLeave(node);
2941 }
2942 }
2943 visitGroup(node) {
2944 if (this._handlers.onGroupEnter) {
2945 this._handlers.onGroupEnter(node);
2946 }
2947 if (node.modifiers) {
2948 this.visit(node.modifiers);
2949 }
2950 node.alternatives.forEach(this.visit, this);
2951 if (this._handlers.onGroupLeave) {
2952 this._handlers.onGroupLeave(node);
2953 }
2954 }
2955 visitModifiers(node) {
2956 if (this._handlers.onModifiersEnter) {
2957 this._handlers.onModifiersEnter(node);
2958 }
2959 if (node.add) {
2960 this.visit(node.add);
2961 }
2962 if (node.remove) {
2963 this.visit(node.remove);
2964 }
2965 if (this._handlers.onModifiersLeave) {
2966 this._handlers.onModifiersLeave(node);
2967 }
2968 }
2969 visitModifierFlags(node) {
2970 if (this._handlers.onModifierFlagsEnter) {
2971 this._handlers.onModifierFlagsEnter(node);
2972 }
2973 if (this._handlers.onModifierFlagsLeave) {
2974 this._handlers.onModifierFlagsLeave(node);
2975 }
2976 }
2977 visitPattern(node) {
2978 if (this._handlers.onPatternEnter) {
2979 this._handlers.onPatternEnter(node);
2980 }
2981 node.alternatives.forEach(this.visit, this);
2982 if (this._handlers.onPatternLeave) {
2983 this._handlers.onPatternLeave(node);
2984 }
2985 }
2986 visitQuantifier(node) {
2987 if (this._handlers.onQuantifierEnter) {
2988 this._handlers.onQuantifierEnter(node);
2989 }
2990 this.visit(node.element);
2991 if (this._handlers.onQuantifierLeave) {
2992 this._handlers.onQuantifierLeave(node);
2993 }
2994 }
2995 visitRegExpLiteral(node) {
2996 if (this._handlers.onRegExpLiteralEnter) {
2997 this._handlers.onRegExpLiteralEnter(node);
2998 }
2999 this.visitPattern(node.pattern);
3000 this.visitFlags(node.flags);
3001 if (this._handlers.onRegExpLiteralLeave) {
3002 this._handlers.onRegExpLiteralLeave(node);
3003 }
3004 }
3005 visitStringAlternative(node) {
3006 if (this._handlers.onStringAlternativeEnter) {
3007 this._handlers.onStringAlternativeEnter(node);
3008 }
3009 node.elements.forEach(this.visit, this);
3010 if (this._handlers.onStringAlternativeLeave) {
3011 this._handlers.onStringAlternativeLeave(node);
3012 }
3013 }
3014}
3015
3016function parseRegExpLiteral(source, options) {
3017 return new RegExpParser(options).parseLiteral(String(source));
3018}
3019function validateRegExpLiteral(source, options) {
3020 new RegExpValidator(options).validateLiteral(source);
3021}
3022function visitRegExpAST(node, handlers) {
3023 new RegExpVisitor(handlers).visit(node);
3024}
3025
3026export { ast as AST, RegExpParser, RegExpSyntaxError, RegExpValidator, parseRegExpLiteral, validateRegExpLiteral, visitRegExpAST };
3027//# sourceMappingURL=index.mjs.map
Note: See TracBrowser for help on using the repository browser.