deps: update acorn to 8.12.1

PR-URL: https://github.com/nodejs/node/pull/53465
Reviewed-By: Marco Ippolito <marcoippolito54@gmail.com>
Reviewed-By: Chemi Atlow <chemi@atlow.co.il>
Reviewed-By: Rafael Gonzaga <rafael.nunu@hotmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Michael Dawson <midawson@redhat.com>
This commit is contained in:
Node.js GitHub Bot 2024-06-16 00:28:06 +00:00 committed by Michael Dawson
parent 359b4284bc
commit 54119757a3
8 changed files with 239 additions and 86 deletions

View File

@ -1,3 +1,33 @@
## 8.12.1 (2024-07-03)
### Bug fixes
Fix a regression that caused Acorn to no longer run on Node versions <8.10.
## 8.12.0 (2024-06-14)
### New features
Support ES2025 duplicate capture group names in regular expressions.
### Bug fixes
Include `VariableDeclarator` in the `AnyNode` type so that walker objects can refer to it without getting a type error.
Properly raise a parse error for invalid `for`/`of` statements using `async` as binding name.
Properly recognize \"use strict\" when preceded by a string with an escaped newline.
Mark the `Parser` constructor as protected, not private, so plugins can extend it without type errors.
Fix a bug where some invalid `delete` expressions were let through when the operand was parenthesized and `preserveParens` was enabled.
Properly normalize line endings in raw strings of invalid template tokens.
Properly track line numbers for escaped newlines in strings.
Fix a bug that broke line number accounting after a template literal with invalid escape sequences.
## 8.11.3 (2023-12-29)
### Bug fixes

View File

@ -50,12 +50,11 @@ Options are provided by in a second argument, which should be an
object containing any of these fields (only `ecmaVersion` is
required):
- **ecmaVersion**: Indicates the ECMAScript version to parse. Must be
either 3, 5, 6 (or 2015), 7 (2016), 8 (2017), 9 (2018), 10 (2019),
11 (2020), 12 (2021), 13 (2022), 14 (2023), or `"latest"` (the
latest the library supports). This influences support for strict
mode, the set of reserved words, and support for new syntax
features.
- **ecmaVersion**: Indicates the ECMAScript version to parse. Can be a
number, either in year (`2022`) or plain version number (`6`) form,
or `"latest"` (the latest the library supports). This influences
support for strict mode, the set of reserved words, and support for
new syntax features.
**NOTE**: Only 'stage 4' (finalized) ECMAScript features are being
implemented by Acorn. Other proposed new features must be

View File

@ -562,7 +562,7 @@ export type ModuleDeclaration =
| ExportDefaultDeclaration
| ExportAllDeclaration
export type AnyNode = Statement | Expression | Declaration | ModuleDeclaration | Literal | Program | SwitchCase | CatchClause | Property | Super | SpreadElement | TemplateElement | AssignmentProperty | ObjectPattern | ArrayPattern | RestElement | AssignmentPattern | ClassBody | MethodDefinition | MetaProperty | ImportSpecifier | ImportDefaultSpecifier | ImportNamespaceSpecifier | ExportSpecifier | AnonymousFunctionDeclaration | AnonymousClassDeclaration | PropertyDefinition | PrivateIdentifier | StaticBlock
export type AnyNode = Statement | Expression | Declaration | ModuleDeclaration | Literal | Program | SwitchCase | CatchClause | Property | Super | SpreadElement | TemplateElement | AssignmentProperty | ObjectPattern | ArrayPattern | RestElement | AssignmentPattern | ClassBody | MethodDefinition | MetaProperty | ImportSpecifier | ImportDefaultSpecifier | ImportNamespaceSpecifier | ExportSpecifier | AnonymousFunctionDeclaration | AnonymousClassDeclaration | PropertyDefinition | PrivateIdentifier | StaticBlock | VariableDeclarator
export function parse(input: string, options: Options): Program
@ -573,16 +573,15 @@ export function tokenizer(input: string, options: Options): {
[Symbol.iterator](): Iterator<Token>
}
export type ecmaVersion = 3 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 2015 | 2016 | 2017 | 2018 | 2019 | 2020 | 2021 | 2022 | 2023 | 2024 | "latest"
export type ecmaVersion = 3 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 2015 | 2016 | 2017 | 2018 | 2019 | 2020 | 2021 | 2022 | 2023 | 2024 | 2025 | "latest"
export interface Options {
/**
* `ecmaVersion` indicates the ECMAScript version to parse. Must be
* either 3, 5, 6 (or 2015), 7 (2016), 8 (2017), 9 (2018), 10
* (2019), 11 (2020), 12 (2021), 13 (2022), 14 (2023), or `"latest"`
* (the latest version the library supports). This influences
* support for strict mode, the set of reserved words, and support
* for new syntax features.
* `ecmaVersion` indicates the ECMAScript version to parse. Can be a
* number, either in year (`2022`) or plain version number (`6`) form,
* or `"latest"` (the latest the library supports). This influences
* support for strict mode, the set of reserved words, and support for
* new syntax features.
*/
ecmaVersion: ecmaVersion
@ -733,7 +732,7 @@ export class Parser {
options: Options
input: string
private constructor(options: Options, input: string, startPos?: number)
protected constructor(options: Options, input: string, startPos?: number)
parse(): Program
static parse(input: string, options: Options): Program

View File

@ -562,7 +562,7 @@ export type ModuleDeclaration =
| ExportDefaultDeclaration
| ExportAllDeclaration
export type AnyNode = Statement | Expression | Declaration | ModuleDeclaration | Literal | Program | SwitchCase | CatchClause | Property | Super | SpreadElement | TemplateElement | AssignmentProperty | ObjectPattern | ArrayPattern | RestElement | AssignmentPattern | ClassBody | MethodDefinition | MetaProperty | ImportSpecifier | ImportDefaultSpecifier | ImportNamespaceSpecifier | ExportSpecifier | AnonymousFunctionDeclaration | AnonymousClassDeclaration | PropertyDefinition | PrivateIdentifier | StaticBlock
export type AnyNode = Statement | Expression | Declaration | ModuleDeclaration | Literal | Program | SwitchCase | CatchClause | Property | Super | SpreadElement | TemplateElement | AssignmentProperty | ObjectPattern | ArrayPattern | RestElement | AssignmentPattern | ClassBody | MethodDefinition | MetaProperty | ImportSpecifier | ImportDefaultSpecifier | ImportNamespaceSpecifier | ExportSpecifier | AnonymousFunctionDeclaration | AnonymousClassDeclaration | PropertyDefinition | PrivateIdentifier | StaticBlock | VariableDeclarator
export function parse(input: string, options: Options): Program
@ -573,16 +573,15 @@ export function tokenizer(input: string, options: Options): {
[Symbol.iterator](): Iterator<Token>
}
export type ecmaVersion = 3 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 2015 | 2016 | 2017 | 2018 | 2019 | 2020 | 2021 | 2022 | 2023 | 2024 | "latest"
export type ecmaVersion = 3 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 2015 | 2016 | 2017 | 2018 | 2019 | 2020 | 2021 | 2022 | 2023 | 2024 | 2025 | "latest"
export interface Options {
/**
* `ecmaVersion` indicates the ECMAScript version to parse. Must be
* either 3, 5, 6 (or 2015), 7 (2016), 8 (2017), 9 (2018), 10
* (2019), 11 (2020), 12 (2021), 13 (2022), 14 (2023), or `"latest"`
* (the latest version the library supports). This influences
* support for strict mode, the set of reserved words, and support
* for new syntax features.
* `ecmaVersion` indicates the ECMAScript version to parse. Can be a
* number, either in year (`2022`) or plain version number (`6`) form,
* or `"latest"` (the latest the library supports). This influences
* support for strict mode, the set of reserved words, and support for
* new syntax features.
*/
ecmaVersion: ecmaVersion
@ -733,7 +732,7 @@ export class Parser {
options: Options
input: string
private constructor(options: Options, input: string, startPos?: number)
protected constructor(options: Options, input: string, startPos?: number)
parse(): Program
static parse(input: string, options: Options): Program

View File

@ -667,7 +667,7 @@
// ## Parser utilities
var literal = /^(?:'((?:\\.|[^'\\])*?)'|"((?:\\.|[^"\\])*?)")/;
var literal = /^(?:'((?:\\[^]|[^'\\])*?)'|"((?:\\[^]|[^"\\])*?)")/;
pp$9.strictDirective = function(start) {
if (this.options.ecmaVersion < 5) { return false }
for (;;) {
@ -853,7 +853,7 @@
// Statement) is allowed here. If context is not empty then only a Statement
// is allowed. However, `let [` is an explicit negative lookahead for
// ExpressionStatement, so special-case it first.
if (nextCh === 91 || nextCh === 92) { return true } // '[', '/'
if (nextCh === 91 || nextCh === 92) { return true } // '[', '\'
if (context) { return false }
if (nextCh === 123 || nextCh > 0xd7ff && nextCh < 0xdc00) { return true } // '{', astral
@ -1046,13 +1046,19 @@
return this.parseFor(node, init$1)
}
var startsWithLet = this.isContextual("let"), isForOf = false;
var containsEsc = this.containsEsc;
var refDestructuringErrors = new DestructuringErrors;
var init = this.parseExpression(awaitAt > -1 ? "await" : true, refDestructuringErrors);
var initPos = this.start;
var init = awaitAt > -1
? this.parseExprSubscripts(refDestructuringErrors, "await")
: this.parseExpression(true, refDestructuringErrors);
if (this.type === types$1._in || (isForOf = this.options.ecmaVersion >= 6 && this.isContextual("of"))) {
if (this.options.ecmaVersion >= 9) {
if (this.type === types$1._in) {
if (awaitAt > -1) { this.unexpected(awaitAt); }
} else { node.await = awaitAt > -1; }
if (awaitAt > -1) { // implies `ecmaVersion >= 9` (see declaration of awaitAt)
if (this.type === types$1._in) { this.unexpected(awaitAt); }
node.await = true;
} else if (isForOf && this.options.ecmaVersion >= 8) {
if (init.start === initPos && !containsEsc && init.type === "Identifier" && init.name === "async") { this.unexpected(); }
else if (this.options.ecmaVersion >= 9) { node.await = false; }
}
if (startsWithLet && isForOf) { this.raise(init.start, "The left-hand side of a for-of loop may not start with 'let'."); }
this.toAssignable(init, false, refDestructuringErrors);
@ -2665,8 +2671,7 @@
node.argument = this.parseMaybeUnary(null, true, update, forInit);
this.checkExpressionErrors(refDestructuringErrors, true);
if (update) { this.checkLValSimple(node.argument); }
else if (this.strict && node.operator === "delete" &&
node.argument.type === "Identifier")
else if (this.strict && node.operator === "delete" && isLocalVariableAccess(node.argument))
{ this.raiseRecoverable(node.start, "Deleting local variable in strict mode"); }
else if (node.operator === "delete" && isPrivateFieldAccess(node.argument))
{ this.raiseRecoverable(node.start, "Private fields can not be deleted"); }
@ -2701,10 +2706,18 @@
}
};
function isLocalVariableAccess(node) {
return (
node.type === "Identifier" ||
node.type === "ParenthesizedExpression" && isLocalVariableAccess(node.expression)
)
}
function isPrivateFieldAccess(node) {
return (
node.type === "MemberExpression" && node.property.type === "PrivateIdentifier" ||
node.type === "ChainExpression" && isPrivateFieldAccess(node.expression)
node.type === "ChainExpression" && isPrivateFieldAccess(node.expression) ||
node.type === "ParenthesizedExpression" && isPrivateFieldAccess(node.expression)
)
}
@ -3131,7 +3144,7 @@
this.raiseRecoverable(this.start, "Bad escape sequence in untagged template literal");
}
elem.value = {
raw: this.value,
raw: this.value.replace(/\r\n?/g, "\n"),
cooked: null
};
} else {
@ -3806,6 +3819,30 @@
var pp$1 = Parser.prototype;
// Track disjunction structure to determine whether a duplicate
// capture group name is allowed because it is in a separate branch.
var BranchID = function BranchID(parent, base) {
// Parent disjunction branch
this.parent = parent;
// Identifies this set of sibling branches
this.base = base || this;
};
BranchID.prototype.separatedFrom = function separatedFrom (alt) {
// A branch is separate from another branch if they or any of
// their parents are siblings in a given disjunction
for (var self = this; self; self = self.parent) {
for (var other = alt; other; other = other.parent) {
if (self.base === other.base && self !== other) { return true }
}
}
return false
};
BranchID.prototype.sibling = function sibling () {
return new BranchID(this.parent, this.base)
};
var RegExpValidationState = function RegExpValidationState(parser) {
this.parser = parser;
this.validFlags = "gim" + (parser.options.ecmaVersion >= 6 ? "uy" : "") + (parser.options.ecmaVersion >= 9 ? "s" : "") + (parser.options.ecmaVersion >= 13 ? "d" : "") + (parser.options.ecmaVersion >= 15 ? "v" : "");
@ -3822,8 +3859,9 @@
this.lastAssertionIsQuantifiable = false;
this.numCapturingParens = 0;
this.maxBackReference = 0;
this.groupNames = [];
this.groupNames = Object.create(null);
this.backReferenceNames = [];
this.branchID = null;
};
RegExpValidationState.prototype.reset = function reset (start, pattern, flags) {
@ -3955,6 +3993,11 @@
}
};
function hasProp(obj) {
for (var _ in obj) { return true }
return false
}
/**
* Validate the pattern part of a given RegExpLiteral.
*
@ -3969,7 +4012,7 @@
// |Pattern[~U, +N]| and use this result instead. Throw a *SyntaxError*
// exception if _P_ did not conform to the grammar, if any elements of _P_
// were not matched by the parse, or if any Early Error conditions exist.
if (!state.switchN && this.options.ecmaVersion >= 9 && state.groupNames.length > 0) {
if (!state.switchN && this.options.ecmaVersion >= 9 && hasProp(state.groupNames)) {
state.switchN = true;
this.regexp_pattern(state);
}
@ -3983,8 +4026,9 @@
state.lastAssertionIsQuantifiable = false;
state.numCapturingParens = 0;
state.maxBackReference = 0;
state.groupNames.length = 0;
state.groupNames = Object.create(null);
state.backReferenceNames.length = 0;
state.branchID = null;
this.regexp_disjunction(state);
@ -4003,7 +4047,7 @@
for (var i = 0, list = state.backReferenceNames; i < list.length; i += 1) {
var name = list[i];
if (state.groupNames.indexOf(name) === -1) {
if (!state.groupNames[name]) {
state.raise("Invalid named capture referenced");
}
}
@ -4011,10 +4055,14 @@
// https://www.ecma-international.org/ecma-262/8.0/#prod-Disjunction
pp$1.regexp_disjunction = function(state) {
var trackDisjunction = this.options.ecmaVersion >= 16;
if (trackDisjunction) { state.branchID = new BranchID(state.branchID, null); }
this.regexp_alternative(state);
while (state.eat(0x7C /* | */)) {
if (trackDisjunction) { state.branchID = state.branchID.sibling(); }
this.regexp_alternative(state);
}
if (trackDisjunction) { state.branchID = state.branchID.parent; }
// Make the same message as V8.
if (this.regexp_eatQuantifier(state, true)) {
@ -4027,8 +4075,7 @@
// https://www.ecma-international.org/ecma-262/8.0/#prod-Alternative
pp$1.regexp_alternative = function(state) {
while (state.pos < state.source.length && this.regexp_eatTerm(state))
{ }
while (state.pos < state.source.length && this.regexp_eatTerm(state)) {}
};
// https://www.ecma-international.org/ecma-262/8.0/#prod-annexB-Term
@ -4266,14 +4313,26 @@
// `?` GroupName
pp$1.regexp_groupSpecifier = function(state) {
if (state.eat(0x3F /* ? */)) {
if (this.regexp_eatGroupName(state)) {
if (state.groupNames.indexOf(state.lastStringValue) !== -1) {
if (!this.regexp_eatGroupName(state)) { state.raise("Invalid group"); }
var trackDisjunction = this.options.ecmaVersion >= 16;
var known = state.groupNames[state.lastStringValue];
if (known) {
if (trackDisjunction) {
for (var i = 0, list = known; i < list.length; i += 1) {
var altID = list[i];
if (!altID.separatedFrom(state.branchID))
{ state.raise("Duplicate capture group name"); }
}
} else {
state.raise("Duplicate capture group name");
}
state.groupNames.push(state.lastStringValue);
return
}
state.raise("Invalid group");
if (trackDisjunction) {
(known || (state.groupNames[state.lastStringValue] = [])).push(state.branchID);
} else {
state.groupNames[state.lastStringValue] = true;
}
}
};
@ -5778,15 +5837,18 @@
break
case "$":
if (this.input[this.pos + 1] !== "{") {
break
}
// falls through
if (this.input[this.pos + 1] !== "{") { break }
// fall through
case "`":
return this.finishToken(types$1.invalidTemplate, this.input.slice(this.start, this.pos))
// no default
case "\r":
if (this.input[this.pos + 1] === "\n") { ++this.pos; }
// fall through
case "\n": case "\u2028": case "\u2029":
++this.curLine;
this.lineStart = this.pos + 1;
break
}
}
this.raise(this.start, "Unterminated template");
@ -5849,6 +5911,7 @@
if (isNewLine(ch)) {
// Unicode new line characters after \ get removed from output in both
// template literals and strings
if (this.options.locations) { this.lineStart = this.pos; ++this.curLine; }
return ""
}
return String.fromCharCode(ch)
@ -5927,7 +5990,7 @@
// [walk]: util/walk.js
var version = "8.11.3";
var version = "8.12.1";
Parser.acorn = {
Parser: Parser,

View File

@ -661,7 +661,7 @@ var pp$9 = Parser.prototype;
// ## Parser utilities
var literal = /^(?:'((?:\\.|[^'\\])*?)'|"((?:\\.|[^"\\])*?)")/;
var literal = /^(?:'((?:\\[^]|[^'\\])*?)'|"((?:\\[^]|[^"\\])*?)")/;
pp$9.strictDirective = function(start) {
if (this.options.ecmaVersion < 5) { return false }
for (;;) {
@ -847,7 +847,7 @@ pp$8.isLet = function(context) {
// Statement) is allowed here. If context is not empty then only a Statement
// is allowed. However, `let [` is an explicit negative lookahead for
// ExpressionStatement, so special-case it first.
if (nextCh === 91 || nextCh === 92) { return true } // '[', '/'
if (nextCh === 91 || nextCh === 92) { return true } // '[', '\'
if (context) { return false }
if (nextCh === 123 || nextCh > 0xd7ff && nextCh < 0xdc00) { return true } // '{', astral
@ -1040,13 +1040,19 @@ pp$8.parseForStatement = function(node) {
return this.parseFor(node, init$1)
}
var startsWithLet = this.isContextual("let"), isForOf = false;
var containsEsc = this.containsEsc;
var refDestructuringErrors = new DestructuringErrors;
var init = this.parseExpression(awaitAt > -1 ? "await" : true, refDestructuringErrors);
var initPos = this.start;
var init = awaitAt > -1
? this.parseExprSubscripts(refDestructuringErrors, "await")
: this.parseExpression(true, refDestructuringErrors);
if (this.type === types$1._in || (isForOf = this.options.ecmaVersion >= 6 && this.isContextual("of"))) {
if (this.options.ecmaVersion >= 9) {
if (this.type === types$1._in) {
if (awaitAt > -1) { this.unexpected(awaitAt); }
} else { node.await = awaitAt > -1; }
if (awaitAt > -1) { // implies `ecmaVersion >= 9` (see declaration of awaitAt)
if (this.type === types$1._in) { this.unexpected(awaitAt); }
node.await = true;
} else if (isForOf && this.options.ecmaVersion >= 8) {
if (init.start === initPos && !containsEsc && init.type === "Identifier" && init.name === "async") { this.unexpected(); }
else if (this.options.ecmaVersion >= 9) { node.await = false; }
}
if (startsWithLet && isForOf) { this.raise(init.start, "The left-hand side of a for-of loop may not start with 'let'."); }
this.toAssignable(init, false, refDestructuringErrors);
@ -2659,8 +2665,7 @@ pp$5.parseMaybeUnary = function(refDestructuringErrors, sawUnary, incDec, forIni
node.argument = this.parseMaybeUnary(null, true, update, forInit);
this.checkExpressionErrors(refDestructuringErrors, true);
if (update) { this.checkLValSimple(node.argument); }
else if (this.strict && node.operator === "delete" &&
node.argument.type === "Identifier")
else if (this.strict && node.operator === "delete" && isLocalVariableAccess(node.argument))
{ this.raiseRecoverable(node.start, "Deleting local variable in strict mode"); }
else if (node.operator === "delete" && isPrivateFieldAccess(node.argument))
{ this.raiseRecoverable(node.start, "Private fields can not be deleted"); }
@ -2695,10 +2700,18 @@ pp$5.parseMaybeUnary = function(refDestructuringErrors, sawUnary, incDec, forIni
}
};
function isLocalVariableAccess(node) {
return (
node.type === "Identifier" ||
node.type === "ParenthesizedExpression" && isLocalVariableAccess(node.expression)
)
}
function isPrivateFieldAccess(node) {
return (
node.type === "MemberExpression" && node.property.type === "PrivateIdentifier" ||
node.type === "ChainExpression" && isPrivateFieldAccess(node.expression)
node.type === "ChainExpression" && isPrivateFieldAccess(node.expression) ||
node.type === "ParenthesizedExpression" && isPrivateFieldAccess(node.expression)
)
}
@ -3125,7 +3138,7 @@ pp$5.parseTemplateElement = function(ref) {
this.raiseRecoverable(this.start, "Bad escape sequence in untagged template literal");
}
elem.value = {
raw: this.value,
raw: this.value.replace(/\r\n?/g, "\n"),
cooked: null
};
} else {
@ -3800,6 +3813,30 @@ for (var i = 0, list = [9, 10, 11, 12, 13, 14]; i < list.length; i += 1) {
var pp$1 = Parser.prototype;
// Track disjunction structure to determine whether a duplicate
// capture group name is allowed because it is in a separate branch.
var BranchID = function BranchID(parent, base) {
// Parent disjunction branch
this.parent = parent;
// Identifies this set of sibling branches
this.base = base || this;
};
BranchID.prototype.separatedFrom = function separatedFrom (alt) {
// A branch is separate from another branch if they or any of
// their parents are siblings in a given disjunction
for (var self = this; self; self = self.parent) {
for (var other = alt; other; other = other.parent) {
if (self.base === other.base && self !== other) { return true }
}
}
return false
};
BranchID.prototype.sibling = function sibling () {
return new BranchID(this.parent, this.base)
};
var RegExpValidationState = function RegExpValidationState(parser) {
this.parser = parser;
this.validFlags = "gim" + (parser.options.ecmaVersion >= 6 ? "uy" : "") + (parser.options.ecmaVersion >= 9 ? "s" : "") + (parser.options.ecmaVersion >= 13 ? "d" : "") + (parser.options.ecmaVersion >= 15 ? "v" : "");
@ -3816,8 +3853,9 @@ var RegExpValidationState = function RegExpValidationState(parser) {
this.lastAssertionIsQuantifiable = false;
this.numCapturingParens = 0;
this.maxBackReference = 0;
this.groupNames = [];
this.groupNames = Object.create(null);
this.backReferenceNames = [];
this.branchID = null;
};
RegExpValidationState.prototype.reset = function reset (start, pattern, flags) {
@ -3949,6 +3987,11 @@ pp$1.validateRegExpFlags = function(state) {
}
};
function hasProp(obj) {
for (var _ in obj) { return true }
return false
}
/**
* Validate the pattern part of a given RegExpLiteral.
*
@ -3963,7 +4006,7 @@ pp$1.validateRegExpPattern = function(state) {
// |Pattern[~U, +N]| and use this result instead. Throw a *SyntaxError*
// exception if _P_ did not conform to the grammar, if any elements of _P_
// were not matched by the parse, or if any Early Error conditions exist.
if (!state.switchN && this.options.ecmaVersion >= 9 && state.groupNames.length > 0) {
if (!state.switchN && this.options.ecmaVersion >= 9 && hasProp(state.groupNames)) {
state.switchN = true;
this.regexp_pattern(state);
}
@ -3977,8 +4020,9 @@ pp$1.regexp_pattern = function(state) {
state.lastAssertionIsQuantifiable = false;
state.numCapturingParens = 0;
state.maxBackReference = 0;
state.groupNames.length = 0;
state.groupNames = Object.create(null);
state.backReferenceNames.length = 0;
state.branchID = null;
this.regexp_disjunction(state);
@ -3997,7 +4041,7 @@ pp$1.regexp_pattern = function(state) {
for (var i = 0, list = state.backReferenceNames; i < list.length; i += 1) {
var name = list[i];
if (state.groupNames.indexOf(name) === -1) {
if (!state.groupNames[name]) {
state.raise("Invalid named capture referenced");
}
}
@ -4005,10 +4049,14 @@ pp$1.regexp_pattern = function(state) {
// https://www.ecma-international.org/ecma-262/8.0/#prod-Disjunction
pp$1.regexp_disjunction = function(state) {
var trackDisjunction = this.options.ecmaVersion >= 16;
if (trackDisjunction) { state.branchID = new BranchID(state.branchID, null); }
this.regexp_alternative(state);
while (state.eat(0x7C /* | */)) {
if (trackDisjunction) { state.branchID = state.branchID.sibling(); }
this.regexp_alternative(state);
}
if (trackDisjunction) { state.branchID = state.branchID.parent; }
// Make the same message as V8.
if (this.regexp_eatQuantifier(state, true)) {
@ -4021,8 +4069,7 @@ pp$1.regexp_disjunction = function(state) {
// https://www.ecma-international.org/ecma-262/8.0/#prod-Alternative
pp$1.regexp_alternative = function(state) {
while (state.pos < state.source.length && this.regexp_eatTerm(state))
{ }
while (state.pos < state.source.length && this.regexp_eatTerm(state)) {}
};
// https://www.ecma-international.org/ecma-262/8.0/#prod-annexB-Term
@ -4260,14 +4307,26 @@ pp$1.regexp_eatExtendedPatternCharacter = function(state) {
// `?` GroupName
pp$1.regexp_groupSpecifier = function(state) {
if (state.eat(0x3F /* ? */)) {
if (this.regexp_eatGroupName(state)) {
if (state.groupNames.indexOf(state.lastStringValue) !== -1) {
if (!this.regexp_eatGroupName(state)) { state.raise("Invalid group"); }
var trackDisjunction = this.options.ecmaVersion >= 16;
var known = state.groupNames[state.lastStringValue];
if (known) {
if (trackDisjunction) {
for (var i = 0, list = known; i < list.length; i += 1) {
var altID = list[i];
if (!altID.separatedFrom(state.branchID))
{ state.raise("Duplicate capture group name"); }
}
} else {
state.raise("Duplicate capture group name");
}
state.groupNames.push(state.lastStringValue);
return
}
state.raise("Invalid group");
if (trackDisjunction) {
(known || (state.groupNames[state.lastStringValue] = [])).push(state.branchID);
} else {
state.groupNames[state.lastStringValue] = true;
}
}
};
@ -5772,15 +5831,18 @@ pp.readInvalidTemplateToken = function() {
break
case "$":
if (this.input[this.pos + 1] !== "{") {
break
}
// falls through
if (this.input[this.pos + 1] !== "{") { break }
// fall through
case "`":
return this.finishToken(types$1.invalidTemplate, this.input.slice(this.start, this.pos))
// no default
case "\r":
if (this.input[this.pos + 1] === "\n") { ++this.pos; }
// fall through
case "\n": case "\u2028": case "\u2029":
++this.curLine;
this.lineStart = this.pos + 1;
break
}
}
this.raise(this.start, "Unterminated template");
@ -5843,6 +5905,7 @@ pp.readEscapedChar = function(inTemplate) {
if (isNewLine(ch)) {
// Unicode new line characters after \ get removed from output in both
// template literals and strings
if (this.options.locations) { this.lineStart = this.pos; ++this.curLine; }
return ""
}
return String.fromCharCode(ch)
@ -5921,7 +5984,7 @@ pp.readWord = function() {
// [walk]: util/walk.js
var version = "8.11.3";
var version = "8.12.1";
Parser.acorn = {
Parser: Parser,

View File

@ -16,7 +16,7 @@
],
"./package.json": "./package.json"
},
"version": "8.11.3",
"version": "8.12.1",
"engines": {
"node": ">=0.4.0"
},
@ -38,13 +38,13 @@
],
"repository": {
"type": "git",
"url": "https://github.com/acornjs/acorn.git"
"url": "git+https://github.com/acornjs/acorn.git"
},
"license": "MIT",
"scripts": {
"prepare": "cd ..; npm run build:main"
},
"bin": {
"acorn": "./bin/acorn"
"acorn": "bin/acorn"
}
}

View File

@ -2,5 +2,5 @@
// Refer to tools/dep_updaters/update-acorn.sh
#ifndef SRC_ACORN_VERSION_H_
#define SRC_ACORN_VERSION_H_
#define ACORN_VERSION "8.11.3"
#define ACORN_VERSION "8.12.1"
#endif // SRC_ACORN_VERSION_H_