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