Skip to content

Commit

Permalink
small fix
Browse files Browse the repository at this point in the history
  • Loading branch information
mysticatea committed Feb 13, 2018
1 parent 4164a1f commit 4434d9b
Showing 1 changed file with 17 additions and 12 deletions.
29 changes: 17 additions & 12 deletions src/regexp.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@ import {isIdentifierStart, isIdentifierChar} from "./identifier.js"
import {Parser} from "./state.js"
import UNICODE_PROPERTY_VALUES from "./unicode-property-data.js"

/* eslint no-invalid-this: error */

const BACKSPACE = 0x08
const CHARACTER_TABULATION = 0x09
const LINE_FEED = 0x0A
Expand Down Expand Up @@ -518,23 +516,30 @@ pp.validateRegExp_groupSpecifier = function(state) {

// GroupName[U] ::
// `<` RegExpIdentifierName[?U] `>`
// Note: this updates `state.lastStringValue` property with the eaten name.
pp.validateRegExp_eatGroupName = function(state) {
state.lastStringValue = ""
if (state.eat(LESS_THAN_SIGN)) {
if (this.validateRegExp_eatRegExpIdentifierName(state) && state.eat(GREATER_THAN_SIGN)) {
return true
}
state.raise("Invalid capture group name")
}
return false
}

// RegExpIdentifierName[U] ::
// RegExpIdentifierStart[?U]
// RegExpIdentifierName[?U] RegExpIdentifierPart[?U]
// Note: this updates `state.lastStringValue` property with the eaten name.
pp.validateRegExp_eatGroupName = function(state) {
pp.validateRegExp_eatRegExpIdentifierName = function(state) {
state.lastStringValue = ""
if (state.eat(LESS_THAN_SIGN)) {
if (this.validateRegExp_eatRegExpIdentifierStart(state)) {
if (this.validateRegExp_eatRegExpIdentifierStart(state)) {
state.lastStringValue += codePointToString(state.lastIntValue)
while (this.validateRegExp_eatRegExpIdentifierPart(state)) {
state.lastStringValue += codePointToString(state.lastIntValue)
while (this.validateRegExp_eatRegExpIdentifierPart(state)) {
state.lastStringValue += codePointToString(state.lastIntValue)
}
if (state.eat(GREATER_THAN_SIGN)) {
return true
}
}
state.raise("Invalid capture group name")
return true
}
return false
}
Expand Down

0 comments on commit 4434d9b

Please sign in to comment.