@eslint-community/regexpp 4.2.0 → 4.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/index.d.ts +9 -0
- package/index.js +254 -235
- package/index.js.map +1 -1
- package/index.mjs +254 -235
- package/index.mjs.map +1 -1
- package/package.json +2 -2
package/index.js
CHANGED
|
@@ -129,105 +129,105 @@ function isValidLoneUnicodeProperty(version, value) {
|
|
|
129
129
|
(version >= 2021 && binPropertySets.es2021.has(value)));
|
|
130
130
|
}
|
|
131
131
|
|
|
132
|
-
const
|
|
133
|
-
const
|
|
134
|
-
const
|
|
135
|
-
const
|
|
136
|
-
const
|
|
137
|
-
const
|
|
138
|
-
const
|
|
139
|
-
const
|
|
140
|
-
const
|
|
141
|
-
const
|
|
142
|
-
const
|
|
143
|
-
const
|
|
144
|
-
const
|
|
145
|
-
const
|
|
146
|
-
const
|
|
147
|
-
const
|
|
148
|
-
const
|
|
149
|
-
const
|
|
150
|
-
const
|
|
151
|
-
const
|
|
152
|
-
const
|
|
153
|
-
const
|
|
154
|
-
const
|
|
155
|
-
const
|
|
156
|
-
const
|
|
157
|
-
const
|
|
158
|
-
const
|
|
159
|
-
const
|
|
160
|
-
const
|
|
161
|
-
const
|
|
162
|
-
const
|
|
163
|
-
const
|
|
164
|
-
const
|
|
165
|
-
const
|
|
166
|
-
const
|
|
167
|
-
const
|
|
168
|
-
const
|
|
169
|
-
const
|
|
170
|
-
const
|
|
171
|
-
const
|
|
172
|
-
const
|
|
173
|
-
const
|
|
174
|
-
const
|
|
175
|
-
const
|
|
176
|
-
const
|
|
177
|
-
const
|
|
178
|
-
const
|
|
179
|
-
const
|
|
180
|
-
const
|
|
181
|
-
const
|
|
182
|
-
const
|
|
183
|
-
const
|
|
184
|
-
const
|
|
185
|
-
const
|
|
186
|
-
const
|
|
187
|
-
const
|
|
188
|
-
const
|
|
189
|
-
const
|
|
190
|
-
const
|
|
191
|
-
const
|
|
192
|
-
const
|
|
193
|
-
const
|
|
194
|
-
const
|
|
195
|
-
const
|
|
196
|
-
const
|
|
197
|
-
const
|
|
198
|
-
const
|
|
132
|
+
const BACKSPACE = 0x08;
|
|
133
|
+
const CHARACTER_TABULATION = 0x09;
|
|
134
|
+
const LINE_FEED = 0x0a;
|
|
135
|
+
const LINE_TABULATION = 0x0b;
|
|
136
|
+
const FORM_FEED = 0x0c;
|
|
137
|
+
const CARRIAGE_RETURN = 0x0d;
|
|
138
|
+
const EXCLAMATION_MARK = 0x21;
|
|
139
|
+
const DOLLAR_SIGN = 0x24;
|
|
140
|
+
const LEFT_PARENTHESIS = 0x28;
|
|
141
|
+
const RIGHT_PARENTHESIS = 0x29;
|
|
142
|
+
const ASTERISK = 0x2a;
|
|
143
|
+
const PLUS_SIGN = 0x2b;
|
|
144
|
+
const COMMA = 0x2c;
|
|
145
|
+
const HYPHEN_MINUS = 0x2d;
|
|
146
|
+
const FULL_STOP = 0x2e;
|
|
147
|
+
const SOLIDUS = 0x2f;
|
|
148
|
+
const DIGIT_ZERO = 0x30;
|
|
149
|
+
const DIGIT_ONE = 0x31;
|
|
150
|
+
const DIGIT_SEVEN = 0x37;
|
|
151
|
+
const DIGIT_NINE = 0x39;
|
|
152
|
+
const COLON = 0x3a;
|
|
153
|
+
const LESS_THAN_SIGN = 0x3c;
|
|
154
|
+
const EQUALS_SIGN = 0x3d;
|
|
155
|
+
const GREATER_THAN_SIGN = 0x3e;
|
|
156
|
+
const QUESTION_MARK = 0x3f;
|
|
157
|
+
const LATIN_CAPITAL_LETTER_A = 0x41;
|
|
158
|
+
const LATIN_CAPITAL_LETTER_B = 0x42;
|
|
159
|
+
const LATIN_CAPITAL_LETTER_D = 0x44;
|
|
160
|
+
const LATIN_CAPITAL_LETTER_F = 0x46;
|
|
161
|
+
const LATIN_CAPITAL_LETTER_P = 0x50;
|
|
162
|
+
const LATIN_CAPITAL_LETTER_S = 0x53;
|
|
163
|
+
const LATIN_CAPITAL_LETTER_W = 0x57;
|
|
164
|
+
const LATIN_CAPITAL_LETTER_Z = 0x5a;
|
|
165
|
+
const LOW_LINE = 0x5f;
|
|
166
|
+
const LATIN_SMALL_LETTER_A = 0x61;
|
|
167
|
+
const LATIN_SMALL_LETTER_B = 0x62;
|
|
168
|
+
const LATIN_SMALL_LETTER_C = 0x63;
|
|
169
|
+
const LATIN_SMALL_LETTER_D = 0x64;
|
|
170
|
+
const LATIN_SMALL_LETTER_F = 0x66;
|
|
171
|
+
const LATIN_SMALL_LETTER_G = 0x67;
|
|
172
|
+
const LATIN_SMALL_LETTER_I = 0x69;
|
|
173
|
+
const LATIN_SMALL_LETTER_K = 0x6b;
|
|
174
|
+
const LATIN_SMALL_LETTER_M = 0x6d;
|
|
175
|
+
const LATIN_SMALL_LETTER_N = 0x6e;
|
|
176
|
+
const LATIN_SMALL_LETTER_P = 0x70;
|
|
177
|
+
const LATIN_SMALL_LETTER_R = 0x72;
|
|
178
|
+
const LATIN_SMALL_LETTER_S = 0x73;
|
|
179
|
+
const LATIN_SMALL_LETTER_T = 0x74;
|
|
180
|
+
const LATIN_SMALL_LETTER_U = 0x75;
|
|
181
|
+
const LATIN_SMALL_LETTER_V = 0x76;
|
|
182
|
+
const LATIN_SMALL_LETTER_W = 0x77;
|
|
183
|
+
const LATIN_SMALL_LETTER_X = 0x78;
|
|
184
|
+
const LATIN_SMALL_LETTER_Y = 0x79;
|
|
185
|
+
const LATIN_SMALL_LETTER_Z = 0x7a;
|
|
186
|
+
const LEFT_SQUARE_BRACKET = 0x5b;
|
|
187
|
+
const REVERSE_SOLIDUS = 0x5c;
|
|
188
|
+
const RIGHT_SQUARE_BRACKET = 0x5d;
|
|
189
|
+
const CIRCUMFLEX_ACCENT = 0x5e;
|
|
190
|
+
const LEFT_CURLY_BRACKET = 0x7b;
|
|
191
|
+
const VERTICAL_LINE = 0x7c;
|
|
192
|
+
const RIGHT_CURLY_BRACKET = 0x7d;
|
|
193
|
+
const ZERO_WIDTH_NON_JOINER = 0x200c;
|
|
194
|
+
const ZERO_WIDTH_JOINER = 0x200d;
|
|
195
|
+
const LINE_SEPARATOR = 0x2028;
|
|
196
|
+
const PARAGRAPH_SEPARATOR = 0x2029;
|
|
197
|
+
const MIN_CODE_POINT = 0x00;
|
|
198
|
+
const MAX_CODE_POINT = 0x10ffff;
|
|
199
199
|
function isLatinLetter(code) {
|
|
200
|
-
return ((code >=
|
|
201
|
-
(code >=
|
|
200
|
+
return ((code >= LATIN_CAPITAL_LETTER_A && code <= LATIN_CAPITAL_LETTER_Z) ||
|
|
201
|
+
(code >= LATIN_SMALL_LETTER_A && code <= LATIN_SMALL_LETTER_Z));
|
|
202
202
|
}
|
|
203
203
|
function isDecimalDigit(code) {
|
|
204
|
-
return code >=
|
|
204
|
+
return code >= DIGIT_ZERO && code <= DIGIT_NINE;
|
|
205
205
|
}
|
|
206
206
|
function isOctalDigit(code) {
|
|
207
|
-
return code >=
|
|
207
|
+
return code >= DIGIT_ZERO && code <= DIGIT_SEVEN;
|
|
208
208
|
}
|
|
209
209
|
function isHexDigit(code) {
|
|
210
|
-
return ((code >=
|
|
211
|
-
(code >=
|
|
212
|
-
(code >=
|
|
210
|
+
return ((code >= DIGIT_ZERO && code <= DIGIT_NINE) ||
|
|
211
|
+
(code >= LATIN_CAPITAL_LETTER_A && code <= LATIN_CAPITAL_LETTER_F) ||
|
|
212
|
+
(code >= LATIN_SMALL_LETTER_A && code <= LATIN_SMALL_LETTER_F));
|
|
213
213
|
}
|
|
214
214
|
function isLineTerminator(code) {
|
|
215
|
-
return (code ===
|
|
216
|
-
code ===
|
|
217
|
-
code ===
|
|
218
|
-
code ===
|
|
215
|
+
return (code === LINE_FEED ||
|
|
216
|
+
code === CARRIAGE_RETURN ||
|
|
217
|
+
code === LINE_SEPARATOR ||
|
|
218
|
+
code === PARAGRAPH_SEPARATOR);
|
|
219
219
|
}
|
|
220
220
|
function isValidUnicode(code) {
|
|
221
|
-
return code >=
|
|
221
|
+
return code >= MIN_CODE_POINT && code <= MAX_CODE_POINT;
|
|
222
222
|
}
|
|
223
223
|
function digitToInt(code) {
|
|
224
|
-
if (code >=
|
|
225
|
-
return code -
|
|
224
|
+
if (code >= LATIN_SMALL_LETTER_A && code <= LATIN_SMALL_LETTER_F) {
|
|
225
|
+
return code - LATIN_SMALL_LETTER_A + 10;
|
|
226
226
|
}
|
|
227
|
-
if (code >=
|
|
228
|
-
return code -
|
|
227
|
+
if (code >= LATIN_CAPITAL_LETTER_A && code <= LATIN_CAPITAL_LETTER_F) {
|
|
228
|
+
return code - LATIN_CAPITAL_LETTER_A + 10;
|
|
229
229
|
}
|
|
230
|
-
return code -
|
|
230
|
+
return code - DIGIT_ZERO;
|
|
231
231
|
}
|
|
232
232
|
function isLeadSurrogate(code) {
|
|
233
233
|
return code >= 0xd800 && code <= 0xdbff;
|
|
@@ -357,33 +357,33 @@ class RegExpSyntaxError extends SyntaxError {
|
|
|
357
357
|
}
|
|
358
358
|
|
|
359
359
|
function isSyntaxCharacter(cp) {
|
|
360
|
-
return (cp ===
|
|
361
|
-
cp ===
|
|
362
|
-
cp ===
|
|
363
|
-
cp ===
|
|
364
|
-
cp ===
|
|
365
|
-
cp ===
|
|
366
|
-
cp ===
|
|
367
|
-
cp ===
|
|
368
|
-
cp ===
|
|
369
|
-
cp ===
|
|
370
|
-
cp ===
|
|
371
|
-
cp ===
|
|
372
|
-
cp ===
|
|
373
|
-
cp ===
|
|
360
|
+
return (cp === CIRCUMFLEX_ACCENT ||
|
|
361
|
+
cp === DOLLAR_SIGN ||
|
|
362
|
+
cp === REVERSE_SOLIDUS ||
|
|
363
|
+
cp === FULL_STOP ||
|
|
364
|
+
cp === ASTERISK ||
|
|
365
|
+
cp === PLUS_SIGN ||
|
|
366
|
+
cp === QUESTION_MARK ||
|
|
367
|
+
cp === LEFT_PARENTHESIS ||
|
|
368
|
+
cp === RIGHT_PARENTHESIS ||
|
|
369
|
+
cp === LEFT_SQUARE_BRACKET ||
|
|
370
|
+
cp === RIGHT_SQUARE_BRACKET ||
|
|
371
|
+
cp === LEFT_CURLY_BRACKET ||
|
|
372
|
+
cp === RIGHT_CURLY_BRACKET ||
|
|
373
|
+
cp === VERTICAL_LINE);
|
|
374
374
|
}
|
|
375
375
|
function isRegExpIdentifierStart(cp) {
|
|
376
|
-
return isIdStart(cp) || cp ===
|
|
376
|
+
return isIdStart(cp) || cp === DOLLAR_SIGN || cp === LOW_LINE;
|
|
377
377
|
}
|
|
378
378
|
function isRegExpIdentifierPart(cp) {
|
|
379
379
|
return (isIdContinue(cp) ||
|
|
380
|
-
cp ===
|
|
381
|
-
cp ===
|
|
382
|
-
cp ===
|
|
383
|
-
cp ===
|
|
380
|
+
cp === DOLLAR_SIGN ||
|
|
381
|
+
cp === LOW_LINE ||
|
|
382
|
+
cp === ZERO_WIDTH_NON_JOINER ||
|
|
383
|
+
cp === ZERO_WIDTH_JOINER);
|
|
384
384
|
}
|
|
385
385
|
function isUnicodePropertyNameCharacter(cp) {
|
|
386
|
-
return isLatinLetter(cp) || cp ===
|
|
386
|
+
return isLatinLetter(cp) || cp === LOW_LINE;
|
|
387
387
|
}
|
|
388
388
|
function isUnicodePropertyValueCharacter(cp) {
|
|
389
389
|
return isUnicodePropertyNameCharacter(cp) || isDecimalDigit(cp);
|
|
@@ -409,7 +409,7 @@ class RegExpValidator {
|
|
|
409
409
|
this._uFlag = this._nFlag = false;
|
|
410
410
|
this.reset(source, start, end);
|
|
411
411
|
this.onLiteralEnter(start);
|
|
412
|
-
if (this.eat(
|
|
412
|
+
if (this.eat(SOLIDUS) && this.eatRegExpBody() && this.eat(SOLIDUS)) {
|
|
413
413
|
const flagStart = this.index;
|
|
414
414
|
const uFlag = source.includes("u", flagStart);
|
|
415
415
|
this.validateFlags(source, flagStart, end);
|
|
@@ -439,32 +439,44 @@ class RegExpValidator {
|
|
|
439
439
|
this.raise(`Duplicated flag '${source[i]}'`);
|
|
440
440
|
}
|
|
441
441
|
existingFlags.add(flag);
|
|
442
|
-
if (flag ===
|
|
442
|
+
if (flag === LATIN_SMALL_LETTER_G) {
|
|
443
443
|
global = true;
|
|
444
444
|
}
|
|
445
|
-
else if (flag ===
|
|
445
|
+
else if (flag === LATIN_SMALL_LETTER_I) {
|
|
446
446
|
ignoreCase = true;
|
|
447
447
|
}
|
|
448
|
-
else if (flag ===
|
|
448
|
+
else if (flag === LATIN_SMALL_LETTER_M) {
|
|
449
449
|
multiline = true;
|
|
450
450
|
}
|
|
451
|
-
else if (flag ===
|
|
451
|
+
else if (flag === LATIN_SMALL_LETTER_U &&
|
|
452
|
+
this.ecmaVersion >= 2015) {
|
|
452
453
|
unicode = true;
|
|
453
454
|
}
|
|
454
|
-
else if (flag ===
|
|
455
|
+
else if (flag === LATIN_SMALL_LETTER_Y &&
|
|
456
|
+
this.ecmaVersion >= 2015) {
|
|
455
457
|
sticky = true;
|
|
456
458
|
}
|
|
457
|
-
else if (flag ===
|
|
459
|
+
else if (flag === LATIN_SMALL_LETTER_S &&
|
|
460
|
+
this.ecmaVersion >= 2018) {
|
|
458
461
|
dotAll = true;
|
|
459
462
|
}
|
|
460
|
-
else if (flag ===
|
|
463
|
+
else if (flag === LATIN_SMALL_LETTER_D &&
|
|
464
|
+
this.ecmaVersion >= 2022) {
|
|
461
465
|
hasIndices = true;
|
|
462
466
|
}
|
|
463
467
|
else {
|
|
464
468
|
this.raise(`Invalid flag '${source[i]}'`);
|
|
465
469
|
}
|
|
466
470
|
}
|
|
467
|
-
this.
|
|
471
|
+
this.onRegExpFlags(start, end, {
|
|
472
|
+
global,
|
|
473
|
+
ignoreCase,
|
|
474
|
+
multiline,
|
|
475
|
+
unicode,
|
|
476
|
+
sticky,
|
|
477
|
+
dotAll,
|
|
478
|
+
hasIndices,
|
|
479
|
+
});
|
|
468
480
|
}
|
|
469
481
|
validatePattern(source, start = 0, end = source.length, uFlag = false) {
|
|
470
482
|
this._uFlag = uFlag && this.ecmaVersion >= 2015;
|
|
@@ -496,9 +508,12 @@ class RegExpValidator {
|
|
|
496
508
|
this._options.onLiteralLeave(start, end);
|
|
497
509
|
}
|
|
498
510
|
}
|
|
499
|
-
|
|
511
|
+
onRegExpFlags(start, end, flags) {
|
|
512
|
+
if (this._options.onRegExpFlags) {
|
|
513
|
+
this._options.onRegExpFlags(start, end, flags);
|
|
514
|
+
}
|
|
500
515
|
if (this._options.onFlags) {
|
|
501
|
-
this._options.onFlags(start, end, global, ignoreCase, multiline, unicode, sticky, dotAll, hasIndices);
|
|
516
|
+
this._options.onFlags(start, end, flags.global, flags.ignoreCase, flags.multiline, flags.unicode, flags.sticky, flags.dotAll, flags.hasIndices);
|
|
502
517
|
}
|
|
503
518
|
}
|
|
504
519
|
onPatternEnter(start) {
|
|
@@ -668,17 +683,17 @@ class RegExpValidator {
|
|
|
668
683
|
if (escaped) {
|
|
669
684
|
escaped = false;
|
|
670
685
|
}
|
|
671
|
-
else if (cp ===
|
|
686
|
+
else if (cp === REVERSE_SOLIDUS) {
|
|
672
687
|
escaped = true;
|
|
673
688
|
}
|
|
674
|
-
else if (cp ===
|
|
689
|
+
else if (cp === LEFT_SQUARE_BRACKET) {
|
|
675
690
|
inClass = true;
|
|
676
691
|
}
|
|
677
|
-
else if (cp ===
|
|
692
|
+
else if (cp === RIGHT_SQUARE_BRACKET) {
|
|
678
693
|
inClass = false;
|
|
679
694
|
}
|
|
680
|
-
else if ((cp ===
|
|
681
|
-
(cp ===
|
|
695
|
+
else if ((cp === SOLIDUS && !inClass) ||
|
|
696
|
+
(cp === ASTERISK && this.index === start)) {
|
|
682
697
|
break;
|
|
683
698
|
}
|
|
684
699
|
this.advance();
|
|
@@ -694,13 +709,13 @@ class RegExpValidator {
|
|
|
694
709
|
this.consumeDisjunction();
|
|
695
710
|
const cp = this.currentCodePoint;
|
|
696
711
|
if (this.currentCodePoint !== -1) {
|
|
697
|
-
if (cp ===
|
|
712
|
+
if (cp === RIGHT_PARENTHESIS) {
|
|
698
713
|
this.raise("Unmatched ')'");
|
|
699
714
|
}
|
|
700
|
-
if (cp ===
|
|
715
|
+
if (cp === REVERSE_SOLIDUS) {
|
|
701
716
|
this.raise("\\ at end of pattern");
|
|
702
717
|
}
|
|
703
|
-
if (cp ===
|
|
718
|
+
if (cp === RIGHT_SQUARE_BRACKET || cp === RIGHT_CURLY_BRACKET) {
|
|
704
719
|
this.raise("Lone quantifier brackets");
|
|
705
720
|
}
|
|
706
721
|
const c = String.fromCodePoint(cp);
|
|
@@ -723,21 +738,21 @@ class RegExpValidator {
|
|
|
723
738
|
if (escaped) {
|
|
724
739
|
escaped = false;
|
|
725
740
|
}
|
|
726
|
-
else if (cp ===
|
|
741
|
+
else if (cp === REVERSE_SOLIDUS) {
|
|
727
742
|
escaped = true;
|
|
728
743
|
}
|
|
729
|
-
else if (cp ===
|
|
744
|
+
else if (cp === LEFT_SQUARE_BRACKET) {
|
|
730
745
|
inClass = true;
|
|
731
746
|
}
|
|
732
|
-
else if (cp ===
|
|
747
|
+
else if (cp === RIGHT_SQUARE_BRACKET) {
|
|
733
748
|
inClass = false;
|
|
734
749
|
}
|
|
735
|
-
else if (cp ===
|
|
750
|
+
else if (cp === LEFT_PARENTHESIS &&
|
|
736
751
|
!inClass &&
|
|
737
|
-
(this.nextCodePoint !==
|
|
738
|
-
(this.nextCodePoint2 ===
|
|
739
|
-
this.nextCodePoint3 !==
|
|
740
|
-
this.nextCodePoint3 !==
|
|
752
|
+
(this.nextCodePoint !== QUESTION_MARK ||
|
|
753
|
+
(this.nextCodePoint2 === LESS_THAN_SIGN &&
|
|
754
|
+
this.nextCodePoint3 !== EQUALS_SIGN &&
|
|
755
|
+
this.nextCodePoint3 !== EXCLAMATION_MARK))) {
|
|
741
756
|
count += 1;
|
|
742
757
|
}
|
|
743
758
|
this.advance();
|
|
@@ -751,11 +766,11 @@ class RegExpValidator {
|
|
|
751
766
|
this.onDisjunctionEnter(start);
|
|
752
767
|
do {
|
|
753
768
|
this.consumeAlternative(i++);
|
|
754
|
-
} while (this.eat(
|
|
769
|
+
} while (this.eat(VERTICAL_LINE));
|
|
755
770
|
if (this.consumeQuantifier(true)) {
|
|
756
771
|
this.raise("Nothing to repeat");
|
|
757
772
|
}
|
|
758
|
-
if (this.eat(
|
|
773
|
+
if (this.eat(LEFT_CURLY_BRACKET)) {
|
|
759
774
|
this.raise("Lone quantifier brackets");
|
|
760
775
|
}
|
|
761
776
|
this.onDisjunctionLeave(start, this.index);
|
|
@@ -784,30 +799,31 @@ class RegExpValidator {
|
|
|
784
799
|
consumeAssertion() {
|
|
785
800
|
const start = this.index;
|
|
786
801
|
this._lastAssertionIsQuantifiable = false;
|
|
787
|
-
if (this.eat(
|
|
802
|
+
if (this.eat(CIRCUMFLEX_ACCENT)) {
|
|
788
803
|
this.onEdgeAssertion(start, this.index, "start");
|
|
789
804
|
return true;
|
|
790
805
|
}
|
|
791
|
-
if (this.eat(
|
|
806
|
+
if (this.eat(DOLLAR_SIGN)) {
|
|
792
807
|
this.onEdgeAssertion(start, this.index, "end");
|
|
793
808
|
return true;
|
|
794
809
|
}
|
|
795
|
-
if (this.eat2(
|
|
810
|
+
if (this.eat2(REVERSE_SOLIDUS, LATIN_CAPITAL_LETTER_B)) {
|
|
796
811
|
this.onWordBoundaryAssertion(start, this.index, "word", true);
|
|
797
812
|
return true;
|
|
798
813
|
}
|
|
799
|
-
if (this.eat2(
|
|
814
|
+
if (this.eat2(REVERSE_SOLIDUS, LATIN_SMALL_LETTER_B)) {
|
|
800
815
|
this.onWordBoundaryAssertion(start, this.index, "word", false);
|
|
801
816
|
return true;
|
|
802
817
|
}
|
|
803
|
-
if (this.eat2(
|
|
804
|
-
const lookbehind = this.ecmaVersion >= 2018 && this.eat(
|
|
818
|
+
if (this.eat2(LEFT_PARENTHESIS, QUESTION_MARK)) {
|
|
819
|
+
const lookbehind = this.ecmaVersion >= 2018 && this.eat(LESS_THAN_SIGN);
|
|
805
820
|
let negate = false;
|
|
806
|
-
if (this.eat(
|
|
821
|
+
if (this.eat(EQUALS_SIGN) ||
|
|
822
|
+
(negate = this.eat(EXCLAMATION_MARK))) {
|
|
807
823
|
const kind = lookbehind ? "lookbehind" : "lookahead";
|
|
808
824
|
this.onLookaroundAssertionEnter(start, kind, negate);
|
|
809
825
|
this.consumeDisjunction();
|
|
810
|
-
if (!this.eat(
|
|
826
|
+
if (!this.eat(RIGHT_PARENTHESIS)) {
|
|
811
827
|
this.raise("Unterminated group");
|
|
812
828
|
}
|
|
813
829
|
this._lastAssertionIsQuantifiable = !lookbehind && !this.strict;
|
|
@@ -823,15 +839,15 @@ class RegExpValidator {
|
|
|
823
839
|
let min = 0;
|
|
824
840
|
let max = 0;
|
|
825
841
|
let greedy = false;
|
|
826
|
-
if (this.eat(
|
|
842
|
+
if (this.eat(ASTERISK)) {
|
|
827
843
|
min = 0;
|
|
828
844
|
max = Number.POSITIVE_INFINITY;
|
|
829
845
|
}
|
|
830
|
-
else if (this.eat(
|
|
846
|
+
else if (this.eat(PLUS_SIGN)) {
|
|
831
847
|
min = 1;
|
|
832
848
|
max = Number.POSITIVE_INFINITY;
|
|
833
849
|
}
|
|
834
|
-
else if (this.eat(
|
|
850
|
+
else if (this.eat(QUESTION_MARK)) {
|
|
835
851
|
min = 0;
|
|
836
852
|
max = 1;
|
|
837
853
|
}
|
|
@@ -842,7 +858,7 @@ class RegExpValidator {
|
|
|
842
858
|
else {
|
|
843
859
|
return false;
|
|
844
860
|
}
|
|
845
|
-
greedy = !this.eat(
|
|
861
|
+
greedy = !this.eat(QUESTION_MARK);
|
|
846
862
|
if (!noConsume) {
|
|
847
863
|
this.onQuantifier(start, this.index, min, max, greedy);
|
|
848
864
|
}
|
|
@@ -850,17 +866,17 @@ class RegExpValidator {
|
|
|
850
866
|
}
|
|
851
867
|
eatBracedQuantifier(noError) {
|
|
852
868
|
const start = this.index;
|
|
853
|
-
if (this.eat(
|
|
869
|
+
if (this.eat(LEFT_CURLY_BRACKET)) {
|
|
854
870
|
this._lastMinValue = 0;
|
|
855
871
|
this._lastMaxValue = Number.POSITIVE_INFINITY;
|
|
856
872
|
if (this.eatDecimalDigits()) {
|
|
857
873
|
this._lastMinValue = this._lastMaxValue = this._lastIntValue;
|
|
858
|
-
if (this.eat(
|
|
874
|
+
if (this.eat(COMMA)) {
|
|
859
875
|
this._lastMaxValue = this.eatDecimalDigits()
|
|
860
876
|
? this._lastIntValue
|
|
861
877
|
: Number.POSITIVE_INFINITY;
|
|
862
878
|
}
|
|
863
|
-
if (this.eat(
|
|
879
|
+
if (this.eat(RIGHT_CURLY_BRACKET)) {
|
|
864
880
|
if (!noError && this._lastMaxValue < this._lastMinValue) {
|
|
865
881
|
this.raise("numbers out of order in {} quantifier");
|
|
866
882
|
}
|
|
@@ -883,7 +899,7 @@ class RegExpValidator {
|
|
|
883
899
|
this.consumeCapturingGroup());
|
|
884
900
|
}
|
|
885
901
|
consumeDot() {
|
|
886
|
-
if (this.eat(
|
|
902
|
+
if (this.eat(FULL_STOP)) {
|
|
887
903
|
this.onAnyCharacterSet(this.index - 1, this.index, "any");
|
|
888
904
|
return true;
|
|
889
905
|
}
|
|
@@ -891,7 +907,7 @@ class RegExpValidator {
|
|
|
891
907
|
}
|
|
892
908
|
consumeReverseSolidusAtomEscape() {
|
|
893
909
|
const start = this.index;
|
|
894
|
-
if (this.eat(
|
|
910
|
+
if (this.eat(REVERSE_SOLIDUS)) {
|
|
895
911
|
if (this.consumeAtomEscape()) {
|
|
896
912
|
return true;
|
|
897
913
|
}
|
|
@@ -901,10 +917,10 @@ class RegExpValidator {
|
|
|
901
917
|
}
|
|
902
918
|
consumeUncapturingGroup() {
|
|
903
919
|
const start = this.index;
|
|
904
|
-
if (this.eat3(
|
|
920
|
+
if (this.eat3(LEFT_PARENTHESIS, QUESTION_MARK, COLON)) {
|
|
905
921
|
this.onGroupEnter(start);
|
|
906
922
|
this.consumeDisjunction();
|
|
907
|
-
if (!this.eat(
|
|
923
|
+
if (!this.eat(RIGHT_PARENTHESIS)) {
|
|
908
924
|
this.raise("Unterminated group");
|
|
909
925
|
}
|
|
910
926
|
this.onGroupLeave(start, this.index);
|
|
@@ -914,19 +930,19 @@ class RegExpValidator {
|
|
|
914
930
|
}
|
|
915
931
|
consumeCapturingGroup() {
|
|
916
932
|
const start = this.index;
|
|
917
|
-
if (this.eat(
|
|
933
|
+
if (this.eat(LEFT_PARENTHESIS)) {
|
|
918
934
|
let name = null;
|
|
919
935
|
if (this.ecmaVersion >= 2018) {
|
|
920
936
|
if (this.consumeGroupSpecifier()) {
|
|
921
937
|
name = this._lastStrValue;
|
|
922
938
|
}
|
|
923
939
|
}
|
|
924
|
-
else if (this.currentCodePoint ===
|
|
940
|
+
else if (this.currentCodePoint === QUESTION_MARK) {
|
|
925
941
|
this.raise("Invalid group");
|
|
926
942
|
}
|
|
927
943
|
this.onCapturingGroupEnter(start, name);
|
|
928
944
|
this.consumeDisjunction();
|
|
929
|
-
if (!this.eat(
|
|
945
|
+
if (!this.eat(RIGHT_PARENTHESIS)) {
|
|
930
946
|
this.raise("Unterminated group");
|
|
931
947
|
}
|
|
932
948
|
this.onCapturingGroupLeave(start, this.index, name);
|
|
@@ -946,11 +962,11 @@ class RegExpValidator {
|
|
|
946
962
|
}
|
|
947
963
|
consumeReverseSolidusFollowedByC() {
|
|
948
964
|
const start = this.index;
|
|
949
|
-
if (this.currentCodePoint ===
|
|
950
|
-
this.nextCodePoint ===
|
|
965
|
+
if (this.currentCodePoint === REVERSE_SOLIDUS &&
|
|
966
|
+
this.nextCodePoint === LATIN_SMALL_LETTER_C) {
|
|
951
967
|
this._lastIntValue = this.currentCodePoint;
|
|
952
968
|
this.advance();
|
|
953
|
-
this.onCharacter(start, this.index,
|
|
969
|
+
this.onCharacter(start, this.index, REVERSE_SOLIDUS);
|
|
954
970
|
return true;
|
|
955
971
|
}
|
|
956
972
|
return false;
|
|
@@ -975,17 +991,17 @@ class RegExpValidator {
|
|
|
975
991
|
const start = this.index;
|
|
976
992
|
const cp = this.currentCodePoint;
|
|
977
993
|
if (cp !== -1 &&
|
|
978
|
-
cp !==
|
|
979
|
-
cp !==
|
|
980
|
-
cp !==
|
|
981
|
-
cp !==
|
|
982
|
-
cp !==
|
|
983
|
-
cp !==
|
|
984
|
-
cp !==
|
|
985
|
-
cp !==
|
|
986
|
-
cp !==
|
|
987
|
-
cp !==
|
|
988
|
-
cp !==
|
|
994
|
+
cp !== CIRCUMFLEX_ACCENT &&
|
|
995
|
+
cp !== DOLLAR_SIGN &&
|
|
996
|
+
cp !== REVERSE_SOLIDUS &&
|
|
997
|
+
cp !== FULL_STOP &&
|
|
998
|
+
cp !== ASTERISK &&
|
|
999
|
+
cp !== PLUS_SIGN &&
|
|
1000
|
+
cp !== QUESTION_MARK &&
|
|
1001
|
+
cp !== LEFT_PARENTHESIS &&
|
|
1002
|
+
cp !== RIGHT_PARENTHESIS &&
|
|
1003
|
+
cp !== LEFT_SQUARE_BRACKET &&
|
|
1004
|
+
cp !== VERTICAL_LINE) {
|
|
989
1005
|
this.advance();
|
|
990
1006
|
this.onCharacter(start, this.index, cp);
|
|
991
1007
|
return true;
|
|
@@ -993,7 +1009,7 @@ class RegExpValidator {
|
|
|
993
1009
|
return false;
|
|
994
1010
|
}
|
|
995
1011
|
consumeGroupSpecifier() {
|
|
996
|
-
if (this.eat(
|
|
1012
|
+
if (this.eat(QUESTION_MARK)) {
|
|
997
1013
|
if (this.eatGroupName()) {
|
|
998
1014
|
if (!this._groupNames.has(this._lastStrValue)) {
|
|
999
1015
|
this._groupNames.add(this._lastStrValue);
|
|
@@ -1034,32 +1050,32 @@ class RegExpValidator {
|
|
|
1034
1050
|
}
|
|
1035
1051
|
consumeCharacterClassEscape() {
|
|
1036
1052
|
const start = this.index;
|
|
1037
|
-
if (this.eat(
|
|
1053
|
+
if (this.eat(LATIN_SMALL_LETTER_D)) {
|
|
1038
1054
|
this._lastIntValue = -1;
|
|
1039
1055
|
this.onEscapeCharacterSet(start - 1, this.index, "digit", false);
|
|
1040
1056
|
return true;
|
|
1041
1057
|
}
|
|
1042
|
-
if (this.eat(
|
|
1058
|
+
if (this.eat(LATIN_CAPITAL_LETTER_D)) {
|
|
1043
1059
|
this._lastIntValue = -1;
|
|
1044
1060
|
this.onEscapeCharacterSet(start - 1, this.index, "digit", true);
|
|
1045
1061
|
return true;
|
|
1046
1062
|
}
|
|
1047
|
-
if (this.eat(
|
|
1063
|
+
if (this.eat(LATIN_SMALL_LETTER_S)) {
|
|
1048
1064
|
this._lastIntValue = -1;
|
|
1049
1065
|
this.onEscapeCharacterSet(start - 1, this.index, "space", false);
|
|
1050
1066
|
return true;
|
|
1051
1067
|
}
|
|
1052
|
-
if (this.eat(
|
|
1068
|
+
if (this.eat(LATIN_CAPITAL_LETTER_S)) {
|
|
1053
1069
|
this._lastIntValue = -1;
|
|
1054
1070
|
this.onEscapeCharacterSet(start - 1, this.index, "space", true);
|
|
1055
1071
|
return true;
|
|
1056
1072
|
}
|
|
1057
|
-
if (this.eat(
|
|
1073
|
+
if (this.eat(LATIN_SMALL_LETTER_W)) {
|
|
1058
1074
|
this._lastIntValue = -1;
|
|
1059
1075
|
this.onEscapeCharacterSet(start - 1, this.index, "word", false);
|
|
1060
1076
|
return true;
|
|
1061
1077
|
}
|
|
1062
|
-
if (this.eat(
|
|
1078
|
+
if (this.eat(LATIN_CAPITAL_LETTER_W)) {
|
|
1063
1079
|
this._lastIntValue = -1;
|
|
1064
1080
|
this.onEscapeCharacterSet(start - 1, this.index, "word", true);
|
|
1065
1081
|
return true;
|
|
@@ -1067,12 +1083,12 @@ class RegExpValidator {
|
|
|
1067
1083
|
let negate = false;
|
|
1068
1084
|
if (this._uFlag &&
|
|
1069
1085
|
this.ecmaVersion >= 2018 &&
|
|
1070
|
-
(this.eat(
|
|
1071
|
-
(negate = this.eat(
|
|
1086
|
+
(this.eat(LATIN_SMALL_LETTER_P) ||
|
|
1087
|
+
(negate = this.eat(LATIN_CAPITAL_LETTER_P)))) {
|
|
1072
1088
|
this._lastIntValue = -1;
|
|
1073
|
-
if (this.eat(
|
|
1089
|
+
if (this.eat(LEFT_CURLY_BRACKET) &&
|
|
1074
1090
|
this.eatUnicodePropertyValueExpression() &&
|
|
1075
|
-
this.eat(
|
|
1091
|
+
this.eat(RIGHT_CURLY_BRACKET)) {
|
|
1076
1092
|
this.onUnicodePropertyCharacterSet(start - 1, this.index, "property", this._lastKeyValue, this._lastValValue || null, negate);
|
|
1077
1093
|
return true;
|
|
1078
1094
|
}
|
|
@@ -1098,7 +1114,7 @@ class RegExpValidator {
|
|
|
1098
1114
|
}
|
|
1099
1115
|
consumeKGroupName() {
|
|
1100
1116
|
const start = this.index;
|
|
1101
|
-
if (this.eat(
|
|
1117
|
+
if (this.eat(LATIN_SMALL_LETTER_K)) {
|
|
1102
1118
|
if (this.eatGroupName()) {
|
|
1103
1119
|
const groupName = this._lastStrValue;
|
|
1104
1120
|
this._backreferenceNames.add(groupName);
|
|
@@ -1111,11 +1127,11 @@ class RegExpValidator {
|
|
|
1111
1127
|
}
|
|
1112
1128
|
consumeCharacterClass() {
|
|
1113
1129
|
const start = this.index;
|
|
1114
|
-
if (this.eat(
|
|
1115
|
-
const negate = this.eat(
|
|
1130
|
+
if (this.eat(LEFT_SQUARE_BRACKET)) {
|
|
1131
|
+
const negate = this.eat(CIRCUMFLEX_ACCENT);
|
|
1116
1132
|
this.onCharacterClassEnter(start, negate);
|
|
1117
1133
|
this.consumeClassRanges();
|
|
1118
|
-
if (!this.eat(
|
|
1134
|
+
if (!this.eat(RIGHT_SQUARE_BRACKET)) {
|
|
1119
1135
|
this.raise("Unterminated character class");
|
|
1120
1136
|
}
|
|
1121
1137
|
this.onCharacterClassLeave(start, this.index, negate);
|
|
@@ -1131,10 +1147,10 @@ class RegExpValidator {
|
|
|
1131
1147
|
break;
|
|
1132
1148
|
}
|
|
1133
1149
|
const min = this._lastIntValue;
|
|
1134
|
-
if (!this.eat(
|
|
1150
|
+
if (!this.eat(HYPHEN_MINUS)) {
|
|
1135
1151
|
continue;
|
|
1136
1152
|
}
|
|
1137
|
-
this.onCharacter(this.index - 1, this.index,
|
|
1153
|
+
this.onCharacter(this.index - 1, this.index, HYPHEN_MINUS);
|
|
1138
1154
|
if (!this.consumeClassAtom()) {
|
|
1139
1155
|
break;
|
|
1140
1156
|
}
|
|
@@ -1154,18 +1170,21 @@ class RegExpValidator {
|
|
|
1154
1170
|
consumeClassAtom() {
|
|
1155
1171
|
const start = this.index;
|
|
1156
1172
|
const cp = this.currentCodePoint;
|
|
1157
|
-
if (cp !== -1 &&
|
|
1173
|
+
if (cp !== -1 &&
|
|
1174
|
+
cp !== REVERSE_SOLIDUS &&
|
|
1175
|
+
cp !== RIGHT_SQUARE_BRACKET) {
|
|
1158
1176
|
this.advance();
|
|
1159
1177
|
this._lastIntValue = cp;
|
|
1160
1178
|
this.onCharacter(start, this.index, this._lastIntValue);
|
|
1161
1179
|
return true;
|
|
1162
1180
|
}
|
|
1163
|
-
if (this.eat(
|
|
1181
|
+
if (this.eat(REVERSE_SOLIDUS)) {
|
|
1164
1182
|
if (this.consumeClassEscape()) {
|
|
1165
1183
|
return true;
|
|
1166
1184
|
}
|
|
1167
|
-
if (!this.strict &&
|
|
1168
|
-
this.
|
|
1185
|
+
if (!this.strict &&
|
|
1186
|
+
this.currentCodePoint === LATIN_SMALL_LETTER_C) {
|
|
1187
|
+
this._lastIntValue = REVERSE_SOLIDUS;
|
|
1169
1188
|
this.onCharacter(start, this.index, this._lastIntValue);
|
|
1170
1189
|
return true;
|
|
1171
1190
|
}
|
|
@@ -1178,21 +1197,21 @@ class RegExpValidator {
|
|
|
1178
1197
|
}
|
|
1179
1198
|
consumeClassEscape() {
|
|
1180
1199
|
const start = this.index;
|
|
1181
|
-
if (this.eat(
|
|
1182
|
-
this._lastIntValue =
|
|
1200
|
+
if (this.eat(LATIN_SMALL_LETTER_B)) {
|
|
1201
|
+
this._lastIntValue = BACKSPACE;
|
|
1183
1202
|
this.onCharacter(start - 1, this.index, this._lastIntValue);
|
|
1184
1203
|
return true;
|
|
1185
1204
|
}
|
|
1186
|
-
if (this._uFlag && this.eat(
|
|
1187
|
-
this._lastIntValue =
|
|
1205
|
+
if (this._uFlag && this.eat(HYPHEN_MINUS)) {
|
|
1206
|
+
this._lastIntValue = HYPHEN_MINUS;
|
|
1188
1207
|
this.onCharacter(start - 1, this.index, this._lastIntValue);
|
|
1189
1208
|
return true;
|
|
1190
1209
|
}
|
|
1191
1210
|
let cp = 0;
|
|
1192
1211
|
if (!this.strict &&
|
|
1193
1212
|
!this._uFlag &&
|
|
1194
|
-
this.currentCodePoint ===
|
|
1195
|
-
(isDecimalDigit((cp = this.nextCodePoint)) || cp ===
|
|
1213
|
+
this.currentCodePoint === LATIN_SMALL_LETTER_C &&
|
|
1214
|
+
(isDecimalDigit((cp = this.nextCodePoint)) || cp === LOW_LINE)) {
|
|
1196
1215
|
this.advance();
|
|
1197
1216
|
this.advance();
|
|
1198
1217
|
this._lastIntValue = cp % 0x20;
|
|
@@ -1202,8 +1221,8 @@ class RegExpValidator {
|
|
|
1202
1221
|
return (this.consumeCharacterClassEscape() || this.consumeCharacterEscape());
|
|
1203
1222
|
}
|
|
1204
1223
|
eatGroupName() {
|
|
1205
|
-
if (this.eat(
|
|
1206
|
-
if (this.eatRegExpIdentifierName() && this.eat(
|
|
1224
|
+
if (this.eat(LESS_THAN_SIGN)) {
|
|
1225
|
+
if (this.eatRegExpIdentifierName() && this.eat(GREATER_THAN_SIGN)) {
|
|
1207
1226
|
return true;
|
|
1208
1227
|
}
|
|
1209
1228
|
this.raise("Invalid capture group name");
|
|
@@ -1225,7 +1244,7 @@ class RegExpValidator {
|
|
|
1225
1244
|
const forceUFlag = !this._uFlag && this.ecmaVersion >= 2020;
|
|
1226
1245
|
let cp = this.currentCodePoint;
|
|
1227
1246
|
this.advance();
|
|
1228
|
-
if (cp ===
|
|
1247
|
+
if (cp === REVERSE_SOLIDUS &&
|
|
1229
1248
|
this.eatRegExpUnicodeEscapeSequence(forceUFlag)) {
|
|
1230
1249
|
cp = this._lastIntValue;
|
|
1231
1250
|
}
|
|
@@ -1249,7 +1268,7 @@ class RegExpValidator {
|
|
|
1249
1268
|
const forceUFlag = !this._uFlag && this.ecmaVersion >= 2020;
|
|
1250
1269
|
let cp = this.currentCodePoint;
|
|
1251
1270
|
this.advance();
|
|
1252
|
-
if (cp ===
|
|
1271
|
+
if (cp === REVERSE_SOLIDUS &&
|
|
1253
1272
|
this.eatRegExpUnicodeEscapeSequence(forceUFlag)) {
|
|
1254
1273
|
cp = this._lastIntValue;
|
|
1255
1274
|
}
|
|
@@ -1270,7 +1289,7 @@ class RegExpValidator {
|
|
|
1270
1289
|
}
|
|
1271
1290
|
eatCControlLetter() {
|
|
1272
1291
|
const start = this.index;
|
|
1273
|
-
if (this.eat(
|
|
1292
|
+
if (this.eat(LATIN_SMALL_LETTER_C)) {
|
|
1274
1293
|
if (this.eatControlLetter()) {
|
|
1275
1294
|
return true;
|
|
1276
1295
|
}
|
|
@@ -1279,7 +1298,7 @@ class RegExpValidator {
|
|
|
1279
1298
|
return false;
|
|
1280
1299
|
}
|
|
1281
1300
|
eatZero() {
|
|
1282
|
-
if (this.currentCodePoint ===
|
|
1301
|
+
if (this.currentCodePoint === DIGIT_ZERO &&
|
|
1283
1302
|
!isDecimalDigit(this.nextCodePoint)) {
|
|
1284
1303
|
this._lastIntValue = 0;
|
|
1285
1304
|
this.advance();
|
|
@@ -1288,24 +1307,24 @@ class RegExpValidator {
|
|
|
1288
1307
|
return false;
|
|
1289
1308
|
}
|
|
1290
1309
|
eatControlEscape() {
|
|
1291
|
-
if (this.eat(
|
|
1292
|
-
this._lastIntValue =
|
|
1310
|
+
if (this.eat(LATIN_SMALL_LETTER_F)) {
|
|
1311
|
+
this._lastIntValue = FORM_FEED;
|
|
1293
1312
|
return true;
|
|
1294
1313
|
}
|
|
1295
|
-
if (this.eat(
|
|
1296
|
-
this._lastIntValue =
|
|
1314
|
+
if (this.eat(LATIN_SMALL_LETTER_N)) {
|
|
1315
|
+
this._lastIntValue = LINE_FEED;
|
|
1297
1316
|
return true;
|
|
1298
1317
|
}
|
|
1299
|
-
if (this.eat(
|
|
1300
|
-
this._lastIntValue =
|
|
1318
|
+
if (this.eat(LATIN_SMALL_LETTER_R)) {
|
|
1319
|
+
this._lastIntValue = CARRIAGE_RETURN;
|
|
1301
1320
|
return true;
|
|
1302
1321
|
}
|
|
1303
|
-
if (this.eat(
|
|
1304
|
-
this._lastIntValue =
|
|
1322
|
+
if (this.eat(LATIN_SMALL_LETTER_T)) {
|
|
1323
|
+
this._lastIntValue = CHARACTER_TABULATION;
|
|
1305
1324
|
return true;
|
|
1306
1325
|
}
|
|
1307
|
-
if (this.eat(
|
|
1308
|
-
this._lastIntValue =
|
|
1326
|
+
if (this.eat(LATIN_SMALL_LETTER_V)) {
|
|
1327
|
+
this._lastIntValue = LINE_TABULATION;
|
|
1309
1328
|
return true;
|
|
1310
1329
|
}
|
|
1311
1330
|
return false;
|
|
@@ -1322,7 +1341,7 @@ class RegExpValidator {
|
|
|
1322
1341
|
eatRegExpUnicodeEscapeSequence(forceUFlag = false) {
|
|
1323
1342
|
const start = this.index;
|
|
1324
1343
|
const uFlag = forceUFlag || this._uFlag;
|
|
1325
|
-
if (this.eat(
|
|
1344
|
+
if (this.eat(LATIN_SMALL_LETTER_U)) {
|
|
1326
1345
|
if ((uFlag && this.eatRegExpUnicodeSurrogatePairEscape()) ||
|
|
1327
1346
|
this.eatFixedHexDigits(4) ||
|
|
1328
1347
|
(uFlag && this.eatRegExpUnicodeCodePointEscape())) {
|
|
@@ -1340,8 +1359,8 @@ class RegExpValidator {
|
|
|
1340
1359
|
if (this.eatFixedHexDigits(4)) {
|
|
1341
1360
|
const lead = this._lastIntValue;
|
|
1342
1361
|
if (isLeadSurrogate(lead) &&
|
|
1343
|
-
this.eat(
|
|
1344
|
-
this.eat(
|
|
1362
|
+
this.eat(REVERSE_SOLIDUS) &&
|
|
1363
|
+
this.eat(LATIN_SMALL_LETTER_U) &&
|
|
1345
1364
|
this.eatFixedHexDigits(4)) {
|
|
1346
1365
|
const trail = this._lastIntValue;
|
|
1347
1366
|
if (isTrailSurrogate(trail)) {
|
|
@@ -1355,9 +1374,9 @@ class RegExpValidator {
|
|
|
1355
1374
|
}
|
|
1356
1375
|
eatRegExpUnicodeCodePointEscape() {
|
|
1357
1376
|
const start = this.index;
|
|
1358
|
-
if (this.eat(
|
|
1377
|
+
if (this.eat(LEFT_CURLY_BRACKET) &&
|
|
1359
1378
|
this.eatHexDigits() &&
|
|
1360
|
-
this.eat(
|
|
1379
|
+
this.eat(RIGHT_CURLY_BRACKET) &&
|
|
1361
1380
|
isValidUnicode(this._lastIntValue)) {
|
|
1362
1381
|
return true;
|
|
1363
1382
|
}
|
|
@@ -1378,32 +1397,32 @@ class RegExpValidator {
|
|
|
1378
1397
|
return false;
|
|
1379
1398
|
}
|
|
1380
1399
|
if (this._uFlag) {
|
|
1381
|
-
return isSyntaxCharacter(cp) || cp ===
|
|
1400
|
+
return isSyntaxCharacter(cp) || cp === SOLIDUS;
|
|
1382
1401
|
}
|
|
1383
1402
|
if (this.strict) {
|
|
1384
1403
|
return !isIdContinue(cp);
|
|
1385
1404
|
}
|
|
1386
1405
|
if (this._nFlag) {
|
|
1387
|
-
return !(cp ===
|
|
1406
|
+
return !(cp === LATIN_SMALL_LETTER_C || cp === LATIN_SMALL_LETTER_K);
|
|
1388
1407
|
}
|
|
1389
|
-
return cp !==
|
|
1408
|
+
return cp !== LATIN_SMALL_LETTER_C;
|
|
1390
1409
|
}
|
|
1391
1410
|
eatDecimalEscape() {
|
|
1392
1411
|
this._lastIntValue = 0;
|
|
1393
1412
|
let cp = this.currentCodePoint;
|
|
1394
|
-
if (cp >=
|
|
1413
|
+
if (cp >= DIGIT_ONE && cp <= DIGIT_NINE) {
|
|
1395
1414
|
do {
|
|
1396
|
-
this._lastIntValue = 10 * this._lastIntValue + (cp -
|
|
1415
|
+
this._lastIntValue = 10 * this._lastIntValue + (cp - DIGIT_ZERO);
|
|
1397
1416
|
this.advance();
|
|
1398
|
-
} while ((cp = this.currentCodePoint) >=
|
|
1399
|
-
cp <=
|
|
1417
|
+
} while ((cp = this.currentCodePoint) >= DIGIT_ZERO &&
|
|
1418
|
+
cp <= DIGIT_NINE);
|
|
1400
1419
|
return true;
|
|
1401
1420
|
}
|
|
1402
1421
|
return false;
|
|
1403
1422
|
}
|
|
1404
1423
|
eatUnicodePropertyValueExpression() {
|
|
1405
1424
|
const start = this.index;
|
|
1406
|
-
if (this.eatUnicodePropertyName() && this.eat(
|
|
1425
|
+
if (this.eatUnicodePropertyName() && this.eat(EQUALS_SIGN)) {
|
|
1407
1426
|
this._lastKeyValue = this._lastStrValue;
|
|
1408
1427
|
if (this.eatUnicodePropertyValue()) {
|
|
1409
1428
|
this._lastValValue = this._lastStrValue;
|
|
@@ -1451,7 +1470,7 @@ class RegExpValidator {
|
|
|
1451
1470
|
}
|
|
1452
1471
|
eatHexEscapeSequence() {
|
|
1453
1472
|
const start = this.index;
|
|
1454
|
-
if (this.eat(
|
|
1473
|
+
if (this.eat(LATIN_SMALL_LETTER_X)) {
|
|
1455
1474
|
if (this.eatFixedHexDigits(2)) {
|
|
1456
1475
|
return true;
|
|
1457
1476
|
}
|
|
@@ -1505,7 +1524,7 @@ class RegExpValidator {
|
|
|
1505
1524
|
const cp = this.currentCodePoint;
|
|
1506
1525
|
if (isOctalDigit(cp)) {
|
|
1507
1526
|
this.advance();
|
|
1508
|
-
this._lastIntValue = cp -
|
|
1527
|
+
this._lastIntValue = cp - DIGIT_ZERO;
|
|
1509
1528
|
return true;
|
|
1510
1529
|
}
|
|
1511
1530
|
this._lastIntValue = 0;
|
|
@@ -1527,14 +1546,14 @@ class RegExpValidator {
|
|
|
1527
1546
|
}
|
|
1528
1547
|
}
|
|
1529
1548
|
|
|
1530
|
-
const
|
|
1531
|
-
const
|
|
1532
|
-
const
|
|
1549
|
+
const DUMMY_PATTERN = {};
|
|
1550
|
+
const DUMMY_FLAGS = {};
|
|
1551
|
+
const DUMMY_CAPTURING_GROUP = {};
|
|
1533
1552
|
class RegExpParserState {
|
|
1534
1553
|
constructor(options) {
|
|
1535
1554
|
var _a;
|
|
1536
|
-
this._node =
|
|
1537
|
-
this._flags =
|
|
1555
|
+
this._node = DUMMY_PATTERN;
|
|
1556
|
+
this._flags = DUMMY_FLAGS;
|
|
1538
1557
|
this._backreferences = [];
|
|
1539
1558
|
this._capturingGroups = [];
|
|
1540
1559
|
this.source = "";
|
|
@@ -1553,7 +1572,7 @@ class RegExpParserState {
|
|
|
1553
1572
|
}
|
|
1554
1573
|
return this._flags;
|
|
1555
1574
|
}
|
|
1556
|
-
|
|
1575
|
+
onRegExpFlags(start, end, { global, ignoreCase, multiline, unicode, sticky, dotAll, hasIndices, }) {
|
|
1557
1576
|
this._flags = {
|
|
1558
1577
|
type: "Flags",
|
|
1559
1578
|
parent: null,
|
|
@@ -1824,7 +1843,7 @@ class RegExpParserState {
|
|
|
1824
1843
|
end,
|
|
1825
1844
|
raw: this.source.slice(start, end),
|
|
1826
1845
|
ref,
|
|
1827
|
-
resolved:
|
|
1846
|
+
resolved: DUMMY_CAPTURING_GROUP,
|
|
1828
1847
|
};
|
|
1829
1848
|
parent.elements.push(node);
|
|
1830
1849
|
this._backreferences.push(node);
|
|
@@ -1870,7 +1889,7 @@ class RegExpParserState {
|
|
|
1870
1889
|
min.type !== "Character" ||
|
|
1871
1890
|
max.type !== "Character" ||
|
|
1872
1891
|
hyphen.type !== "Character" ||
|
|
1873
|
-
hyphen.value !==
|
|
1892
|
+
hyphen.value !== HYPHEN_MINUS) {
|
|
1874
1893
|
throw new Error("UnknownError");
|
|
1875
1894
|
}
|
|
1876
1895
|
const node = {
|