deps: update acorn to 8.14.0

PR-URL: https://github.com/nodejs/node/pull/55699
Reviewed-By: Rafael Gonzaga <rafael.nunu@hotmail.com>
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
This commit is contained in:
Node.js GitHub Bot 2024-11-04 20:00:11 -05:00 committed by GitHub
parent 0b58160e2e
commit 73cfaba8b6
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
7 changed files with 280 additions and 30 deletions

View File

@ -1,3 +1,15 @@
## 8.14.0 (2024-10-27)
### New features
Support ES2025 import attributes.
Support ES2025 RegExp modifiers.
### Bug fixes
Support some missing Unicode properties.
## 8.13.0 (2024-10-16) ## 8.13.0 (2024-10-16)
### New features ### New features

View File

@ -403,6 +403,7 @@ export interface ImportDeclaration extends Node {
type: "ImportDeclaration" type: "ImportDeclaration"
specifiers: Array<ImportSpecifier | ImportDefaultSpecifier | ImportNamespaceSpecifier> specifiers: Array<ImportSpecifier | ImportDefaultSpecifier | ImportNamespaceSpecifier>
source: Literal source: Literal
attributes: Array<ImportAttribute>
} }
export interface ImportSpecifier extends Node { export interface ImportSpecifier extends Node {
@ -421,11 +422,18 @@ export interface ImportNamespaceSpecifier extends Node {
local: Identifier local: Identifier
} }
export interface ImportAttribute extends Node {
type: "ImportAttribute"
key: Identifier | Literal
value: Literal
}
export interface ExportNamedDeclaration extends Node { export interface ExportNamedDeclaration extends Node {
type: "ExportNamedDeclaration" type: "ExportNamedDeclaration"
declaration?: Declaration | null declaration?: Declaration | null
specifiers: Array<ExportSpecifier> specifiers: Array<ExportSpecifier>
source?: Literal | null source?: Literal | null
attributes: Array<ImportAttribute>
} }
export interface ExportSpecifier extends Node { export interface ExportSpecifier extends Node {
@ -454,6 +462,7 @@ export interface ExportAllDeclaration extends Node {
type: "ExportAllDeclaration" type: "ExportAllDeclaration"
source: Literal source: Literal
exported?: Identifier | Literal | null exported?: Identifier | Literal | null
attributes: Array<ImportAttribute>
} }
export interface AwaitExpression extends Node { export interface AwaitExpression extends Node {
@ -469,6 +478,7 @@ export interface ChainExpression extends Node {
export interface ImportExpression extends Node { export interface ImportExpression extends Node {
type: "ImportExpression" type: "ImportExpression"
source: Expression source: Expression
options: Expression | null
} }
export interface ParenthesizedExpression extends Node { export interface ParenthesizedExpression extends Node {
@ -562,7 +572,7 @@ export type ModuleDeclaration =
| ExportDefaultDeclaration | ExportDefaultDeclaration
| ExportAllDeclaration | 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 | VariableDeclarator export type AnyNode = Statement | Expression | Declaration | ModuleDeclaration | Literal | Program | SwitchCase | CatchClause | Property | Super | SpreadElement | TemplateElement | AssignmentProperty | ObjectPattern | ArrayPattern | RestElement | AssignmentPattern | ClassBody | MethodDefinition | MetaProperty | ImportAttribute | ImportSpecifier | ImportDefaultSpecifier | ImportNamespaceSpecifier | ExportSpecifier | AnonymousFunctionDeclaration | AnonymousClassDeclaration | PropertyDefinition | PrivateIdentifier | StaticBlock | VariableDeclarator
export function parse(input: string, options: Options): Program export function parse(input: string, options: Options): Program

View File

@ -403,6 +403,7 @@ export interface ImportDeclaration extends Node {
type: "ImportDeclaration" type: "ImportDeclaration"
specifiers: Array<ImportSpecifier | ImportDefaultSpecifier | ImportNamespaceSpecifier> specifiers: Array<ImportSpecifier | ImportDefaultSpecifier | ImportNamespaceSpecifier>
source: Literal source: Literal
attributes: Array<ImportAttribute>
} }
export interface ImportSpecifier extends Node { export interface ImportSpecifier extends Node {
@ -421,11 +422,18 @@ export interface ImportNamespaceSpecifier extends Node {
local: Identifier local: Identifier
} }
export interface ImportAttribute extends Node {
type: "ImportAttribute"
key: Identifier | Literal
value: Literal
}
export interface ExportNamedDeclaration extends Node { export interface ExportNamedDeclaration extends Node {
type: "ExportNamedDeclaration" type: "ExportNamedDeclaration"
declaration?: Declaration | null declaration?: Declaration | null
specifiers: Array<ExportSpecifier> specifiers: Array<ExportSpecifier>
source?: Literal | null source?: Literal | null
attributes: Array<ImportAttribute>
} }
export interface ExportSpecifier extends Node { export interface ExportSpecifier extends Node {
@ -454,6 +462,7 @@ export interface ExportAllDeclaration extends Node {
type: "ExportAllDeclaration" type: "ExportAllDeclaration"
source: Literal source: Literal
exported?: Identifier | Literal | null exported?: Identifier | Literal | null
attributes: Array<ImportAttribute>
} }
export interface AwaitExpression extends Node { export interface AwaitExpression extends Node {
@ -469,6 +478,7 @@ export interface ChainExpression extends Node {
export interface ImportExpression extends Node { export interface ImportExpression extends Node {
type: "ImportExpression" type: "ImportExpression"
source: Expression source: Expression
options: Expression | null
} }
export interface ParenthesizedExpression extends Node { export interface ParenthesizedExpression extends Node {
@ -562,7 +572,7 @@ export type ModuleDeclaration =
| ExportDefaultDeclaration | ExportDefaultDeclaration
| ExportAllDeclaration | 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 | VariableDeclarator export type AnyNode = Statement | Expression | Declaration | ModuleDeclaration | Literal | Program | SwitchCase | CatchClause | Property | Super | SpreadElement | TemplateElement | AssignmentProperty | ObjectPattern | ArrayPattern | RestElement | AssignmentPattern | ClassBody | MethodDefinition | MetaProperty | ImportAttribute | ImportSpecifier | ImportDefaultSpecifier | ImportNamespaceSpecifier | ExportSpecifier | AnonymousFunctionDeclaration | AnonymousClassDeclaration | PropertyDefinition | PrivateIdentifier | StaticBlock | VariableDeclarator
export function parse(input: string, options: Options): Program export function parse(input: string, options: Options): Program

View File

@ -1678,6 +1678,8 @@
this.expectContextual("from"); this.expectContextual("from");
if (this.type !== types$1.string) { this.unexpected(); } if (this.type !== types$1.string) { this.unexpected(); }
node.source = this.parseExprAtom(); node.source = this.parseExprAtom();
if (this.options.ecmaVersion >= 16)
{ node.attributes = this.parseWithClause(); }
this.semicolon(); this.semicolon();
return this.finishNode(node, "ExportAllDeclaration") return this.finishNode(node, "ExportAllDeclaration")
}; };
@ -1708,6 +1710,8 @@
if (this.eatContextual("from")) { if (this.eatContextual("from")) {
if (this.type !== types$1.string) { this.unexpected(); } if (this.type !== types$1.string) { this.unexpected(); }
node.source = this.parseExprAtom(); node.source = this.parseExprAtom();
if (this.options.ecmaVersion >= 16)
{ node.attributes = this.parseWithClause(); }
} else { } else {
for (var i = 0, list = node.specifiers; i < list.length; i += 1) { for (var i = 0, list = node.specifiers; i < list.length; i += 1) {
// check for keywords used as local names // check for keywords used as local names
@ -1848,6 +1852,8 @@
this.expectContextual("from"); this.expectContextual("from");
node.source = this.type === types$1.string ? this.parseExprAtom() : this.unexpected(); node.source = this.type === types$1.string ? this.parseExprAtom() : this.unexpected();
} }
if (this.options.ecmaVersion >= 16)
{ node.attributes = this.parseWithClause(); }
this.semicolon(); this.semicolon();
return this.finishNode(node, "ImportDeclaration") return this.finishNode(node, "ImportDeclaration")
}; };
@ -1908,6 +1914,41 @@
return nodes return nodes
}; };
pp$8.parseWithClause = function() {
var nodes = [];
if (!this.eat(types$1._with)) {
return nodes
}
this.expect(types$1.braceL);
var attributeKeys = {};
var first = true;
while (!this.eat(types$1.braceR)) {
if (!first) {
this.expect(types$1.comma);
if (this.afterTrailingComma(types$1.braceR)) { break }
} else { first = false; }
var attr = this.parseImportAttribute();
var keyName = attr.key.type === "Identifier" ? attr.key.name : attr.key.value;
if (hasOwn(attributeKeys, keyName))
{ this.raiseRecoverable(attr.key.start, "Duplicate attribute key '" + keyName + "'"); }
attributeKeys[keyName] = true;
nodes.push(attr);
}
return nodes
};
pp$8.parseImportAttribute = function() {
var node = this.startNode();
node.key = this.type === types$1.string ? this.parseExprAtom() : this.parseIdent(this.options.allowReserved !== "never");
this.expect(types$1.colon);
if (this.type !== types$1.string) {
this.unexpected();
}
node.value = this.parseExprAtom();
return this.finishNode(node, "ImportAttribute")
};
pp$8.parseModuleExportName = function() { pp$8.parseModuleExportName = function() {
if (this.options.ecmaVersion >= 13 && this.type === types$1.string) { if (this.options.ecmaVersion >= 13 && this.type === types$1.string) {
var stringLiteral = this.parseLiteral(this.value); var stringLiteral = this.parseLiteral(this.value);
@ -2975,13 +3016,32 @@
// Parse node.source. // Parse node.source.
node.source = this.parseMaybeAssign(); node.source = this.parseMaybeAssign();
// Verify ending. if (this.options.ecmaVersion >= 16) {
if (!this.eat(types$1.parenR)) { if (!this.eat(types$1.parenR)) {
var errorPos = this.start; this.expect(types$1.comma);
if (this.eat(types$1.comma) && this.eat(types$1.parenR)) { if (!this.afterTrailingComma(types$1.parenR)) {
this.raiseRecoverable(errorPos, "Trailing comma is not allowed in import()"); node.options = this.parseMaybeAssign();
if (!this.eat(types$1.parenR)) {
this.expect(types$1.comma);
if (!this.afterTrailingComma(types$1.parenR)) {
this.unexpected();
}
}
} else {
node.options = null;
}
} else { } else {
this.unexpected(errorPos); node.options = null;
}
} else {
// Verify ending.
if (!this.eat(types$1.parenR)) {
var errorPos = this.start;
if (this.eat(types$1.comma) && this.eat(types$1.parenR)) {
this.raiseRecoverable(errorPos, "Trailing comma is not allowed in import()");
} else {
this.unexpected(errorPos);
}
} }
} }
@ -3741,6 +3801,9 @@
return newNode return newNode
}; };
// This file was generated by "bin/generate-unicode-script-values.js". Do not modify manually!
var scriptValuesAddedInUnicode = "Gara Garay Gukh Gurung_Khema Hrkt Katakana_Or_Hiragana Kawi Kirat_Rai Krai Nag_Mundari Nagm Ol_Onal Onao Sunu Sunuwar Todhri Todr Tulu_Tigalari Tutg Unknown Zzzz";
// This file contains Unicode properties extracted from the ECMAScript specification. // This file contains Unicode properties extracted from the ECMAScript specification.
// The lists are extracted like so: // The lists are extracted like so:
// $$('#table-binary-unicode-properties > figure > table > tbody > tr > td:nth-child(1) code').map(el => el.innerText) // $$('#table-binary-unicode-properties > figure > table > tbody > tr > td:nth-child(1) code').map(el => el.innerText)
@ -3783,7 +3846,7 @@
var ecma11ScriptValues = ecma10ScriptValues + " Elymaic Elym Nandinagari Nand Nyiakeng_Puachue_Hmong Hmnp Wancho Wcho"; var ecma11ScriptValues = ecma10ScriptValues + " Elymaic Elym Nandinagari Nand Nyiakeng_Puachue_Hmong Hmnp Wancho Wcho";
var ecma12ScriptValues = ecma11ScriptValues + " Chorasmian Chrs Diak Dives_Akuru Khitan_Small_Script Kits Yezi Yezidi"; var ecma12ScriptValues = ecma11ScriptValues + " Chorasmian Chrs Diak Dives_Akuru Khitan_Small_Script Kits Yezi Yezidi";
var ecma13ScriptValues = ecma12ScriptValues + " Cypro_Minoan Cpmn Old_Uyghur Ougr Tangsa Tnsa Toto Vithkuqi Vith"; var ecma13ScriptValues = ecma12ScriptValues + " Cypro_Minoan Cpmn Old_Uyghur Ougr Tangsa Tnsa Toto Vithkuqi Vith";
var ecma14ScriptValues = ecma13ScriptValues + " Hrkt Katakana_Or_Hiragana Kawi Nag_Mundari Nagm Unknown Zzzz"; var ecma14ScriptValues = ecma13ScriptValues + " " + scriptValuesAddedInUnicode;
var unicodeScriptValues = { var unicodeScriptValues = {
9: ecma9ScriptValues, 9: ecma9ScriptValues,
@ -4208,12 +4271,41 @@
pp$1.regexp_eatUncapturingGroup = function(state) { pp$1.regexp_eatUncapturingGroup = function(state) {
var start = state.pos; var start = state.pos;
if (state.eat(0x28 /* ( */)) { if (state.eat(0x28 /* ( */)) {
if (state.eat(0x3F /* ? */) && state.eat(0x3A /* : */)) { if (state.eat(0x3F /* ? */)) {
this.regexp_disjunction(state); if (this.options.ecmaVersion >= 16) {
if (state.eat(0x29 /* ) */)) { var addModifiers = this.regexp_eatModifiers(state);
return true var hasHyphen = state.eat(0x2D /* - */);
if (addModifiers || hasHyphen) {
for (var i = 0; i < addModifiers.length; i++) {
var modifier = addModifiers.charAt(i);
if (addModifiers.indexOf(modifier, i + 1) > -1) {
state.raise("Duplicate regular expression modifiers");
}
}
if (hasHyphen) {
var removeModifiers = this.regexp_eatModifiers(state);
if (!addModifiers && !removeModifiers && state.current() === 0x3A /* : */) {
state.raise("Invalid regular expression modifiers");
}
for (var i$1 = 0; i$1 < removeModifiers.length; i$1++) {
var modifier$1 = removeModifiers.charAt(i$1);
if (
removeModifiers.indexOf(modifier$1, i$1 + 1) > -1 ||
addModifiers.indexOf(modifier$1) > -1
) {
state.raise("Duplicate regular expression modifiers");
}
}
}
}
}
if (state.eat(0x3A /* : */)) {
this.regexp_disjunction(state);
if (state.eat(0x29 /* ) */)) {
return true
}
state.raise("Unterminated group");
} }
state.raise("Unterminated group");
} }
state.pos = start; state.pos = start;
} }
@ -4235,6 +4327,23 @@
} }
return false return false
}; };
// RegularExpressionModifiers ::
// [empty]
// RegularExpressionModifiers RegularExpressionModifier
pp$1.regexp_eatModifiers = function(state) {
var modifiers = "";
var ch = 0;
while ((ch = state.current()) !== -1 && isRegularExpressionModifier(ch)) {
modifiers += codePointToString(ch);
state.advance();
}
return modifiers
};
// RegularExpressionModifier :: one of
// `i` `m` `s`
function isRegularExpressionModifier(ch) {
return ch === 0x69 /* i */ || ch === 0x6d /* m */ || ch === 0x73 /* s */
}
// https://www.ecma-international.org/ecma-262/8.0/#prod-annexB-ExtendedAtom // https://www.ecma-international.org/ecma-262/8.0/#prod-annexB-ExtendedAtom
pp$1.regexp_eatExtendedAtom = function(state) { pp$1.regexp_eatExtendedAtom = function(state) {
@ -5990,7 +6099,7 @@
// [walk]: util/walk.js // [walk]: util/walk.js
var version = "8.13.0"; var version = "8.14.0";
Parser.acorn = { Parser.acorn = {
Parser: Parser, Parser: Parser,

View File

@ -1672,6 +1672,8 @@ pp$8.parseExportAllDeclaration = function(node, exports) {
this.expectContextual("from"); this.expectContextual("from");
if (this.type !== types$1.string) { this.unexpected(); } if (this.type !== types$1.string) { this.unexpected(); }
node.source = this.parseExprAtom(); node.source = this.parseExprAtom();
if (this.options.ecmaVersion >= 16)
{ node.attributes = this.parseWithClause(); }
this.semicolon(); this.semicolon();
return this.finishNode(node, "ExportAllDeclaration") return this.finishNode(node, "ExportAllDeclaration")
}; };
@ -1702,6 +1704,8 @@ pp$8.parseExport = function(node, exports) {
if (this.eatContextual("from")) { if (this.eatContextual("from")) {
if (this.type !== types$1.string) { this.unexpected(); } if (this.type !== types$1.string) { this.unexpected(); }
node.source = this.parseExprAtom(); node.source = this.parseExprAtom();
if (this.options.ecmaVersion >= 16)
{ node.attributes = this.parseWithClause(); }
} else { } else {
for (var i = 0, list = node.specifiers; i < list.length; i += 1) { for (var i = 0, list = node.specifiers; i < list.length; i += 1) {
// check for keywords used as local names // check for keywords used as local names
@ -1842,6 +1846,8 @@ pp$8.parseImport = function(node) {
this.expectContextual("from"); this.expectContextual("from");
node.source = this.type === types$1.string ? this.parseExprAtom() : this.unexpected(); node.source = this.type === types$1.string ? this.parseExprAtom() : this.unexpected();
} }
if (this.options.ecmaVersion >= 16)
{ node.attributes = this.parseWithClause(); }
this.semicolon(); this.semicolon();
return this.finishNode(node, "ImportDeclaration") return this.finishNode(node, "ImportDeclaration")
}; };
@ -1902,6 +1908,41 @@ pp$8.parseImportSpecifiers = function() {
return nodes return nodes
}; };
pp$8.parseWithClause = function() {
var nodes = [];
if (!this.eat(types$1._with)) {
return nodes
}
this.expect(types$1.braceL);
var attributeKeys = {};
var first = true;
while (!this.eat(types$1.braceR)) {
if (!first) {
this.expect(types$1.comma);
if (this.afterTrailingComma(types$1.braceR)) { break }
} else { first = false; }
var attr = this.parseImportAttribute();
var keyName = attr.key.type === "Identifier" ? attr.key.name : attr.key.value;
if (hasOwn(attributeKeys, keyName))
{ this.raiseRecoverable(attr.key.start, "Duplicate attribute key '" + keyName + "'"); }
attributeKeys[keyName] = true;
nodes.push(attr);
}
return nodes
};
pp$8.parseImportAttribute = function() {
var node = this.startNode();
node.key = this.type === types$1.string ? this.parseExprAtom() : this.parseIdent(this.options.allowReserved !== "never");
this.expect(types$1.colon);
if (this.type !== types$1.string) {
this.unexpected();
}
node.value = this.parseExprAtom();
return this.finishNode(node, "ImportAttribute")
};
pp$8.parseModuleExportName = function() { pp$8.parseModuleExportName = function() {
if (this.options.ecmaVersion >= 13 && this.type === types$1.string) { if (this.options.ecmaVersion >= 13 && this.type === types$1.string) {
var stringLiteral = this.parseLiteral(this.value); var stringLiteral = this.parseLiteral(this.value);
@ -2969,13 +3010,32 @@ pp$5.parseDynamicImport = function(node) {
// Parse node.source. // Parse node.source.
node.source = this.parseMaybeAssign(); node.source = this.parseMaybeAssign();
// Verify ending. if (this.options.ecmaVersion >= 16) {
if (!this.eat(types$1.parenR)) { if (!this.eat(types$1.parenR)) {
var errorPos = this.start; this.expect(types$1.comma);
if (this.eat(types$1.comma) && this.eat(types$1.parenR)) { if (!this.afterTrailingComma(types$1.parenR)) {
this.raiseRecoverable(errorPos, "Trailing comma is not allowed in import()"); node.options = this.parseMaybeAssign();
if (!this.eat(types$1.parenR)) {
this.expect(types$1.comma);
if (!this.afterTrailingComma(types$1.parenR)) {
this.unexpected();
}
}
} else {
node.options = null;
}
} else { } else {
this.unexpected(errorPos); node.options = null;
}
} else {
// Verify ending.
if (!this.eat(types$1.parenR)) {
var errorPos = this.start;
if (this.eat(types$1.comma) && this.eat(types$1.parenR)) {
this.raiseRecoverable(errorPos, "Trailing comma is not allowed in import()");
} else {
this.unexpected(errorPos);
}
} }
} }
@ -3735,6 +3795,9 @@ pp$2.copyNode = function(node) {
return newNode return newNode
}; };
// This file was generated by "bin/generate-unicode-script-values.js". Do not modify manually!
var scriptValuesAddedInUnicode = "Gara Garay Gukh Gurung_Khema Hrkt Katakana_Or_Hiragana Kawi Kirat_Rai Krai Nag_Mundari Nagm Ol_Onal Onao Sunu Sunuwar Todhri Todr Tulu_Tigalari Tutg Unknown Zzzz";
// This file contains Unicode properties extracted from the ECMAScript specification. // This file contains Unicode properties extracted from the ECMAScript specification.
// The lists are extracted like so: // The lists are extracted like so:
// $$('#table-binary-unicode-properties > figure > table > tbody > tr > td:nth-child(1) code').map(el => el.innerText) // $$('#table-binary-unicode-properties > figure > table > tbody > tr > td:nth-child(1) code').map(el => el.innerText)
@ -3777,7 +3840,7 @@ var ecma10ScriptValues = ecma9ScriptValues + " Dogra Dogr Gunjala_Gondi Gong Han
var ecma11ScriptValues = ecma10ScriptValues + " Elymaic Elym Nandinagari Nand Nyiakeng_Puachue_Hmong Hmnp Wancho Wcho"; var ecma11ScriptValues = ecma10ScriptValues + " Elymaic Elym Nandinagari Nand Nyiakeng_Puachue_Hmong Hmnp Wancho Wcho";
var ecma12ScriptValues = ecma11ScriptValues + " Chorasmian Chrs Diak Dives_Akuru Khitan_Small_Script Kits Yezi Yezidi"; var ecma12ScriptValues = ecma11ScriptValues + " Chorasmian Chrs Diak Dives_Akuru Khitan_Small_Script Kits Yezi Yezidi";
var ecma13ScriptValues = ecma12ScriptValues + " Cypro_Minoan Cpmn Old_Uyghur Ougr Tangsa Tnsa Toto Vithkuqi Vith"; var ecma13ScriptValues = ecma12ScriptValues + " Cypro_Minoan Cpmn Old_Uyghur Ougr Tangsa Tnsa Toto Vithkuqi Vith";
var ecma14ScriptValues = ecma13ScriptValues + " Hrkt Katakana_Or_Hiragana Kawi Nag_Mundari Nagm Unknown Zzzz"; var ecma14ScriptValues = ecma13ScriptValues + " " + scriptValuesAddedInUnicode;
var unicodeScriptValues = { var unicodeScriptValues = {
9: ecma9ScriptValues, 9: ecma9ScriptValues,
@ -4202,12 +4265,41 @@ pp$1.regexp_eatReverseSolidusAtomEscape = function(state) {
pp$1.regexp_eatUncapturingGroup = function(state) { pp$1.regexp_eatUncapturingGroup = function(state) {
var start = state.pos; var start = state.pos;
if (state.eat(0x28 /* ( */)) { if (state.eat(0x28 /* ( */)) {
if (state.eat(0x3F /* ? */) && state.eat(0x3A /* : */)) { if (state.eat(0x3F /* ? */)) {
this.regexp_disjunction(state); if (this.options.ecmaVersion >= 16) {
if (state.eat(0x29 /* ) */)) { var addModifiers = this.regexp_eatModifiers(state);
return true var hasHyphen = state.eat(0x2D /* - */);
if (addModifiers || hasHyphen) {
for (var i = 0; i < addModifiers.length; i++) {
var modifier = addModifiers.charAt(i);
if (addModifiers.indexOf(modifier, i + 1) > -1) {
state.raise("Duplicate regular expression modifiers");
}
}
if (hasHyphen) {
var removeModifiers = this.regexp_eatModifiers(state);
if (!addModifiers && !removeModifiers && state.current() === 0x3A /* : */) {
state.raise("Invalid regular expression modifiers");
}
for (var i$1 = 0; i$1 < removeModifiers.length; i$1++) {
var modifier$1 = removeModifiers.charAt(i$1);
if (
removeModifiers.indexOf(modifier$1, i$1 + 1) > -1 ||
addModifiers.indexOf(modifier$1) > -1
) {
state.raise("Duplicate regular expression modifiers");
}
}
}
}
}
if (state.eat(0x3A /* : */)) {
this.regexp_disjunction(state);
if (state.eat(0x29 /* ) */)) {
return true
}
state.raise("Unterminated group");
} }
state.raise("Unterminated group");
} }
state.pos = start; state.pos = start;
} }
@ -4229,6 +4321,23 @@ pp$1.regexp_eatCapturingGroup = function(state) {
} }
return false return false
}; };
// RegularExpressionModifiers ::
// [empty]
// RegularExpressionModifiers RegularExpressionModifier
pp$1.regexp_eatModifiers = function(state) {
var modifiers = "";
var ch = 0;
while ((ch = state.current()) !== -1 && isRegularExpressionModifier(ch)) {
modifiers += codePointToString(ch);
state.advance();
}
return modifiers
};
// RegularExpressionModifier :: one of
// `i` `m` `s`
function isRegularExpressionModifier(ch) {
return ch === 0x69 /* i */ || ch === 0x6d /* m */ || ch === 0x73 /* s */
}
// https://www.ecma-international.org/ecma-262/8.0/#prod-annexB-ExtendedAtom // https://www.ecma-international.org/ecma-262/8.0/#prod-annexB-ExtendedAtom
pp$1.regexp_eatExtendedAtom = function(state) { pp$1.regexp_eatExtendedAtom = function(state) {
@ -5984,7 +6093,7 @@ pp.readWord = function() {
// [walk]: util/walk.js // [walk]: util/walk.js
var version = "8.13.0"; var version = "8.14.0";
Parser.acorn = { Parser.acorn = {
Parser: Parser, Parser: Parser,

View File

@ -16,7 +16,7 @@
], ],
"./package.json": "./package.json" "./package.json": "./package.json"
}, },
"version": "8.13.0", "version": "8.14.0",
"engines": { "engines": {
"node": ">=0.4.0" "node": ">=0.4.0"
}, },

View File

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