goldstein 3.2.4 → 3.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/ChangeLog +14 -0
- package/README.md +6 -4
- package/bin/gs.js +1 -0
- package/build/parser.cjs +484 -159
- package/package.json +10 -10
- package/packages/goldstein/index.js +4 -8
- package/packages/goldstein/parser.js +6 -2
- package/packages/keyword-arrow/index.js +1 -4
- package/packages/keyword-curry/index.js +1 -0
- package/packages/keyword-fn/index.js +2 -0
- package/packages/keyword-freeze/index.js +3 -4
- package/packages/keyword-guard/index.js +2 -0
- package/packages/keyword-should/index.js +2 -2
- package/packages/keyword-try/index.js +1 -2
- package/packages/operator/index.js +1 -1
- package/packages/operator/scopeflags.js +2 -4
- package/packages/parser/index.js +1 -3
- package/packages/string-interpolation/index.js +3 -5
package/build/parser.cjs
CHANGED
|
@@ -333,6 +333,10 @@ var defaultOptions = {
|
|
|
333
333
|
// allowed and treated as a line comment. Enabled by default when
|
|
334
334
|
// `ecmaVersion` >= 2023.
|
|
335
335
|
allowHashBang: false,
|
|
336
|
+
// By default, the parser will verify that private properties are
|
|
337
|
+
// only used in places where they are valid and have been declared.
|
|
338
|
+
// Set this to false to turn such checks off.
|
|
339
|
+
checkPrivateFields: true,
|
|
336
340
|
// When `locations` is on, `loc` properties holding objects with
|
|
337
341
|
// `start` and `end` properties in `{line, column}` form (with
|
|
338
342
|
// line being 1-based and column 0-based) will be attached to the
|
|
@@ -1030,6 +1034,14 @@ pp$8.parseThrowStatement = function(node) {
|
|
|
1030
1034
|
return this.finishNode(node, "ThrowStatement");
|
|
1031
1035
|
};
|
|
1032
1036
|
var empty$1 = [];
|
|
1037
|
+
pp$8.parseCatchClauseParam = function() {
|
|
1038
|
+
var param = this.parseBindingAtom();
|
|
1039
|
+
var simple = param.type === "Identifier";
|
|
1040
|
+
this.enterScope(simple ? SCOPE_SIMPLE_CATCH : 0);
|
|
1041
|
+
this.checkLValPattern(param, simple ? BIND_SIMPLE_CATCH : BIND_LEXICAL);
|
|
1042
|
+
this.expect(types$1.parenR);
|
|
1043
|
+
return param;
|
|
1044
|
+
};
|
|
1033
1045
|
pp$8.parseTryStatement = function(node) {
|
|
1034
1046
|
this.next();
|
|
1035
1047
|
node.block = this.parseBlock();
|
|
@@ -1038,11 +1050,7 @@ pp$8.parseTryStatement = function(node) {
|
|
|
1038
1050
|
var clause = this.startNode();
|
|
1039
1051
|
this.next();
|
|
1040
1052
|
if (this.eat(types$1.parenL)) {
|
|
1041
|
-
clause.param = this.
|
|
1042
|
-
var simple = clause.param.type === "Identifier";
|
|
1043
|
-
this.enterScope(simple ? SCOPE_SIMPLE_CATCH : 0);
|
|
1044
|
-
this.checkLValPattern(clause.param, simple ? BIND_SIMPLE_CATCH : BIND_LEXICAL);
|
|
1045
|
-
this.expect(types$1.parenR);
|
|
1053
|
+
clause.param = this.parseCatchClauseParam();
|
|
1046
1054
|
} else {
|
|
1047
1055
|
if (this.options.ecmaVersion < 10) {
|
|
1048
1056
|
this.unexpected();
|
|
@@ -1060,9 +1068,9 @@ pp$8.parseTryStatement = function(node) {
|
|
|
1060
1068
|
}
|
|
1061
1069
|
return this.finishNode(node, "TryStatement");
|
|
1062
1070
|
};
|
|
1063
|
-
pp$8.parseVarStatement = function(node, kind) {
|
|
1071
|
+
pp$8.parseVarStatement = function(node, kind, allowMissingInitializer) {
|
|
1064
1072
|
this.next();
|
|
1065
|
-
this.parseVar(node, false, kind);
|
|
1073
|
+
this.parseVar(node, false, kind, allowMissingInitializer);
|
|
1066
1074
|
this.semicolon();
|
|
1067
1075
|
return this.finishNode(node, "VariableDeclaration");
|
|
1068
1076
|
};
|
|
@@ -1167,7 +1175,7 @@ pp$8.parseForIn = function(node, init) {
|
|
|
1167
1175
|
this.labels.pop();
|
|
1168
1176
|
return this.finishNode(node, isForIn ? "ForInStatement" : "ForOfStatement");
|
|
1169
1177
|
};
|
|
1170
|
-
pp$8.parseVar = function(node, isFor, kind) {
|
|
1178
|
+
pp$8.parseVar = function(node, isFor, kind, allowMissingInitializer) {
|
|
1171
1179
|
node.declarations = [];
|
|
1172
1180
|
node.kind = kind;
|
|
1173
1181
|
for (; ; ) {
|
|
@@ -1175,9 +1183,9 @@ pp$8.parseVar = function(node, isFor, kind) {
|
|
|
1175
1183
|
this.parseVarId(decl, kind);
|
|
1176
1184
|
if (this.eat(types$1.eq)) {
|
|
1177
1185
|
decl.init = this.parseMaybeAssign(isFor);
|
|
1178
|
-
} else if (kind === "const" && !(this.type === types$1._in || this.options.ecmaVersion >= 6 && this.isContextual("of"))) {
|
|
1186
|
+
} else if (!allowMissingInitializer && kind === "const" && !(this.type === types$1._in || this.options.ecmaVersion >= 6 && this.isContextual("of"))) {
|
|
1179
1187
|
this.unexpected();
|
|
1180
|
-
} else if (decl.id.type !== "Identifier" && !(isFor && (this.type === types$1._in || this.isContextual("of")))) {
|
|
1188
|
+
} else if (!allowMissingInitializer && decl.id.type !== "Identifier" && !(isFor && (this.type === types$1._in || this.isContextual("of")))) {
|
|
1181
1189
|
this.raise(this.lastTokEnd, "Complex binding patterns require an initialization value");
|
|
1182
1190
|
} else {
|
|
1183
1191
|
decl.init = null;
|
|
@@ -1250,7 +1258,7 @@ pp$8.parseClass = function(node, isStatement) {
|
|
|
1250
1258
|
classBody.body.push(element);
|
|
1251
1259
|
if (element.type === "MethodDefinition" && element.kind === "constructor") {
|
|
1252
1260
|
if (hadConstructor) {
|
|
1253
|
-
this.
|
|
1261
|
+
this.raiseRecoverable(element.start, "Duplicate constructor in the same class");
|
|
1254
1262
|
}
|
|
1255
1263
|
hadConstructor = true;
|
|
1256
1264
|
} else if (element.key && element.key.type === "PrivateIdentifier" && isPrivateNameConflicted(privateNameMap, element)) {
|
|
@@ -1423,6 +1431,9 @@ pp$8.exitClassBody = function() {
|
|
|
1423
1431
|
var ref2 = this.privateNameStack.pop();
|
|
1424
1432
|
var declared = ref2.declared;
|
|
1425
1433
|
var used = ref2.used;
|
|
1434
|
+
if (!this.options.checkPrivateFields) {
|
|
1435
|
+
return;
|
|
1436
|
+
}
|
|
1426
1437
|
var len = this.privateNameStack.length;
|
|
1427
1438
|
var parent = len === 0 ? null : this.privateNameStack[len - 1];
|
|
1428
1439
|
for (var i = 0; i < used.length; ++i) {
|
|
@@ -1458,46 +1469,35 @@ function checkKeyName(node, name) {
|
|
|
1458
1469
|
var key = node.key;
|
|
1459
1470
|
return !computed && (key.type === "Identifier" && key.name === name || key.type === "Literal" && key.value === name);
|
|
1460
1471
|
}
|
|
1472
|
+
pp$8.parseExportAllDeclaration = function(node, exports) {
|
|
1473
|
+
if (this.options.ecmaVersion >= 11) {
|
|
1474
|
+
if (this.eatContextual("as")) {
|
|
1475
|
+
node.exported = this.parseModuleExportName();
|
|
1476
|
+
this.checkExport(exports, node.exported, this.lastTokStart);
|
|
1477
|
+
} else {
|
|
1478
|
+
node.exported = null;
|
|
1479
|
+
}
|
|
1480
|
+
}
|
|
1481
|
+
this.expectContextual("from");
|
|
1482
|
+
if (this.type !== types$1.string) {
|
|
1483
|
+
this.unexpected();
|
|
1484
|
+
}
|
|
1485
|
+
node.source = this.parseExprAtom();
|
|
1486
|
+
this.semicolon();
|
|
1487
|
+
return this.finishNode(node, "ExportAllDeclaration");
|
|
1488
|
+
};
|
|
1461
1489
|
pp$8.parseExport = function(node, exports) {
|
|
1462
1490
|
this.next();
|
|
1463
1491
|
if (this.eat(types$1.star)) {
|
|
1464
|
-
|
|
1465
|
-
if (this.eatContextual("as")) {
|
|
1466
|
-
node.exported = this.parseModuleExportName();
|
|
1467
|
-
this.checkExport(exports, node.exported, this.lastTokStart);
|
|
1468
|
-
} else {
|
|
1469
|
-
node.exported = null;
|
|
1470
|
-
}
|
|
1471
|
-
}
|
|
1472
|
-
this.expectContextual("from");
|
|
1473
|
-
if (this.type !== types$1.string) {
|
|
1474
|
-
this.unexpected();
|
|
1475
|
-
}
|
|
1476
|
-
node.source = this.parseExprAtom();
|
|
1477
|
-
this.semicolon();
|
|
1478
|
-
return this.finishNode(node, "ExportAllDeclaration");
|
|
1492
|
+
return this.parseExportAllDeclaration(node, exports);
|
|
1479
1493
|
}
|
|
1480
1494
|
if (this.eat(types$1._default)) {
|
|
1481
1495
|
this.checkExport(exports, "default", this.lastTokStart);
|
|
1482
|
-
|
|
1483
|
-
if (this.type === types$1._function || (isAsync = this.isAsyncFunction())) {
|
|
1484
|
-
var fNode = this.startNode();
|
|
1485
|
-
this.next();
|
|
1486
|
-
if (isAsync) {
|
|
1487
|
-
this.next();
|
|
1488
|
-
}
|
|
1489
|
-
node.declaration = this.parseFunction(fNode, FUNC_STATEMENT | FUNC_NULLABLE_ID, false, isAsync);
|
|
1490
|
-
} else if (this.type === types$1._class) {
|
|
1491
|
-
var cNode = this.startNode();
|
|
1492
|
-
node.declaration = this.parseClass(cNode, "nullableID");
|
|
1493
|
-
} else {
|
|
1494
|
-
node.declaration = this.parseMaybeAssign();
|
|
1495
|
-
this.semicolon();
|
|
1496
|
-
}
|
|
1496
|
+
node.declaration = this.parseExportDefaultDeclaration();
|
|
1497
1497
|
return this.finishNode(node, "ExportDefaultDeclaration");
|
|
1498
1498
|
}
|
|
1499
1499
|
if (this.shouldParseExportStatement()) {
|
|
1500
|
-
node.declaration = this.
|
|
1500
|
+
node.declaration = this.parseExportDeclaration(node);
|
|
1501
1501
|
if (node.declaration.type === "VariableDeclaration") {
|
|
1502
1502
|
this.checkVariableExport(exports, node.declaration.declarations);
|
|
1503
1503
|
} else {
|
|
@@ -1528,6 +1528,27 @@ pp$8.parseExport = function(node, exports) {
|
|
|
1528
1528
|
}
|
|
1529
1529
|
return this.finishNode(node, "ExportNamedDeclaration");
|
|
1530
1530
|
};
|
|
1531
|
+
pp$8.parseExportDeclaration = function(node) {
|
|
1532
|
+
return this.parseStatement(null);
|
|
1533
|
+
};
|
|
1534
|
+
pp$8.parseExportDefaultDeclaration = function() {
|
|
1535
|
+
var isAsync;
|
|
1536
|
+
if (this.type === types$1._function || (isAsync = this.isAsyncFunction())) {
|
|
1537
|
+
var fNode = this.startNode();
|
|
1538
|
+
this.next();
|
|
1539
|
+
if (isAsync) {
|
|
1540
|
+
this.next();
|
|
1541
|
+
}
|
|
1542
|
+
return this.parseFunction(fNode, FUNC_STATEMENT | FUNC_NULLABLE_ID, false, isAsync);
|
|
1543
|
+
} else if (this.type === types$1._class) {
|
|
1544
|
+
var cNode = this.startNode();
|
|
1545
|
+
return this.parseClass(cNode, "nullableID");
|
|
1546
|
+
} else {
|
|
1547
|
+
var declaration = this.parseMaybeAssign();
|
|
1548
|
+
this.semicolon();
|
|
1549
|
+
return declaration;
|
|
1550
|
+
}
|
|
1551
|
+
};
|
|
1531
1552
|
pp$8.checkExport = function(exports, name, pos) {
|
|
1532
1553
|
if (!exports) {
|
|
1533
1554
|
return;
|
|
@@ -1578,6 +1599,17 @@ pp$8.checkVariableExport = function(exports, decls) {
|
|
|
1578
1599
|
pp$8.shouldParseExportStatement = function() {
|
|
1579
1600
|
return this.type.keyword === "var" || this.type.keyword === "const" || this.type.keyword === "class" || this.type.keyword === "function" || this.isLet() || this.isAsyncFunction();
|
|
1580
1601
|
};
|
|
1602
|
+
pp$8.parseExportSpecifier = function(exports) {
|
|
1603
|
+
var node = this.startNode();
|
|
1604
|
+
node.local = this.parseModuleExportName();
|
|
1605
|
+
node.exported = this.eatContextual("as") ? this.parseModuleExportName() : node.local;
|
|
1606
|
+
this.checkExport(
|
|
1607
|
+
exports,
|
|
1608
|
+
node.exported,
|
|
1609
|
+
node.exported.start
|
|
1610
|
+
);
|
|
1611
|
+
return this.finishNode(node, "ExportSpecifier");
|
|
1612
|
+
};
|
|
1581
1613
|
pp$8.parseExportSpecifiers = function(exports) {
|
|
1582
1614
|
var nodes = [], first = true;
|
|
1583
1615
|
this.expect(types$1.braceL);
|
|
@@ -1590,15 +1622,7 @@ pp$8.parseExportSpecifiers = function(exports) {
|
|
|
1590
1622
|
} else {
|
|
1591
1623
|
first = false;
|
|
1592
1624
|
}
|
|
1593
|
-
|
|
1594
|
-
node.local = this.parseModuleExportName();
|
|
1595
|
-
node.exported = this.eatContextual("as") ? this.parseModuleExportName() : node.local;
|
|
1596
|
-
this.checkExport(
|
|
1597
|
-
exports,
|
|
1598
|
-
node.exported,
|
|
1599
|
-
node.exported.start
|
|
1600
|
-
);
|
|
1601
|
-
nodes.push(this.finishNode(node, "ExportSpecifier"));
|
|
1625
|
+
nodes.push(this.parseExportSpecifier(exports));
|
|
1602
1626
|
}
|
|
1603
1627
|
return nodes;
|
|
1604
1628
|
};
|
|
@@ -1615,24 +1639,42 @@ pp$8.parseImport = function(node) {
|
|
|
1615
1639
|
this.semicolon();
|
|
1616
1640
|
return this.finishNode(node, "ImportDeclaration");
|
|
1617
1641
|
};
|
|
1642
|
+
pp$8.parseImportSpecifier = function() {
|
|
1643
|
+
var node = this.startNode();
|
|
1644
|
+
node.imported = this.parseModuleExportName();
|
|
1645
|
+
if (this.eatContextual("as")) {
|
|
1646
|
+
node.local = this.parseIdent();
|
|
1647
|
+
} else {
|
|
1648
|
+
this.checkUnreserved(node.imported);
|
|
1649
|
+
node.local = node.imported;
|
|
1650
|
+
}
|
|
1651
|
+
this.checkLValSimple(node.local, BIND_LEXICAL);
|
|
1652
|
+
return this.finishNode(node, "ImportSpecifier");
|
|
1653
|
+
};
|
|
1654
|
+
pp$8.parseImportDefaultSpecifier = function() {
|
|
1655
|
+
var node = this.startNode();
|
|
1656
|
+
node.local = this.parseIdent();
|
|
1657
|
+
this.checkLValSimple(node.local, BIND_LEXICAL);
|
|
1658
|
+
return this.finishNode(node, "ImportDefaultSpecifier");
|
|
1659
|
+
};
|
|
1660
|
+
pp$8.parseImportNamespaceSpecifier = function() {
|
|
1661
|
+
var node = this.startNode();
|
|
1662
|
+
this.next();
|
|
1663
|
+
this.expectContextual("as");
|
|
1664
|
+
node.local = this.parseIdent();
|
|
1665
|
+
this.checkLValSimple(node.local, BIND_LEXICAL);
|
|
1666
|
+
return this.finishNode(node, "ImportNamespaceSpecifier");
|
|
1667
|
+
};
|
|
1618
1668
|
pp$8.parseImportSpecifiers = function() {
|
|
1619
1669
|
var nodes = [], first = true;
|
|
1620
1670
|
if (this.type === types$1.name) {
|
|
1621
|
-
|
|
1622
|
-
node.local = this.parseIdent();
|
|
1623
|
-
this.checkLValSimple(node.local, BIND_LEXICAL);
|
|
1624
|
-
nodes.push(this.finishNode(node, "ImportDefaultSpecifier"));
|
|
1671
|
+
nodes.push(this.parseImportDefaultSpecifier());
|
|
1625
1672
|
if (!this.eat(types$1.comma)) {
|
|
1626
1673
|
return nodes;
|
|
1627
1674
|
}
|
|
1628
1675
|
}
|
|
1629
1676
|
if (this.type === types$1.star) {
|
|
1630
|
-
|
|
1631
|
-
this.next();
|
|
1632
|
-
this.expectContextual("as");
|
|
1633
|
-
node$1.local = this.parseIdent();
|
|
1634
|
-
this.checkLValSimple(node$1.local, BIND_LEXICAL);
|
|
1635
|
-
nodes.push(this.finishNode(node$1, "ImportNamespaceSpecifier"));
|
|
1677
|
+
nodes.push(this.parseImportNamespaceSpecifier());
|
|
1636
1678
|
return nodes;
|
|
1637
1679
|
}
|
|
1638
1680
|
this.expect(types$1.braceL);
|
|
@@ -1645,16 +1687,7 @@ pp$8.parseImportSpecifiers = function() {
|
|
|
1645
1687
|
} else {
|
|
1646
1688
|
first = false;
|
|
1647
1689
|
}
|
|
1648
|
-
|
|
1649
|
-
node$2.imported = this.parseModuleExportName();
|
|
1650
|
-
if (this.eatContextual("as")) {
|
|
1651
|
-
node$2.local = this.parseIdent();
|
|
1652
|
-
} else {
|
|
1653
|
-
this.checkUnreserved(node$2.imported);
|
|
1654
|
-
node$2.local = node$2.imported;
|
|
1655
|
-
}
|
|
1656
|
-
this.checkLValSimple(node$2.local, BIND_LEXICAL);
|
|
1657
|
-
nodes.push(this.finishNode(node$2, "ImportSpecifier"));
|
|
1690
|
+
nodes.push(this.parseImportSpecifier());
|
|
1658
1691
|
}
|
|
1659
1692
|
return nodes;
|
|
1660
1693
|
};
|
|
@@ -1795,7 +1828,7 @@ pp$7.parseBindingAtom = function() {
|
|
|
1795
1828
|
}
|
|
1796
1829
|
return this.parseIdent();
|
|
1797
1830
|
};
|
|
1798
|
-
pp$7.parseBindingList = function(close, allowEmpty, allowTrailingComma) {
|
|
1831
|
+
pp$7.parseBindingList = function(close, allowEmpty, allowTrailingComma, allowModifiers) {
|
|
1799
1832
|
var elts = [], first = true;
|
|
1800
1833
|
while (!this.eat(close)) {
|
|
1801
1834
|
if (first) {
|
|
@@ -1812,18 +1845,21 @@ pp$7.parseBindingList = function(close, allowEmpty, allowTrailingComma) {
|
|
|
1812
1845
|
this.parseBindingListItem(rest);
|
|
1813
1846
|
elts.push(rest);
|
|
1814
1847
|
if (this.type === types$1.comma) {
|
|
1815
|
-
this.
|
|
1848
|
+
this.raiseRecoverable(this.start, "Comma is not permitted after the rest element");
|
|
1816
1849
|
}
|
|
1817
1850
|
this.expect(close);
|
|
1818
1851
|
break;
|
|
1819
1852
|
} else {
|
|
1820
|
-
|
|
1821
|
-
this.parseBindingListItem(elem);
|
|
1822
|
-
elts.push(elem);
|
|
1853
|
+
elts.push(this.parseAssignableListItem(allowModifiers));
|
|
1823
1854
|
}
|
|
1824
1855
|
}
|
|
1825
1856
|
return elts;
|
|
1826
1857
|
};
|
|
1858
|
+
pp$7.parseAssignableListItem = function(allowModifiers) {
|
|
1859
|
+
var elem = this.parseMaybeDefault(this.start, this.startLoc);
|
|
1860
|
+
this.parseBindingListItem(elem);
|
|
1861
|
+
return elem;
|
|
1862
|
+
};
|
|
1827
1863
|
pp$7.parseBindingListItem = function(param) {
|
|
1828
1864
|
return param;
|
|
1829
1865
|
};
|
|
@@ -2266,7 +2302,7 @@ pp$5.parseMaybeUnary = function(refDestructuringErrors, sawUnary, incDec, forIni
|
|
|
2266
2302
|
}
|
|
2267
2303
|
expr = this.finishNode(node, update ? "UpdateExpression" : "UnaryExpression");
|
|
2268
2304
|
} else if (!sawUnary && this.type === types$1.privateId) {
|
|
2269
|
-
if (forInit || this.privateNameStack.length === 0) {
|
|
2305
|
+
if ((forInit || this.privateNameStack.length === 0) && this.options.checkPrivateFields) {
|
|
2270
2306
|
this.unexpected();
|
|
2271
2307
|
}
|
|
2272
2308
|
expr = this.parsePrivateIdent();
|
|
@@ -2340,6 +2376,12 @@ pp$5.parseSubscripts = function(base, startPos, startLoc, noCalls, forInit) {
|
|
|
2340
2376
|
base = element;
|
|
2341
2377
|
}
|
|
2342
2378
|
};
|
|
2379
|
+
pp$5.shouldParseAsyncArrow = function() {
|
|
2380
|
+
return !this.canInsertSemicolon() && this.eat(types$1.arrow);
|
|
2381
|
+
};
|
|
2382
|
+
pp$5.parseSubscriptAsyncArrow = function(startPos, startLoc, exprList, forInit) {
|
|
2383
|
+
return this.parseArrowExpression(this.startNodeAt(startPos, startLoc), exprList, true, forInit);
|
|
2384
|
+
};
|
|
2343
2385
|
pp$5.parseSubscript = function(base, startPos, startLoc, noCalls, maybeAsyncArrow, optionalChained, forInit) {
|
|
2344
2386
|
var optionalSupported = this.options.ecmaVersion >= 11;
|
|
2345
2387
|
var optional = optionalSupported && this.eat(types$1.questionDot);
|
|
@@ -2369,7 +2411,7 @@ pp$5.parseSubscript = function(base, startPos, startLoc, noCalls, maybeAsyncArro
|
|
|
2369
2411
|
this.awaitPos = 0;
|
|
2370
2412
|
this.awaitIdentPos = 0;
|
|
2371
2413
|
var exprList = this.parseExprList(types$1.parenR, this.options.ecmaVersion >= 8, false, refDestructuringErrors);
|
|
2372
|
-
if (maybeAsyncArrow && !optional &&
|
|
2414
|
+
if (maybeAsyncArrow && !optional && this.shouldParseAsyncArrow()) {
|
|
2373
2415
|
this.checkPatternErrors(refDestructuringErrors, false);
|
|
2374
2416
|
this.checkYieldAwaitInDefaultParams();
|
|
2375
2417
|
if (this.awaitIdentPos > 0) {
|
|
@@ -2378,7 +2420,7 @@ pp$5.parseSubscript = function(base, startPos, startLoc, noCalls, maybeAsyncArro
|
|
|
2378
2420
|
this.yieldPos = oldYieldPos;
|
|
2379
2421
|
this.awaitPos = oldAwaitPos;
|
|
2380
2422
|
this.awaitIdentPos = oldAwaitIdentPos;
|
|
2381
|
-
return this.
|
|
2423
|
+
return this.parseSubscriptAsyncArrow(startPos, startLoc, exprList, forInit);
|
|
2382
2424
|
}
|
|
2383
2425
|
this.checkExpressionErrors(refDestructuringErrors, true);
|
|
2384
2426
|
this.yieldPos = oldYieldPos || this.yieldPos;
|
|
@@ -2402,7 +2444,7 @@ pp$5.parseSubscript = function(base, startPos, startLoc, noCalls, maybeAsyncArro
|
|
|
2402
2444
|
}
|
|
2403
2445
|
return base;
|
|
2404
2446
|
};
|
|
2405
|
-
pp$5.parseExprAtom = function(refDestructuringErrors, forInit) {
|
|
2447
|
+
pp$5.parseExprAtom = function(refDestructuringErrors, forInit, forNew) {
|
|
2406
2448
|
if (this.type === types$1.slash) {
|
|
2407
2449
|
this.readRegexp();
|
|
2408
2450
|
}
|
|
@@ -2492,28 +2534,30 @@ pp$5.parseExprAtom = function(refDestructuringErrors, forInit) {
|
|
|
2492
2534
|
return this.parseTemplate();
|
|
2493
2535
|
case types$1._import:
|
|
2494
2536
|
if (this.options.ecmaVersion >= 11) {
|
|
2495
|
-
return this.parseExprImport();
|
|
2537
|
+
return this.parseExprImport(forNew);
|
|
2496
2538
|
} else {
|
|
2497
2539
|
return this.unexpected();
|
|
2498
2540
|
}
|
|
2499
2541
|
default:
|
|
2500
|
-
this.
|
|
2542
|
+
return this.parseExprAtomDefault();
|
|
2501
2543
|
}
|
|
2502
2544
|
};
|
|
2503
|
-
pp$5.
|
|
2545
|
+
pp$5.parseExprAtomDefault = function() {
|
|
2546
|
+
this.unexpected();
|
|
2547
|
+
};
|
|
2548
|
+
pp$5.parseExprImport = function(forNew) {
|
|
2504
2549
|
var node = this.startNode();
|
|
2505
2550
|
if (this.containsEsc) {
|
|
2506
2551
|
this.raiseRecoverable(this.start, "Escape sequence in keyword import");
|
|
2507
2552
|
}
|
|
2508
2553
|
var meta = this.parseIdent(true);
|
|
2509
|
-
|
|
2510
|
-
|
|
2511
|
-
|
|
2512
|
-
|
|
2513
|
-
|
|
2514
|
-
|
|
2515
|
-
|
|
2516
|
-
this.unexpected();
|
|
2554
|
+
if (this.type === types$1.parenL && !forNew) {
|
|
2555
|
+
return this.parseDynamicImport(node);
|
|
2556
|
+
} else if (this.type === types$1.dot) {
|
|
2557
|
+
node.meta = meta;
|
|
2558
|
+
return this.parseImportMeta(node);
|
|
2559
|
+
} else {
|
|
2560
|
+
this.unexpected();
|
|
2517
2561
|
}
|
|
2518
2562
|
};
|
|
2519
2563
|
pp$5.parseDynamicImport = function(node) {
|
|
@@ -2560,6 +2604,9 @@ pp$5.parseParenExpression = function() {
|
|
|
2560
2604
|
this.expect(types$1.parenR);
|
|
2561
2605
|
return val;
|
|
2562
2606
|
};
|
|
2607
|
+
pp$5.shouldParseArrow = function(exprList) {
|
|
2608
|
+
return !this.canInsertSemicolon();
|
|
2609
|
+
};
|
|
2563
2610
|
pp$5.parseParenAndDistinguishExpression = function(canBeArrow, forInit) {
|
|
2564
2611
|
var startPos = this.start, startLoc = this.startLoc, val, allowTrailingComma = this.options.ecmaVersion >= 8;
|
|
2565
2612
|
if (this.options.ecmaVersion >= 6) {
|
|
@@ -2578,7 +2625,10 @@ pp$5.parseParenAndDistinguishExpression = function(canBeArrow, forInit) {
|
|
|
2578
2625
|
spreadStart = this.start;
|
|
2579
2626
|
exprList.push(this.parseParenItem(this.parseRestBinding()));
|
|
2580
2627
|
if (this.type === types$1.comma) {
|
|
2581
|
-
this.
|
|
2628
|
+
this.raiseRecoverable(
|
|
2629
|
+
this.start,
|
|
2630
|
+
"Comma is not permitted after the rest element"
|
|
2631
|
+
);
|
|
2582
2632
|
}
|
|
2583
2633
|
break;
|
|
2584
2634
|
} else {
|
|
@@ -2587,7 +2637,7 @@ pp$5.parseParenAndDistinguishExpression = function(canBeArrow, forInit) {
|
|
|
2587
2637
|
}
|
|
2588
2638
|
var innerEndPos = this.lastTokEnd, innerEndLoc = this.lastTokEndLoc;
|
|
2589
2639
|
this.expect(types$1.parenR);
|
|
2590
|
-
if (canBeArrow &&
|
|
2640
|
+
if (canBeArrow && this.shouldParseArrow(exprList) && this.eat(types$1.arrow)) {
|
|
2591
2641
|
this.checkPatternErrors(refDestructuringErrors, false);
|
|
2592
2642
|
this.checkYieldAwaitInDefaultParams();
|
|
2593
2643
|
this.yieldPos = oldYieldPos;
|
|
@@ -2649,11 +2699,8 @@ pp$5.parseNew = function() {
|
|
|
2649
2699
|
}
|
|
2650
2700
|
return this.finishNode(node, "MetaProperty");
|
|
2651
2701
|
}
|
|
2652
|
-
var startPos = this.start, startLoc = this.startLoc
|
|
2653
|
-
node.callee = this.parseSubscripts(this.parseExprAtom(), startPos, startLoc, true, false);
|
|
2654
|
-
if (isImport && node.callee.type === "ImportExpression") {
|
|
2655
|
-
this.raise(startPos, "Cannot use new with import()");
|
|
2656
|
-
}
|
|
2702
|
+
var startPos = this.start, startLoc = this.startLoc;
|
|
2703
|
+
node.callee = this.parseSubscripts(this.parseExprAtom(null, false, true), startPos, startLoc, true, false);
|
|
2657
2704
|
if (this.eat(types$1.parenL)) {
|
|
2658
2705
|
node.arguments = this.parseExprList(types$1.parenR, this.options.ecmaVersion >= 8, false);
|
|
2659
2706
|
} else {
|
|
@@ -2735,7 +2782,7 @@ pp$5.parseProperty = function(isPattern, refDestructuringErrors) {
|
|
|
2735
2782
|
if (isPattern) {
|
|
2736
2783
|
prop.argument = this.parseIdent(false);
|
|
2737
2784
|
if (this.type === types$1.comma) {
|
|
2738
|
-
this.
|
|
2785
|
+
this.raiseRecoverable(this.start, "Comma is not permitted after the rest element");
|
|
2739
2786
|
}
|
|
2740
2787
|
return this.finishNode(prop, "RestElement");
|
|
2741
2788
|
}
|
|
@@ -2768,6 +2815,24 @@ pp$5.parseProperty = function(isPattern, refDestructuringErrors) {
|
|
|
2768
2815
|
this.parsePropertyValue(prop, isPattern, isGenerator, isAsync, startPos, startLoc, refDestructuringErrors, containsEsc);
|
|
2769
2816
|
return this.finishNode(prop, "Property");
|
|
2770
2817
|
};
|
|
2818
|
+
pp$5.parseGetterSetter = function(prop) {
|
|
2819
|
+
prop.kind = prop.key.name;
|
|
2820
|
+
this.parsePropertyName(prop);
|
|
2821
|
+
prop.value = this.parseMethod(false);
|
|
2822
|
+
var paramCount = prop.kind === "get" ? 0 : 1;
|
|
2823
|
+
if (prop.value.params.length !== paramCount) {
|
|
2824
|
+
var start = prop.value.start;
|
|
2825
|
+
if (prop.kind === "get") {
|
|
2826
|
+
this.raiseRecoverable(start, "getter should have no params");
|
|
2827
|
+
} else {
|
|
2828
|
+
this.raiseRecoverable(start, "setter should have exactly one param");
|
|
2829
|
+
}
|
|
2830
|
+
} else {
|
|
2831
|
+
if (prop.kind === "set" && prop.value.params[0].type === "RestElement") {
|
|
2832
|
+
this.raiseRecoverable(prop.value.params[0].start, "Setter cannot use rest params");
|
|
2833
|
+
}
|
|
2834
|
+
}
|
|
2835
|
+
};
|
|
2771
2836
|
pp$5.parsePropertyValue = function(prop, isPattern, isGenerator, isAsync, startPos, startLoc, refDestructuringErrors, containsEsc) {
|
|
2772
2837
|
if ((isGenerator || isAsync) && this.type === types$1.colon) {
|
|
2773
2838
|
this.unexpected();
|
|
@@ -2786,22 +2851,7 @@ pp$5.parsePropertyValue = function(prop, isPattern, isGenerator, isAsync, startP
|
|
|
2786
2851
|
if (isGenerator || isAsync) {
|
|
2787
2852
|
this.unexpected();
|
|
2788
2853
|
}
|
|
2789
|
-
|
|
2790
|
-
this.parsePropertyName(prop);
|
|
2791
|
-
prop.value = this.parseMethod(false);
|
|
2792
|
-
var paramCount = prop.kind === "get" ? 0 : 1;
|
|
2793
|
-
if (prop.value.params.length !== paramCount) {
|
|
2794
|
-
var start = prop.value.start;
|
|
2795
|
-
if (prop.kind === "get") {
|
|
2796
|
-
this.raiseRecoverable(start, "getter should have no params");
|
|
2797
|
-
} else {
|
|
2798
|
-
this.raiseRecoverable(start, "setter should have exactly one param");
|
|
2799
|
-
}
|
|
2800
|
-
} else {
|
|
2801
|
-
if (prop.kind === "set" && prop.value.params[0].type === "RestElement") {
|
|
2802
|
-
this.raiseRecoverable(prop.value.params[0].start, "Setter cannot use rest params");
|
|
2803
|
-
}
|
|
2804
|
-
}
|
|
2854
|
+
this.parseGetterSetter(prop);
|
|
2805
2855
|
} else if (this.options.ecmaVersion >= 6 && !prop.computed && prop.key.type === "Identifier") {
|
|
2806
2856
|
if (isGenerator || isAsync) {
|
|
2807
2857
|
this.unexpected();
|
|
@@ -2991,6 +3041,18 @@ pp$5.checkUnreserved = function(ref2) {
|
|
|
2991
3041
|
}
|
|
2992
3042
|
};
|
|
2993
3043
|
pp$5.parseIdent = function(liberal) {
|
|
3044
|
+
var node = this.parseIdentNode();
|
|
3045
|
+
this.next(!!liberal);
|
|
3046
|
+
this.finishNode(node, "Identifier");
|
|
3047
|
+
if (!liberal) {
|
|
3048
|
+
this.checkUnreserved(node);
|
|
3049
|
+
if (node.name === "await" && !this.awaitIdentPos) {
|
|
3050
|
+
this.awaitIdentPos = node.start;
|
|
3051
|
+
}
|
|
3052
|
+
}
|
|
3053
|
+
return node;
|
|
3054
|
+
};
|
|
3055
|
+
pp$5.parseIdentNode = function() {
|
|
2994
3056
|
var node = this.startNode();
|
|
2995
3057
|
if (this.type === types$1.name) {
|
|
2996
3058
|
node.name = this.value;
|
|
@@ -3002,14 +3064,6 @@ pp$5.parseIdent = function(liberal) {
|
|
|
3002
3064
|
} else {
|
|
3003
3065
|
this.unexpected();
|
|
3004
3066
|
}
|
|
3005
|
-
this.next(!!liberal);
|
|
3006
|
-
this.finishNode(node, "Identifier");
|
|
3007
|
-
if (!liberal) {
|
|
3008
|
-
this.checkUnreserved(node);
|
|
3009
|
-
if (node.name === "await" && !this.awaitIdentPos) {
|
|
3010
|
-
this.awaitIdentPos = node.start;
|
|
3011
|
-
}
|
|
3012
|
-
}
|
|
3013
3067
|
return node;
|
|
3014
3068
|
};
|
|
3015
3069
|
pp$5.parsePrivateIdent = function() {
|
|
@@ -3021,10 +3075,12 @@ pp$5.parsePrivateIdent = function() {
|
|
|
3021
3075
|
}
|
|
3022
3076
|
this.next();
|
|
3023
3077
|
this.finishNode(node, "PrivateIdentifier");
|
|
3024
|
-
if (this.
|
|
3025
|
-
this.
|
|
3026
|
-
|
|
3027
|
-
|
|
3078
|
+
if (this.options.checkPrivateFields) {
|
|
3079
|
+
if (this.privateNameStack.length === 0) {
|
|
3080
|
+
this.raise(node.start, "Private field '#" + node.name + "' must be declared in an enclosing class");
|
|
3081
|
+
} else {
|
|
3082
|
+
this.privateNameStack[this.privateNameStack.length - 1].used.push(node);
|
|
3083
|
+
}
|
|
3028
3084
|
}
|
|
3029
3085
|
return node;
|
|
3030
3086
|
};
|
|
@@ -3208,13 +3264,22 @@ var unicodeBinaryProperties = {
|
|
|
3208
3264
|
13: ecma13BinaryProperties,
|
|
3209
3265
|
14: ecma14BinaryProperties
|
|
3210
3266
|
};
|
|
3267
|
+
var ecma14BinaryPropertiesOfStrings = "Basic_Emoji Emoji_Keycap_Sequence RGI_Emoji_Modifier_Sequence RGI_Emoji_Flag_Sequence RGI_Emoji_Tag_Sequence RGI_Emoji_ZWJ_Sequence RGI_Emoji";
|
|
3268
|
+
var unicodeBinaryPropertiesOfStrings = {
|
|
3269
|
+
9: "",
|
|
3270
|
+
10: "",
|
|
3271
|
+
11: "",
|
|
3272
|
+
12: "",
|
|
3273
|
+
13: "",
|
|
3274
|
+
14: ecma14BinaryPropertiesOfStrings
|
|
3275
|
+
};
|
|
3211
3276
|
var unicodeGeneralCategoryValues = "Cased_Letter LC Close_Punctuation Pe Connector_Punctuation Pc Control Cc cntrl Currency_Symbol Sc Dash_Punctuation Pd Decimal_Number Nd digit Enclosing_Mark Me Final_Punctuation Pf Format Cf Initial_Punctuation Pi Letter L Letter_Number Nl Line_Separator Zl Lowercase_Letter Ll Mark M Combining_Mark Math_Symbol Sm Modifier_Letter Lm Modifier_Symbol Sk Nonspacing_Mark Mn Number N Open_Punctuation Ps Other C Other_Letter Lo Other_Number No Other_Punctuation Po Other_Symbol So Paragraph_Separator Zp Private_Use Co Punctuation P punct Separator Z Space_Separator Zs Spacing_Mark Mc Surrogate Cs Symbol S Titlecase_Letter Lt Unassigned Cn Uppercase_Letter Lu";
|
|
3212
3277
|
var ecma9ScriptValues = "Adlam Adlm Ahom Anatolian_Hieroglyphs Hluw Arabic Arab Armenian Armn Avestan Avst Balinese Bali Bamum Bamu Bassa_Vah Bass Batak Batk Bengali Beng Bhaiksuki Bhks Bopomofo Bopo Brahmi Brah Braille Brai Buginese Bugi Buhid Buhd Canadian_Aboriginal Cans Carian Cari Caucasian_Albanian Aghb Chakma Cakm Cham Cham Cherokee Cher Common Zyyy Coptic Copt Qaac Cuneiform Xsux Cypriot Cprt Cyrillic Cyrl Deseret Dsrt Devanagari Deva Duployan Dupl Egyptian_Hieroglyphs Egyp Elbasan Elba Ethiopic Ethi Georgian Geor Glagolitic Glag Gothic Goth Grantha Gran Greek Grek Gujarati Gujr Gurmukhi Guru Han Hani Hangul Hang Hanunoo Hano Hatran Hatr Hebrew Hebr Hiragana Hira Imperial_Aramaic Armi Inherited Zinh Qaai Inscriptional_Pahlavi Phli Inscriptional_Parthian Prti Javanese Java Kaithi Kthi Kannada Knda Katakana Kana Kayah_Li Kali Kharoshthi Khar Khmer Khmr Khojki Khoj Khudawadi Sind Lao Laoo Latin Latn Lepcha Lepc Limbu Limb Linear_A Lina Linear_B Linb Lisu Lisu Lycian Lyci Lydian Lydi Mahajani Mahj Malayalam Mlym Mandaic Mand Manichaean Mani Marchen Marc Masaram_Gondi Gonm Meetei_Mayek Mtei Mende_Kikakui Mend Meroitic_Cursive Merc Meroitic_Hieroglyphs Mero Miao Plrd Modi Mongolian Mong Mro Mroo Multani Mult Myanmar Mymr Nabataean Nbat New_Tai_Lue Talu Newa Newa Nko Nkoo Nushu Nshu Ogham Ogam Ol_Chiki Olck Old_Hungarian Hung Old_Italic Ital Old_North_Arabian Narb Old_Permic Perm Old_Persian Xpeo Old_South_Arabian Sarb Old_Turkic Orkh Oriya Orya Osage Osge Osmanya Osma Pahawh_Hmong Hmng Palmyrene Palm Pau_Cin_Hau Pauc Phags_Pa Phag Phoenician Phnx Psalter_Pahlavi Phlp Rejang Rjng Runic Runr Samaritan Samr Saurashtra Saur Sharada Shrd Shavian Shaw Siddham Sidd SignWriting Sgnw Sinhala Sinh Sora_Sompeng Sora Soyombo Soyo Sundanese Sund Syloti_Nagri Sylo Syriac Syrc Tagalog Tglg Tagbanwa Tagb Tai_Le Tale Tai_Tham Lana Tai_Viet Tavt Takri Takr Tamil Taml Tangut Tang Telugu Telu Thaana Thaa Thai Thai Tibetan Tibt Tifinagh Tfng Tirhuta Tirh Ugaritic Ugar Vai Vaii Warang_Citi Wara Yi Yiii Zanabazar_Square Zanb";
|
|
3213
3278
|
var ecma10ScriptValues = ecma9ScriptValues + " Dogra Dogr Gunjala_Gondi Gong Hanifi_Rohingya Rohg Makasar Maka Medefaidrin Medf Old_Sogdian Sogo Sogdian Sogd";
|
|
3214
3279
|
var ecma11ScriptValues = ecma10ScriptValues + " Elymaic Elym Nandinagari Nand Nyiakeng_Puachue_Hmong Hmnp Wancho Wcho";
|
|
3215
3280
|
var ecma12ScriptValues = ecma11ScriptValues + " Chorasmian Chrs Diak Dives_Akuru Khitan_Small_Script Kits Yezi Yezidi";
|
|
3216
3281
|
var ecma13ScriptValues = ecma12ScriptValues + " Cypro_Minoan Cpmn Old_Uyghur Ougr Tangsa Tnsa Toto Vithkuqi Vith";
|
|
3217
|
-
var ecma14ScriptValues = ecma13ScriptValues + " Kawi Nag_Mundari Nagm";
|
|
3282
|
+
var ecma14ScriptValues = ecma13ScriptValues + " Hrkt Katakana_Or_Hiragana Kawi Nag_Mundari Nagm Unknown Zzzz";
|
|
3218
3283
|
var unicodeScriptValues = {
|
|
3219
3284
|
9: ecma9ScriptValues,
|
|
3220
3285
|
10: ecma10ScriptValues,
|
|
@@ -3227,6 +3292,7 @@ var data = {};
|
|
|
3227
3292
|
function buildUnicodeData(ecmaVersion) {
|
|
3228
3293
|
var d = data[ecmaVersion] = {
|
|
3229
3294
|
binary: wordsRegexp(unicodeBinaryProperties[ecmaVersion] + " " + unicodeGeneralCategoryValues),
|
|
3295
|
+
binaryOfStrings: wordsRegexp(unicodeBinaryPropertiesOfStrings[ecmaVersion]),
|
|
3230
3296
|
nonBinary: {
|
|
3231
3297
|
General_Category: wordsRegexp(unicodeGeneralCategoryValues),
|
|
3232
3298
|
Script: wordsRegexp(unicodeScriptValues[ecmaVersion])
|
|
@@ -3247,12 +3313,13 @@ var list;
|
|
|
3247
3313
|
var pp$1 = Parser.prototype;
|
|
3248
3314
|
var RegExpValidationState = function RegExpValidationState2(parser) {
|
|
3249
3315
|
this.parser = parser;
|
|
3250
|
-
this.validFlags = "gim" + (parser.options.ecmaVersion >= 6 ? "uy" : "") + (parser.options.ecmaVersion >= 9 ? "s" : "") + (parser.options.ecmaVersion >= 13 ? "d" : "");
|
|
3316
|
+
this.validFlags = "gim" + (parser.options.ecmaVersion >= 6 ? "uy" : "") + (parser.options.ecmaVersion >= 9 ? "s" : "") + (parser.options.ecmaVersion >= 13 ? "d" : "") + (parser.options.ecmaVersion >= 15 ? "v" : "");
|
|
3251
3317
|
this.unicodeProperties = data[parser.options.ecmaVersion >= 14 ? 14 : parser.options.ecmaVersion];
|
|
3252
3318
|
this.source = "";
|
|
3253
3319
|
this.flags = "";
|
|
3254
3320
|
this.start = 0;
|
|
3255
3321
|
this.switchU = false;
|
|
3322
|
+
this.switchV = false;
|
|
3256
3323
|
this.switchN = false;
|
|
3257
3324
|
this.pos = 0;
|
|
3258
3325
|
this.lastIntValue = 0;
|
|
@@ -3264,12 +3331,20 @@ var RegExpValidationState = function RegExpValidationState2(parser) {
|
|
|
3264
3331
|
this.backReferenceNames = [];
|
|
3265
3332
|
};
|
|
3266
3333
|
RegExpValidationState.prototype.reset = function reset(start, pattern, flags) {
|
|
3334
|
+
var unicodeSets = flags.indexOf("v") !== -1;
|
|
3267
3335
|
var unicode = flags.indexOf("u") !== -1;
|
|
3268
3336
|
this.start = start | 0;
|
|
3269
3337
|
this.source = pattern + "";
|
|
3270
3338
|
this.flags = flags;
|
|
3271
|
-
|
|
3272
|
-
|
|
3339
|
+
if (unicodeSets && this.parser.options.ecmaVersion >= 15) {
|
|
3340
|
+
this.switchU = true;
|
|
3341
|
+
this.switchV = true;
|
|
3342
|
+
this.switchN = true;
|
|
3343
|
+
} else {
|
|
3344
|
+
this.switchU = unicode && this.parser.options.ecmaVersion >= 6;
|
|
3345
|
+
this.switchV = false;
|
|
3346
|
+
this.switchN = unicode && this.parser.options.ecmaVersion >= 9;
|
|
3347
|
+
}
|
|
3273
3348
|
};
|
|
3274
3349
|
RegExpValidationState.prototype.raise = function raise(message) {
|
|
3275
3350
|
this.parser.raiseRecoverable(this.start, "Invalid regular expression: /" + this.source + "/: " + message);
|
|
@@ -3327,9 +3402,26 @@ RegExpValidationState.prototype.eat = function eat(ch, forceU) {
|
|
|
3327
3402
|
}
|
|
3328
3403
|
return false;
|
|
3329
3404
|
};
|
|
3405
|
+
RegExpValidationState.prototype.eatChars = function eatChars(chs, forceU) {
|
|
3406
|
+
if (forceU === void 0)
|
|
3407
|
+
forceU = false;
|
|
3408
|
+
var pos = this.pos;
|
|
3409
|
+
for (var i = 0, list = chs; i < list.length; i += 1) {
|
|
3410
|
+
var ch = list[i];
|
|
3411
|
+
var current2 = this.at(pos, forceU);
|
|
3412
|
+
if (current2 === -1 || current2 !== ch) {
|
|
3413
|
+
return false;
|
|
3414
|
+
}
|
|
3415
|
+
pos = this.nextIndex(pos, forceU);
|
|
3416
|
+
}
|
|
3417
|
+
this.pos = pos;
|
|
3418
|
+
return true;
|
|
3419
|
+
};
|
|
3330
3420
|
pp$1.validateRegExpFlags = function(state) {
|
|
3331
3421
|
var validFlags = state.validFlags;
|
|
3332
3422
|
var flags = state.flags;
|
|
3423
|
+
var u = false;
|
|
3424
|
+
var v = false;
|
|
3333
3425
|
for (var i = 0; i < flags.length; i++) {
|
|
3334
3426
|
var flag = flags.charAt(i);
|
|
3335
3427
|
if (validFlags.indexOf(flag) === -1) {
|
|
@@ -3338,6 +3430,15 @@ pp$1.validateRegExpFlags = function(state) {
|
|
|
3338
3430
|
if (flags.indexOf(flag, i + 1) > -1) {
|
|
3339
3431
|
this.raise(state.start, "Duplicate regular expression flag");
|
|
3340
3432
|
}
|
|
3433
|
+
if (flag === "u") {
|
|
3434
|
+
u = true;
|
|
3435
|
+
}
|
|
3436
|
+
if (flag === "v") {
|
|
3437
|
+
v = true;
|
|
3438
|
+
}
|
|
3439
|
+
}
|
|
3440
|
+
if (this.options.ecmaVersion >= 15 && u && v) {
|
|
3441
|
+
this.raise(state.start, "Invalid regular expression flag");
|
|
3341
3442
|
}
|
|
3342
3443
|
};
|
|
3343
3444
|
pp$1.validateRegExpPattern = function(state) {
|
|
@@ -3915,28 +4016,36 @@ pp$1.regexp_eatDecimalEscape = function(state) {
|
|
|
3915
4016
|
}
|
|
3916
4017
|
return false;
|
|
3917
4018
|
};
|
|
4019
|
+
var CharSetNone = 0;
|
|
4020
|
+
var CharSetOk = 1;
|
|
4021
|
+
var CharSetString = 2;
|
|
3918
4022
|
pp$1.regexp_eatCharacterClassEscape = function(state) {
|
|
3919
4023
|
var ch = state.current();
|
|
3920
4024
|
if (isCharacterClassEscape(ch)) {
|
|
3921
4025
|
state.lastIntValue = -1;
|
|
3922
4026
|
state.advance();
|
|
3923
|
-
return
|
|
4027
|
+
return CharSetOk;
|
|
3924
4028
|
}
|
|
3925
|
-
|
|
4029
|
+
var negate = false;
|
|
4030
|
+
if (state.switchU && this.options.ecmaVersion >= 9 && ((negate = ch === 80) || ch === 112)) {
|
|
3926
4031
|
state.lastIntValue = -1;
|
|
3927
4032
|
state.advance();
|
|
4033
|
+
var result;
|
|
3928
4034
|
if (state.eat(
|
|
3929
4035
|
123
|
|
3930
4036
|
/* { */
|
|
3931
|
-
) && this.regexp_eatUnicodePropertyValueExpression(state) && state.eat(
|
|
4037
|
+
) && (result = this.regexp_eatUnicodePropertyValueExpression(state)) && state.eat(
|
|
3932
4038
|
125
|
|
3933
4039
|
/* } */
|
|
3934
4040
|
)) {
|
|
3935
|
-
|
|
4041
|
+
if (negate && result === CharSetString) {
|
|
4042
|
+
state.raise("Invalid property name");
|
|
4043
|
+
}
|
|
4044
|
+
return result;
|
|
3936
4045
|
}
|
|
3937
4046
|
state.raise("Invalid property name");
|
|
3938
4047
|
}
|
|
3939
|
-
return
|
|
4048
|
+
return CharSetNone;
|
|
3940
4049
|
};
|
|
3941
4050
|
function isCharacterClassEscape(ch) {
|
|
3942
4051
|
return ch === 100 || ch === 68 || ch === 115 || ch === 83 || ch === 119 || ch === 87;
|
|
@@ -3951,16 +4060,15 @@ pp$1.regexp_eatUnicodePropertyValueExpression = function(state) {
|
|
|
3951
4060
|
if (this.regexp_eatUnicodePropertyValue(state)) {
|
|
3952
4061
|
var value = state.lastStringValue;
|
|
3953
4062
|
this.regexp_validateUnicodePropertyNameAndValue(state, name, value);
|
|
3954
|
-
return
|
|
4063
|
+
return CharSetOk;
|
|
3955
4064
|
}
|
|
3956
4065
|
}
|
|
3957
4066
|
state.pos = start;
|
|
3958
4067
|
if (this.regexp_eatLoneUnicodePropertyNameOrValue(state)) {
|
|
3959
4068
|
var nameOrValue = state.lastStringValue;
|
|
3960
|
-
this.regexp_validateUnicodePropertyNameOrValue(state, nameOrValue);
|
|
3961
|
-
return true;
|
|
4069
|
+
return this.regexp_validateUnicodePropertyNameOrValue(state, nameOrValue);
|
|
3962
4070
|
}
|
|
3963
|
-
return
|
|
4071
|
+
return CharSetNone;
|
|
3964
4072
|
};
|
|
3965
4073
|
pp$1.regexp_validateUnicodePropertyNameAndValue = function(state, name, value) {
|
|
3966
4074
|
if (!hasOwn(state.unicodeProperties.nonBinary, name)) {
|
|
@@ -3971,9 +4079,13 @@ pp$1.regexp_validateUnicodePropertyNameAndValue = function(state, name, value) {
|
|
|
3971
4079
|
}
|
|
3972
4080
|
};
|
|
3973
4081
|
pp$1.regexp_validateUnicodePropertyNameOrValue = function(state, nameOrValue) {
|
|
3974
|
-
if (
|
|
3975
|
-
|
|
4082
|
+
if (state.unicodeProperties.binary.test(nameOrValue)) {
|
|
4083
|
+
return CharSetOk;
|
|
3976
4084
|
}
|
|
4085
|
+
if (state.switchV && state.unicodeProperties.binaryOfStrings.test(nameOrValue)) {
|
|
4086
|
+
return CharSetString;
|
|
4087
|
+
}
|
|
4088
|
+
state.raise("Invalid property name");
|
|
3977
4089
|
};
|
|
3978
4090
|
pp$1.regexp_eatUnicodePropertyName = function(state) {
|
|
3979
4091
|
var ch = 0;
|
|
@@ -4007,22 +4119,35 @@ pp$1.regexp_eatCharacterClass = function(state) {
|
|
|
4007
4119
|
91
|
|
4008
4120
|
/* [ */
|
|
4009
4121
|
)) {
|
|
4010
|
-
state.eat(
|
|
4122
|
+
var negate = state.eat(
|
|
4011
4123
|
94
|
|
4012
4124
|
/* ^ */
|
|
4013
4125
|
);
|
|
4014
|
-
this.
|
|
4015
|
-
if (state.eat(
|
|
4126
|
+
var result = this.regexp_classContents(state);
|
|
4127
|
+
if (!state.eat(
|
|
4016
4128
|
93
|
|
4017
4129
|
/* ] */
|
|
4018
4130
|
)) {
|
|
4019
|
-
|
|
4131
|
+
state.raise("Unterminated character class");
|
|
4020
4132
|
}
|
|
4021
|
-
|
|
4133
|
+
if (negate && result === CharSetString) {
|
|
4134
|
+
state.raise("Negated character class may contain strings");
|
|
4135
|
+
}
|
|
4136
|
+
return true;
|
|
4022
4137
|
}
|
|
4023
4138
|
return false;
|
|
4024
4139
|
};
|
|
4025
|
-
pp$1.
|
|
4140
|
+
pp$1.regexp_classContents = function(state) {
|
|
4141
|
+
if (state.current() === 93) {
|
|
4142
|
+
return CharSetOk;
|
|
4143
|
+
}
|
|
4144
|
+
if (state.switchV) {
|
|
4145
|
+
return this.regexp_classSetExpression(state);
|
|
4146
|
+
}
|
|
4147
|
+
this.regexp_nonEmptyClassRanges(state);
|
|
4148
|
+
return CharSetOk;
|
|
4149
|
+
};
|
|
4150
|
+
pp$1.regexp_nonEmptyClassRanges = function(state) {
|
|
4026
4151
|
while (this.regexp_eatClassAtom(state)) {
|
|
4027
4152
|
var left = state.lastIntValue;
|
|
4028
4153
|
if (state.eat(
|
|
@@ -4092,6 +4217,207 @@ pp$1.regexp_eatClassEscape = function(state) {
|
|
|
4092
4217
|
}
|
|
4093
4218
|
return this.regexp_eatCharacterClassEscape(state) || this.regexp_eatCharacterEscape(state);
|
|
4094
4219
|
};
|
|
4220
|
+
pp$1.regexp_classSetExpression = function(state) {
|
|
4221
|
+
var result = CharSetOk, subResult;
|
|
4222
|
+
if (this.regexp_eatClassSetRange(state))
|
|
4223
|
+
;
|
|
4224
|
+
else if (subResult = this.regexp_eatClassSetOperand(state)) {
|
|
4225
|
+
if (subResult === CharSetString) {
|
|
4226
|
+
result = CharSetString;
|
|
4227
|
+
}
|
|
4228
|
+
var start = state.pos;
|
|
4229
|
+
while (state.eatChars(
|
|
4230
|
+
[38, 38]
|
|
4231
|
+
/* && */
|
|
4232
|
+
)) {
|
|
4233
|
+
if (state.current() !== 38 && (subResult = this.regexp_eatClassSetOperand(state))) {
|
|
4234
|
+
if (subResult !== CharSetString) {
|
|
4235
|
+
result = CharSetOk;
|
|
4236
|
+
}
|
|
4237
|
+
continue;
|
|
4238
|
+
}
|
|
4239
|
+
state.raise("Invalid character in character class");
|
|
4240
|
+
}
|
|
4241
|
+
if (start !== state.pos) {
|
|
4242
|
+
return result;
|
|
4243
|
+
}
|
|
4244
|
+
while (state.eatChars(
|
|
4245
|
+
[45, 45]
|
|
4246
|
+
/* -- */
|
|
4247
|
+
)) {
|
|
4248
|
+
if (this.regexp_eatClassSetOperand(state)) {
|
|
4249
|
+
continue;
|
|
4250
|
+
}
|
|
4251
|
+
state.raise("Invalid character in character class");
|
|
4252
|
+
}
|
|
4253
|
+
if (start !== state.pos) {
|
|
4254
|
+
return result;
|
|
4255
|
+
}
|
|
4256
|
+
} else {
|
|
4257
|
+
state.raise("Invalid character in character class");
|
|
4258
|
+
}
|
|
4259
|
+
for (; ; ) {
|
|
4260
|
+
if (this.regexp_eatClassSetRange(state)) {
|
|
4261
|
+
continue;
|
|
4262
|
+
}
|
|
4263
|
+
subResult = this.regexp_eatClassSetOperand(state);
|
|
4264
|
+
if (!subResult) {
|
|
4265
|
+
return result;
|
|
4266
|
+
}
|
|
4267
|
+
if (subResult === CharSetString) {
|
|
4268
|
+
result = CharSetString;
|
|
4269
|
+
}
|
|
4270
|
+
}
|
|
4271
|
+
};
|
|
4272
|
+
pp$1.regexp_eatClassSetRange = function(state) {
|
|
4273
|
+
var start = state.pos;
|
|
4274
|
+
if (this.regexp_eatClassSetCharacter(state)) {
|
|
4275
|
+
var left = state.lastIntValue;
|
|
4276
|
+
if (state.eat(
|
|
4277
|
+
45
|
|
4278
|
+
/* - */
|
|
4279
|
+
) && this.regexp_eatClassSetCharacter(state)) {
|
|
4280
|
+
var right = state.lastIntValue;
|
|
4281
|
+
if (left !== -1 && right !== -1 && left > right) {
|
|
4282
|
+
state.raise("Range out of order in character class");
|
|
4283
|
+
}
|
|
4284
|
+
return true;
|
|
4285
|
+
}
|
|
4286
|
+
state.pos = start;
|
|
4287
|
+
}
|
|
4288
|
+
return false;
|
|
4289
|
+
};
|
|
4290
|
+
pp$1.regexp_eatClassSetOperand = function(state) {
|
|
4291
|
+
if (this.regexp_eatClassSetCharacter(state)) {
|
|
4292
|
+
return CharSetOk;
|
|
4293
|
+
}
|
|
4294
|
+
return this.regexp_eatClassStringDisjunction(state) || this.regexp_eatNestedClass(state);
|
|
4295
|
+
};
|
|
4296
|
+
pp$1.regexp_eatNestedClass = function(state) {
|
|
4297
|
+
var start = state.pos;
|
|
4298
|
+
if (state.eat(
|
|
4299
|
+
91
|
|
4300
|
+
/* [ */
|
|
4301
|
+
)) {
|
|
4302
|
+
var negate = state.eat(
|
|
4303
|
+
94
|
|
4304
|
+
/* ^ */
|
|
4305
|
+
);
|
|
4306
|
+
var result = this.regexp_classContents(state);
|
|
4307
|
+
if (state.eat(
|
|
4308
|
+
93
|
|
4309
|
+
/* ] */
|
|
4310
|
+
)) {
|
|
4311
|
+
if (negate && result === CharSetString) {
|
|
4312
|
+
state.raise("Negated character class may contain strings");
|
|
4313
|
+
}
|
|
4314
|
+
return result;
|
|
4315
|
+
}
|
|
4316
|
+
state.pos = start;
|
|
4317
|
+
}
|
|
4318
|
+
if (state.eat(
|
|
4319
|
+
92
|
|
4320
|
+
/* \ */
|
|
4321
|
+
)) {
|
|
4322
|
+
var result$1 = this.regexp_eatCharacterClassEscape(state);
|
|
4323
|
+
if (result$1) {
|
|
4324
|
+
return result$1;
|
|
4325
|
+
}
|
|
4326
|
+
state.pos = start;
|
|
4327
|
+
}
|
|
4328
|
+
return null;
|
|
4329
|
+
};
|
|
4330
|
+
pp$1.regexp_eatClassStringDisjunction = function(state) {
|
|
4331
|
+
var start = state.pos;
|
|
4332
|
+
if (state.eatChars(
|
|
4333
|
+
[92, 113]
|
|
4334
|
+
/* \q */
|
|
4335
|
+
)) {
|
|
4336
|
+
if (state.eat(
|
|
4337
|
+
123
|
|
4338
|
+
/* { */
|
|
4339
|
+
)) {
|
|
4340
|
+
var result = this.regexp_classStringDisjunctionContents(state);
|
|
4341
|
+
if (state.eat(
|
|
4342
|
+
125
|
|
4343
|
+
/* } */
|
|
4344
|
+
)) {
|
|
4345
|
+
return result;
|
|
4346
|
+
}
|
|
4347
|
+
} else {
|
|
4348
|
+
state.raise("Invalid escape");
|
|
4349
|
+
}
|
|
4350
|
+
state.pos = start;
|
|
4351
|
+
}
|
|
4352
|
+
return null;
|
|
4353
|
+
};
|
|
4354
|
+
pp$1.regexp_classStringDisjunctionContents = function(state) {
|
|
4355
|
+
var result = this.regexp_classString(state);
|
|
4356
|
+
while (state.eat(
|
|
4357
|
+
124
|
|
4358
|
+
/* | */
|
|
4359
|
+
)) {
|
|
4360
|
+
if (this.regexp_classString(state) === CharSetString) {
|
|
4361
|
+
result = CharSetString;
|
|
4362
|
+
}
|
|
4363
|
+
}
|
|
4364
|
+
return result;
|
|
4365
|
+
};
|
|
4366
|
+
pp$1.regexp_classString = function(state) {
|
|
4367
|
+
var count = 0;
|
|
4368
|
+
while (this.regexp_eatClassSetCharacter(state)) {
|
|
4369
|
+
count++;
|
|
4370
|
+
}
|
|
4371
|
+
return count === 1 ? CharSetOk : CharSetString;
|
|
4372
|
+
};
|
|
4373
|
+
pp$1.regexp_eatClassSetCharacter = function(state) {
|
|
4374
|
+
var start = state.pos;
|
|
4375
|
+
if (state.eat(
|
|
4376
|
+
92
|
|
4377
|
+
/* \ */
|
|
4378
|
+
)) {
|
|
4379
|
+
if (this.regexp_eatCharacterEscape(state) || this.regexp_eatClassSetReservedPunctuator(state)) {
|
|
4380
|
+
return true;
|
|
4381
|
+
}
|
|
4382
|
+
if (state.eat(
|
|
4383
|
+
98
|
|
4384
|
+
/* b */
|
|
4385
|
+
)) {
|
|
4386
|
+
state.lastIntValue = 8;
|
|
4387
|
+
return true;
|
|
4388
|
+
}
|
|
4389
|
+
state.pos = start;
|
|
4390
|
+
return false;
|
|
4391
|
+
}
|
|
4392
|
+
var ch = state.current();
|
|
4393
|
+
if (ch < 0 || ch === state.lookahead() && isClassSetReservedDoublePunctuatorCharacter(ch)) {
|
|
4394
|
+
return false;
|
|
4395
|
+
}
|
|
4396
|
+
if (isClassSetSyntaxCharacter(ch)) {
|
|
4397
|
+
return false;
|
|
4398
|
+
}
|
|
4399
|
+
state.advance();
|
|
4400
|
+
state.lastIntValue = ch;
|
|
4401
|
+
return true;
|
|
4402
|
+
};
|
|
4403
|
+
function isClassSetReservedDoublePunctuatorCharacter(ch) {
|
|
4404
|
+
return ch === 33 || ch >= 35 && ch <= 38 || ch >= 42 && ch <= 44 || ch === 46 || ch >= 58 && ch <= 64 || ch === 94 || ch === 96 || ch === 126;
|
|
4405
|
+
}
|
|
4406
|
+
function isClassSetSyntaxCharacter(ch) {
|
|
4407
|
+
return ch === 40 || ch === 41 || ch === 45 || ch === 47 || ch >= 91 && ch <= 93 || ch >= 123 && ch <= 125;
|
|
4408
|
+
}
|
|
4409
|
+
pp$1.regexp_eatClassSetReservedPunctuator = function(state) {
|
|
4410
|
+
var ch = state.current();
|
|
4411
|
+
if (isClassSetReservedPunctuator(ch)) {
|
|
4412
|
+
state.lastIntValue = ch;
|
|
4413
|
+
state.advance();
|
|
4414
|
+
return true;
|
|
4415
|
+
}
|
|
4416
|
+
return false;
|
|
4417
|
+
};
|
|
4418
|
+
function isClassSetReservedPunctuator(ch) {
|
|
4419
|
+
return ch === 33 || ch === 35 || ch === 37 || ch === 38 || ch === 44 || ch === 45 || ch >= 58 && ch <= 62 || ch === 64 || ch === 96 || ch === 126;
|
|
4420
|
+
}
|
|
4095
4421
|
pp$1.regexp_eatClassControlLetter = function(state) {
|
|
4096
4422
|
var ch = state.current();
|
|
4097
4423
|
if (isDecimalDigit(ch) || ch === 95) {
|
|
@@ -5007,7 +5333,7 @@ pp.readWord = function() {
|
|
|
5007
5333
|
}
|
|
5008
5334
|
return this.finishToken(type, word);
|
|
5009
5335
|
};
|
|
5010
|
-
var version = "8.
|
|
5336
|
+
var version = "8.10.0";
|
|
5011
5337
|
Parser.acorn = {
|
|
5012
5338
|
Parser,
|
|
5013
5339
|
version,
|
|
@@ -5032,9 +5358,7 @@ Parser.acorn = {
|
|
|
5032
5358
|
|
|
5033
5359
|
// packages/parser/index.js
|
|
5034
5360
|
var extendParser = (keywords3) => {
|
|
5035
|
-
const parser = Parser.extend(
|
|
5036
|
-
...keywords3
|
|
5037
|
-
);
|
|
5361
|
+
const parser = Parser.extend(...keywords3);
|
|
5038
5362
|
const parse4 = createParse(parser);
|
|
5039
5363
|
return {
|
|
5040
5364
|
parse: parse4
|
|
@@ -5344,7 +5668,7 @@ function stringInterpolation(Parser3) {
|
|
|
5344
5668
|
}
|
|
5345
5669
|
} else if (char === ")") {
|
|
5346
5670
|
parenthesis--;
|
|
5347
|
-
if (parenthesis
|
|
5671
|
+
if (!parenthesis && literalOpened) {
|
|
5348
5672
|
char = "}";
|
|
5349
5673
|
literalOpened = false;
|
|
5350
5674
|
}
|
|
@@ -5354,7 +5678,7 @@ function stringInterpolation(Parser3) {
|
|
|
5354
5678
|
if (isTemplateLiteral) {
|
|
5355
5679
|
const node = this.startNode();
|
|
5356
5680
|
this.next();
|
|
5357
|
-
const { quasis, expressions } = import_putout3.template.ast(
|
|
5681
|
+
const { quasis, expressions } = import_putout3.template.ast(`\`${out.join("")}\``);
|
|
5358
5682
|
assign2(node, {
|
|
5359
5683
|
quasis,
|
|
5360
5684
|
expressions
|
|
@@ -5425,9 +5749,7 @@ function keywordFreeze(Parser3) {
|
|
|
5425
5749
|
type: "Identifier",
|
|
5426
5750
|
name: "freeze"
|
|
5427
5751
|
},
|
|
5428
|
-
arguments: [
|
|
5429
|
-
expression
|
|
5430
|
-
]
|
|
5752
|
+
arguments: [expression]
|
|
5431
5753
|
}
|
|
5432
5754
|
};
|
|
5433
5755
|
else
|
|
@@ -5526,7 +5848,10 @@ var defaultKeywords = {
|
|
|
5526
5848
|
stringInterpolation
|
|
5527
5849
|
};
|
|
5528
5850
|
var keywords2 = defaultKeywords;
|
|
5529
|
-
var parse3 = (source, options, keywords3 = defaultKeywords) => {
|
|
5530
|
-
const { parse: parse4 } = extendParser(Object.values(
|
|
5851
|
+
var parse3 = (source, options = {}, keywords3 = defaultKeywords) => {
|
|
5852
|
+
const { parse: parse4 } = extendParser(Object.values({
|
|
5853
|
+
...options.keywords,
|
|
5854
|
+
...keywords3
|
|
5855
|
+
}));
|
|
5531
5856
|
return parse4(source);
|
|
5532
5857
|
};
|