From 4434d9b92cc3701ba4a611e0915b460ec13df890 Mon Sep 17 00:00:00 2001 From: Toru Nagashima Date: Tue, 13 Feb 2018 22:18:37 +0900 Subject: [PATCH] small fix --- src/regexp.js | 29 +++++++++++++++++------------ 1 file changed, 17 insertions(+), 12 deletions(-) diff --git a/src/regexp.js b/src/regexp.js index acc6a853d..3da456f39 100644 --- a/src/regexp.js +++ b/src/regexp.js @@ -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 @@ -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 }