+ return false;
+ }
+ consumeGroupSpecifier() {
+ if (this.eat(QuestionMark)) {
+ if (this.eatGroupName()) {
+ if (!this._groupNames.has(this._lastStrValue)) {
+ this._groupNames.add(this._lastStrValue);
+ return true;
+ }
+ this.raise("Duplicate capture group name");
+ }
+ this.raise("Invalid group");
+ }
+ return false;
+ }
+ consumeAtomEscape() {
+ if (this.consumeBackreference() ||
+ this.consumeCharacterClassEscape() ||
+ this.consumeCharacterEscape() ||
+ (this._nFlag && this.consumeKGroupName())) {
+ return true;
+ }
+ if (this.strict || this._uFlag) {
+ this.raise("Invalid escape");
+ }
+ return false;
+ }
+ consumeBackreference() {
+ const start = this.index;
+ if (this.eatDecimalEscape()) {
+ const n = this._lastIntValue;
+ if (n <= this._numCapturingParens) {
+ this.onBackreference(start - 1, this.index, n);
+ return true;
+ }
+ if (this.strict || this._uFlag) {
+ this.raise("Invalid escape");
+ }
+ this.rewind(start);
+ }
+ return false;
+ }
+ consumeCharacterClassEscape() {
+ const start = this.index;
+ if (this.eat(LatinSmallLetterD)) {
+ this._lastIntValue = -1;
+ this.onEscapeCharacterSet(start - 1, this.index, "digit", false);
+ return true;
+ }
+ if (this.eat(LatinCapitalLetterD)) {
+ this._lastIntValue = -1;
+ this.onEscapeCharacterSet(start - 1, this.index, "digit", true);
+ return true;
+ }
+ if (this.eat(LatinSmallLetterS)) {
+ this._lastIntValue = -1;
+ this.onEscapeCharacterSet(start - 1, this.index, "space", false);
+ return true;
+ }
+ if (this.eat(LatinCapitalLetterS)) {
+ this._lastIntValue = -1;
+ this.onEscapeCharacterSet(start - 1, this.index, "space", true);
+ return true;
+ }
+ if (this.eat(LatinSmallLetterW)) {
+ this._lastIntValue = -1;
+ this.onEscapeCharacterSet(start - 1, this.index, "word", false);
+ return true;
+ }
+ if (this.eat(LatinCapitalLetterW)) {
+ this._lastIntValue = -1;
+ this.onEscapeCharacterSet(start - 1, this.index, "word", true);
+ return true;
+ }
+ let negate = false;
+ if (this._uFlag &&
+ this.ecmaVersion >= 2018 &&
+ (this.eat(LatinSmallLetterP) ||
+ (negate = this.eat(LatinCapitalLetterP)))) {
+ this._lastIntValue = -1;
+ if (this.eat(LeftCurlyBracket) &&
+ this.eatUnicodePropertyValueExpression() &&
+ this.eat(RightCurlyBracket)) {
+ this.onUnicodePropertyCharacterSet(start - 1, this.index, "property", this._lastKeyValue, this._lastValValue || null, negate);
+ return true;
+ }
+ this.raise("Invalid property name");
+ }
+ return false;
+ }
+ consumeCharacterEscape() {
+ const start = this.index;
+ if (this.eatControlEscape() ||
+ this.eatCControlLetter() ||
+ this.eatZero() ||
+ this.eatHexEscapeSequence() ||
+ this.eatRegExpUnicodeEscapeSequence() ||
+ (!this.strict &&
+ !this._uFlag &&
+ this.eatLegacyOctalEscapeSequence()) ||
+ this.eatIdentityEscape()) {
+ this.onCharacter(start - 1, this.index, this._lastIntValue);
+ return true;
+ }
+ return false;
+ }
+ consumeKGroupName() {
+ const start = this.index;
+ if (this.eat(LatinSmallLetterK)) {
+ if (this.eatGroupName()) {
+ const groupName = this._lastStrValue;
+ this._backreferenceNames.add(groupName);
+ this.onBackreference(start - 1, this.index, groupName);
+ return true;
+ }
+ this.raise("Invalid named reference");
+ }
+ return false;
+ }
+ consumeCharacterClass() {
+ const start = this.index;
+ if (this.eat(LeftSquareBracket)) {
+ const negate = this.eat(CircumflexAccent);
+ this.onCharacterClassEnter(start, negate);
+ this.consumeClassRanges();
+ if (!this.eat(RightSquareBracket)) {
+ this.raise("Unterminated character class");
+ }
+ this.onCharacterClassLeave(start, this.index, negate);
+ return true;
+ }
+ return false;
+ }
+ consumeClassRanges() {
+ const strict = this.strict || this._uFlag;
+ for (;;) {
+ const rangeStart = this.index;
+ if (!this.consumeClassAtom()) {
+ break;
+ }
+ const min = this._lastIntValue;
+ if (!this.eat(HyphenMinus)) {
+ continue;
+ }
+ this.onCharacter(this.index - 1, this.index, HyphenMinus);
+ if (!this.consumeClassAtom()) {
+ break;
+ }
+ const max = this._lastIntValue;
+ if (min === -1 || max === -1) {
+ if (strict) {
+ this.raise("Invalid character class");
+ }
+ continue;
+ }
+ if (min > max) {
+ this.raise("Range out of order in character class");
+ }
+ this.onCharacterClassRange(rangeStart, this.index, min, max);
+ }