@@ -902,6 +902,9 @@ export class RegExpValidator {
902
902
if ( cp === RightParenthesis ) {
903
903
this . raise ( "Unmatched ')'" )
904
904
}
905
+ if ( cp === ReverseSolidus ) {
906
+ this . raise ( "\\ at end of pattern" )
907
+ }
905
908
if ( cp === RightSquareBracket || cp === RightCurlyBracket ) {
906
909
this . raise ( "Lone quantifier brackets" )
907
910
}
@@ -1176,6 +1179,7 @@ export class RegExpValidator {
1176
1179
return (
1177
1180
this . eatDot ( ) ||
1178
1181
this . eatReverseSolidusAtomEscape ( ) ||
1182
+ this . eatReverseSolidusFollowedByC ( ) ||
1179
1183
this . eatCharacterClass ( ) ||
1180
1184
this . eatUncapturingGroup ( ) ||
1181
1185
this . eatCapturingGroup ( ) ||
@@ -1184,6 +1188,20 @@ export class RegExpValidator {
1184
1188
)
1185
1189
}
1186
1190
1191
+ // \ [lookahead = c]
1192
+ private eatReverseSolidusFollowedByC ( ) : boolean {
1193
+ if (
1194
+ this . currentCodePoint === ReverseSolidus &&
1195
+ this . nextCodePoint === LatinSmallLetterC
1196
+ ) {
1197
+ this . _lastIntValue = this . currentCodePoint
1198
+ this . advance ( )
1199
+ this . onCharacter ( this . index - 1 , this . index , ReverseSolidus )
1200
+ return true
1201
+ }
1202
+ return false
1203
+ }
1204
+
1187
1205
// https://www.ecma-international.org/ecma-262/8.0/#prod-strict-InvalidBracedQuantifier
1188
1206
private eatInvalidBracedQuantifier ( ) : boolean {
1189
1207
if ( this . eatBracedQuantifier ( true ) ) {
@@ -1222,6 +1240,7 @@ export class RegExpValidator {
1222
1240
cp !== - 1 &&
1223
1241
cp !== CircumflexAccent &&
1224
1242
cp !== DollarSign &&
1243
+ cp !== ReverseSolidus &&
1225
1244
cp !== FullStop &&
1226
1245
cp !== Asterisk &&
1227
1246
cp !== PlusSign &&
@@ -1457,6 +1476,7 @@ export class RegExpValidator {
1457
1476
}
1458
1477
1459
1478
// https://www.ecma-international.org/ecma-262/8.0/#prod-RegExpUnicodeEscapeSequence
1479
+ //eslint-disable-next-line complexity
1460
1480
private eatRegExpUnicodeEscapeSequence ( ) : boolean {
1461
1481
const start = this . index
1462
1482
0 commit comments