@hpcc-js/observablehq-compiler 1.2.8 → 1.2.9

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/dist/index.esm.js CHANGED
@@ -11,6 +11,9 @@ var nonASCIIidentifierChars = "\u200c\u200d\xb7\u0300-\u036f\u0387\u0483-\u0487\
11
11
  var nonASCIIidentifierStartChars = "\xaa\xb5\xba\xc0-\xd6\xd8-\xf6\xf8-\u02c1\u02c6-\u02d1\u02e0-\u02e4\u02ec\u02ee\u0370-\u0374\u0376\u0377\u037a-\u037d\u037f\u0386\u0388-\u038a\u038c\u038e-\u03a1\u03a3-\u03f5\u03f7-\u0481\u048a-\u052f\u0531-\u0556\u0559\u0560-\u0588\u05d0-\u05ea\u05ef-\u05f2\u0620-\u064a\u066e\u066f\u0671-\u06d3\u06d5\u06e5\u06e6\u06ee\u06ef\u06fa-\u06fc\u06ff\u0710\u0712-\u072f\u074d-\u07a5\u07b1\u07ca-\u07ea\u07f4\u07f5\u07fa\u0800-\u0815\u081a\u0824\u0828\u0840-\u0858\u0860-\u086a\u0870-\u0887\u0889-\u088e\u08a0-\u08c9\u0904-\u0939\u093d\u0950\u0958-\u0961\u0971-\u0980\u0985-\u098c\u098f\u0990\u0993-\u09a8\u09aa-\u09b0\u09b2\u09b6-\u09b9\u09bd\u09ce\u09dc\u09dd\u09df-\u09e1\u09f0\u09f1\u09fc\u0a05-\u0a0a\u0a0f\u0a10\u0a13-\u0a28\u0a2a-\u0a30\u0a32\u0a33\u0a35\u0a36\u0a38\u0a39\u0a59-\u0a5c\u0a5e\u0a72-\u0a74\u0a85-\u0a8d\u0a8f-\u0a91\u0a93-\u0aa8\u0aaa-\u0ab0\u0ab2\u0ab3\u0ab5-\u0ab9\u0abd\u0ad0\u0ae0\u0ae1\u0af9\u0b05-\u0b0c\u0b0f\u0b10\u0b13-\u0b28\u0b2a-\u0b30\u0b32\u0b33\u0b35-\u0b39\u0b3d\u0b5c\u0b5d\u0b5f-\u0b61\u0b71\u0b83\u0b85-\u0b8a\u0b8e-\u0b90\u0b92-\u0b95\u0b99\u0b9a\u0b9c\u0b9e\u0b9f\u0ba3\u0ba4\u0ba8-\u0baa\u0bae-\u0bb9\u0bd0\u0c05-\u0c0c\u0c0e-\u0c10\u0c12-\u0c28\u0c2a-\u0c39\u0c3d\u0c58-\u0c5a\u0c5d\u0c60\u0c61\u0c80\u0c85-\u0c8c\u0c8e-\u0c90\u0c92-\u0ca8\u0caa-\u0cb3\u0cb5-\u0cb9\u0cbd\u0cdd\u0cde\u0ce0\u0ce1\u0cf1\u0cf2\u0d04-\u0d0c\u0d0e-\u0d10\u0d12-\u0d3a\u0d3d\u0d4e\u0d54-\u0d56\u0d5f-\u0d61\u0d7a-\u0d7f\u0d85-\u0d96\u0d9a-\u0db1\u0db3-\u0dbb\u0dbd\u0dc0-\u0dc6\u0e01-\u0e30\u0e32\u0e33\u0e40-\u0e46\u0e81\u0e82\u0e84\u0e86-\u0e8a\u0e8c-\u0ea3\u0ea5\u0ea7-\u0eb0\u0eb2\u0eb3\u0ebd\u0ec0-\u0ec4\u0ec6\u0edc-\u0edf\u0f00\u0f40-\u0f47\u0f49-\u0f6c\u0f88-\u0f8c\u1000-\u102a\u103f\u1050-\u1055\u105a-\u105d\u1061\u1065\u1066\u106e-\u1070\u1075-\u1081\u108e\u10a0-\u10c5\u10c7\u10cd\u10d0-\u10fa\u10fc-\u1248\u124a-\u124d\u1250-\u1256\u1258\u125a-\u125d\u1260-\u1288\u128a-\u128d\u1290-\u12b0\u12b2-\u12b5\u12b8-\u12be\u12c0\u12c2-\u12c5\u12c8-\u12d6\u12d8-\u1310\u1312-\u1315\u1318-\u135a\u1380-\u138f\u13a0-\u13f5\u13f8-\u13fd\u1401-\u166c\u166f-\u167f\u1681-\u169a\u16a0-\u16ea\u16ee-\u16f8\u1700-\u1711\u171f-\u1731\u1740-\u1751\u1760-\u176c\u176e-\u1770\u1780-\u17b3\u17d7\u17dc\u1820-\u1878\u1880-\u18a8\u18aa\u18b0-\u18f5\u1900-\u191e\u1950-\u196d\u1970-\u1974\u1980-\u19ab\u19b0-\u19c9\u1a00-\u1a16\u1a20-\u1a54\u1aa7\u1b05-\u1b33\u1b45-\u1b4c\u1b83-\u1ba0\u1bae\u1baf\u1bba-\u1be5\u1c00-\u1c23\u1c4d-\u1c4f\u1c5a-\u1c7d\u1c80-\u1c88\u1c90-\u1cba\u1cbd-\u1cbf\u1ce9-\u1cec\u1cee-\u1cf3\u1cf5\u1cf6\u1cfa\u1d00-\u1dbf\u1e00-\u1f15\u1f18-\u1f1d\u1f20-\u1f45\u1f48-\u1f4d\u1f50-\u1f57\u1f59\u1f5b\u1f5d\u1f5f-\u1f7d\u1f80-\u1fb4\u1fb6-\u1fbc\u1fbe\u1fc2-\u1fc4\u1fc6-\u1fcc\u1fd0-\u1fd3\u1fd6-\u1fdb\u1fe0-\u1fec\u1ff2-\u1ff4\u1ff6-\u1ffc\u2071\u207f\u2090-\u209c\u2102\u2107\u210a-\u2113\u2115\u2118-\u211d\u2124\u2126\u2128\u212a-\u2139\u213c-\u213f\u2145-\u2149\u214e\u2160-\u2188\u2c00-\u2ce4\u2ceb-\u2cee\u2cf2\u2cf3\u2d00-\u2d25\u2d27\u2d2d\u2d30-\u2d67\u2d6f\u2d80-\u2d96\u2da0-\u2da6\u2da8-\u2dae\u2db0-\u2db6\u2db8-\u2dbe\u2dc0-\u2dc6\u2dc8-\u2dce\u2dd0-\u2dd6\u2dd8-\u2dde\u3005-\u3007\u3021-\u3029\u3031-\u3035\u3038-\u303c\u3041-\u3096\u309b-\u309f\u30a1-\u30fa\u30fc-\u30ff\u3105-\u312f\u3131-\u318e\u31a0-\u31bf\u31f0-\u31ff\u3400-\u4dbf\u4e00-\ua48c\ua4d0-\ua4fd\ua500-\ua60c\ua610-\ua61f\ua62a\ua62b\ua640-\ua66e\ua67f-\ua69d\ua6a0-\ua6ef\ua717-\ua71f\ua722-\ua788\ua78b-\ua7ca\ua7d0\ua7d1\ua7d3\ua7d5-\ua7d9\ua7f2-\ua801\ua803-\ua805\ua807-\ua80a\ua80c-\ua822\ua840-\ua873\ua882-\ua8b3\ua8f2-\ua8f7\ua8fb\ua8fd\ua8fe\ua90a-\ua925\ua930-\ua946\ua960-\ua97c\ua984-\ua9b2\ua9cf\ua9e0-\ua9e4\ua9e6-\ua9ef\ua9fa-\ua9fe\uaa00-\uaa28\uaa40-\uaa42\uaa44-\uaa4b\uaa60-\uaa76\uaa7a\uaa7e-\uaaaf\uaab1\uaab5\uaab6\uaab9-\uaabd\uaac0\uaac2\uaadb-\uaadd\uaae0-\uaaea\uaaf2-\uaaf4\uab01-\uab06\uab09-\uab0e\uab11-\uab16\uab20-\uab26\uab28-\uab2e\uab30-\uab5a\uab5c-\uab69\uab70-\uabe2\uac00-\ud7a3\ud7b0-\ud7c6\ud7cb-\ud7fb\uf900-\ufa6d\ufa70-\ufad9\ufb00-\ufb06\ufb13-\ufb17\ufb1d\ufb1f-\ufb28\ufb2a-\ufb36\ufb38-\ufb3c\ufb3e\ufb40\ufb41\ufb43\ufb44\ufb46-\ufbb1\ufbd3-\ufd3d\ufd50-\ufd8f\ufd92-\ufdc7\ufdf0-\ufdfb\ufe70-\ufe74\ufe76-\ufefc\uff21-\uff3a\uff41-\uff5a\uff66-\uffbe\uffc2-\uffc7\uffca-\uffcf\uffd2-\uffd7\uffda-\uffdc";
12
12
 
13
13
  // These are a run-length and offset encoded representation of the
14
+ // >0xffff code points that are a valid part of identifiers. The
15
+ // offset starts at 0x10000, and each pair of numbers represents an
16
+ // offset to the next range, and then a size of the range.
14
17
 
15
18
  // Reserved word lists for various dialects of the language
16
19
 
@@ -363,6 +366,10 @@ var defaultOptions = {
363
366
  // allowed and treated as a line comment. Enabled by default when
364
367
  // `ecmaVersion` >= 2023.
365
368
  allowHashBang: false,
369
+ // By default, the parser will verify that private properties are
370
+ // only used in places where they are valid and have been declared.
371
+ // Set this to false to turn such checks off.
372
+ checkPrivateFields: true,
366
373
  // When `locations` is on, `loc` properties holding objects with
367
374
  // `start` and `end` properties in `{line, column}` form (with
368
375
  // line being 1-based and column 0-based) will be attached to the
@@ -1129,6 +1136,16 @@ pp$8.parseThrowStatement = function(node) {
1129
1136
 
1130
1137
  var empty$1 = [];
1131
1138
 
1139
+ pp$8.parseCatchClauseParam = function() {
1140
+ var param = this.parseBindingAtom();
1141
+ var simple = param.type === "Identifier";
1142
+ this.enterScope(simple ? SCOPE_SIMPLE_CATCH : 0);
1143
+ this.checkLValPattern(param, simple ? BIND_SIMPLE_CATCH : BIND_LEXICAL);
1144
+ this.expect(types$1.parenR);
1145
+
1146
+ return param
1147
+ };
1148
+
1132
1149
  pp$8.parseTryStatement = function(node) {
1133
1150
  this.next();
1134
1151
  node.block = this.parseBlock();
@@ -1137,11 +1154,7 @@ pp$8.parseTryStatement = function(node) {
1137
1154
  var clause = this.startNode();
1138
1155
  this.next();
1139
1156
  if (this.eat(types$1.parenL)) {
1140
- clause.param = this.parseBindingAtom();
1141
- var simple = clause.param.type === "Identifier";
1142
- this.enterScope(simple ? SCOPE_SIMPLE_CATCH : 0);
1143
- this.checkLValPattern(clause.param, simple ? BIND_SIMPLE_CATCH : BIND_LEXICAL);
1144
- this.expect(types$1.parenR);
1157
+ clause.param = this.parseCatchClauseParam();
1145
1158
  } else {
1146
1159
  if (this.options.ecmaVersion < 10) { this.unexpected(); }
1147
1160
  clause.param = null;
@@ -1157,9 +1170,9 @@ pp$8.parseTryStatement = function(node) {
1157
1170
  return this.finishNode(node, "TryStatement")
1158
1171
  };
1159
1172
 
1160
- pp$8.parseVarStatement = function(node, kind) {
1173
+ pp$8.parseVarStatement = function(node, kind, allowMissingInitializer) {
1161
1174
  this.next();
1162
- this.parseVar(node, false, kind);
1175
+ this.parseVar(node, false, kind, allowMissingInitializer);
1163
1176
  this.semicolon();
1164
1177
  return this.finishNode(node, "VariableDeclaration")
1165
1178
  };
@@ -1288,7 +1301,7 @@ pp$8.parseForIn = function(node, init) {
1288
1301
 
1289
1302
  // Parse a list of variable declarations.
1290
1303
 
1291
- pp$8.parseVar = function(node, isFor, kind) {
1304
+ pp$8.parseVar = function(node, isFor, kind, allowMissingInitializer) {
1292
1305
  node.declarations = [];
1293
1306
  node.kind = kind;
1294
1307
  for (;;) {
@@ -1296,9 +1309,9 @@ pp$8.parseVar = function(node, isFor, kind) {
1296
1309
  this.parseVarId(decl, kind);
1297
1310
  if (this.eat(types$1.eq)) {
1298
1311
  decl.init = this.parseMaybeAssign(isFor);
1299
- } else if (kind === "const" && !(this.type === types$1._in || (this.options.ecmaVersion >= 6 && this.isContextual("of")))) {
1312
+ } else if (!allowMissingInitializer && kind === "const" && !(this.type === types$1._in || (this.options.ecmaVersion >= 6 && this.isContextual("of")))) {
1300
1313
  this.unexpected();
1301
- } else if (decl.id.type !== "Identifier" && !(isFor && (this.type === types$1._in || this.isContextual("of")))) {
1314
+ } else if (!allowMissingInitializer && decl.id.type !== "Identifier" && !(isFor && (this.type === types$1._in || this.isContextual("of")))) {
1302
1315
  this.raise(this.lastTokEnd, "Complex binding patterns require an initialization value");
1303
1316
  } else {
1304
1317
  decl.init = null;
@@ -1387,7 +1400,7 @@ pp$8.parseClass = function(node, isStatement) {
1387
1400
  if (element) {
1388
1401
  classBody.body.push(element);
1389
1402
  if (element.type === "MethodDefinition" && element.kind === "constructor") {
1390
- if (hadConstructor) { this.raise(element.start, "Duplicate constructor in the same class"); }
1403
+ if (hadConstructor) { this.raiseRecoverable(element.start, "Duplicate constructor in the same class"); }
1391
1404
  hadConstructor = true;
1392
1405
  } else if (element.key && element.key.type === "PrivateIdentifier" && isPrivateNameConflicted(privateNameMap, element)) {
1393
1406
  this.raiseRecoverable(element.key.start, ("Identifier '#" + (element.key.name) + "' has already been declared"));
@@ -1585,6 +1598,7 @@ pp$8.exitClassBody = function() {
1585
1598
  var ref = this.privateNameStack.pop();
1586
1599
  var declared = ref.declared;
1587
1600
  var used = ref.used;
1601
+ if (!this.options.checkPrivateFields) { return }
1588
1602
  var len = this.privateNameStack.length;
1589
1603
  var parent = len === 0 ? null : this.privateNameStack[len - 1];
1590
1604
  for (var i = 0; i < used.length; ++i) {
@@ -1636,44 +1650,36 @@ function checkKeyName(node, name) {
1636
1650
 
1637
1651
  // Parses module export declaration.
1638
1652
 
1653
+ pp$8.parseExportAllDeclaration = function(node, exports) {
1654
+ if (this.options.ecmaVersion >= 11) {
1655
+ if (this.eatContextual("as")) {
1656
+ node.exported = this.parseModuleExportName();
1657
+ this.checkExport(exports, node.exported, this.lastTokStart);
1658
+ } else {
1659
+ node.exported = null;
1660
+ }
1661
+ }
1662
+ this.expectContextual("from");
1663
+ if (this.type !== types$1.string) { this.unexpected(); }
1664
+ node.source = this.parseExprAtom();
1665
+ this.semicolon();
1666
+ return this.finishNode(node, "ExportAllDeclaration")
1667
+ };
1668
+
1639
1669
  pp$8.parseExport = function(node, exports) {
1640
1670
  this.next();
1641
1671
  // export * from '...'
1642
1672
  if (this.eat(types$1.star)) {
1643
- if (this.options.ecmaVersion >= 11) {
1644
- if (this.eatContextual("as")) {
1645
- node.exported = this.parseModuleExportName();
1646
- this.checkExport(exports, node.exported, this.lastTokStart);
1647
- } else {
1648
- node.exported = null;
1649
- }
1650
- }
1651
- this.expectContextual("from");
1652
- if (this.type !== types$1.string) { this.unexpected(); }
1653
- node.source = this.parseExprAtom();
1654
- this.semicolon();
1655
- return this.finishNode(node, "ExportAllDeclaration")
1673
+ return this.parseExportAllDeclaration(node, exports)
1656
1674
  }
1657
1675
  if (this.eat(types$1._default)) { // export default ...
1658
1676
  this.checkExport(exports, "default", this.lastTokStart);
1659
- var isAsync;
1660
- if (this.type === types$1._function || (isAsync = this.isAsyncFunction())) {
1661
- var fNode = this.startNode();
1662
- this.next();
1663
- if (isAsync) { this.next(); }
1664
- node.declaration = this.parseFunction(fNode, FUNC_STATEMENT | FUNC_NULLABLE_ID, false, isAsync);
1665
- } else if (this.type === types$1._class) {
1666
- var cNode = this.startNode();
1667
- node.declaration = this.parseClass(cNode, "nullableID");
1668
- } else {
1669
- node.declaration = this.parseMaybeAssign();
1670
- this.semicolon();
1671
- }
1677
+ node.declaration = this.parseExportDefaultDeclaration();
1672
1678
  return this.finishNode(node, "ExportDefaultDeclaration")
1673
1679
  }
1674
1680
  // export var|const|let|function|class ...
1675
1681
  if (this.shouldParseExportStatement()) {
1676
- node.declaration = this.parseStatement(null);
1682
+ node.declaration = this.parseExportDeclaration(node);
1677
1683
  if (node.declaration.type === "VariableDeclaration")
1678
1684
  { this.checkVariableExport(exports, node.declaration.declarations); }
1679
1685
  else
@@ -1707,6 +1713,27 @@ pp$8.parseExport = function(node, exports) {
1707
1713
  return this.finishNode(node, "ExportNamedDeclaration")
1708
1714
  };
1709
1715
 
1716
+ pp$8.parseExportDeclaration = function(node) {
1717
+ return this.parseStatement(null)
1718
+ };
1719
+
1720
+ pp$8.parseExportDefaultDeclaration = function() {
1721
+ var isAsync;
1722
+ if (this.type === types$1._function || (isAsync = this.isAsyncFunction())) {
1723
+ var fNode = this.startNode();
1724
+ this.next();
1725
+ if (isAsync) { this.next(); }
1726
+ return this.parseFunction(fNode, FUNC_STATEMENT | FUNC_NULLABLE_ID, false, isAsync)
1727
+ } else if (this.type === types$1._class) {
1728
+ var cNode = this.startNode();
1729
+ return this.parseClass(cNode, "nullableID")
1730
+ } else {
1731
+ var declaration = this.parseMaybeAssign();
1732
+ this.semicolon();
1733
+ return declaration
1734
+ }
1735
+ };
1736
+
1710
1737
  pp$8.checkExport = function(exports, name, pos) {
1711
1738
  if (!exports) { return }
1712
1739
  if (typeof name !== "string")
@@ -1764,6 +1791,20 @@ pp$8.shouldParseExportStatement = function() {
1764
1791
 
1765
1792
  // Parses a comma-separated list of module exports.
1766
1793
 
1794
+ pp$8.parseExportSpecifier = function(exports) {
1795
+ var node = this.startNode();
1796
+ node.local = this.parseModuleExportName();
1797
+
1798
+ node.exported = this.eatContextual("as") ? this.parseModuleExportName() : node.local;
1799
+ this.checkExport(
1800
+ exports,
1801
+ node.exported,
1802
+ node.exported.start
1803
+ );
1804
+
1805
+ return this.finishNode(node, "ExportSpecifier")
1806
+ };
1807
+
1767
1808
  pp$8.parseExportSpecifiers = function(exports) {
1768
1809
  var nodes = [], first = true;
1769
1810
  // export { x, y as z } [from '...']
@@ -1774,15 +1815,7 @@ pp$8.parseExportSpecifiers = function(exports) {
1774
1815
  if (this.afterTrailingComma(types$1.braceR)) { break }
1775
1816
  } else { first = false; }
1776
1817
 
1777
- var node = this.startNode();
1778
- node.local = this.parseModuleExportName();
1779
- node.exported = this.eatContextual("as") ? this.parseModuleExportName() : node.local;
1780
- this.checkExport(
1781
- exports,
1782
- node.exported,
1783
- node.exported.start
1784
- );
1785
- nodes.push(this.finishNode(node, "ExportSpecifier"));
1818
+ nodes.push(this.parseExportSpecifier(exports));
1786
1819
  }
1787
1820
  return nodes
1788
1821
  };
@@ -1791,6 +1824,7 @@ pp$8.parseExportSpecifiers = function(exports) {
1791
1824
 
1792
1825
  pp$8.parseImport = function(node) {
1793
1826
  this.next();
1827
+
1794
1828
  // import '...'
1795
1829
  if (this.type === types$1.string) {
1796
1830
  node.specifiers = empty$1;
@@ -1806,23 +1840,46 @@ pp$8.parseImport = function(node) {
1806
1840
 
1807
1841
  // Parses a comma-separated list of module imports.
1808
1842
 
1843
+ pp$8.parseImportSpecifier = function() {
1844
+ var node = this.startNode();
1845
+ node.imported = this.parseModuleExportName();
1846
+
1847
+ if (this.eatContextual("as")) {
1848
+ node.local = this.parseIdent();
1849
+ } else {
1850
+ this.checkUnreserved(node.imported);
1851
+ node.local = node.imported;
1852
+ }
1853
+ this.checkLValSimple(node.local, BIND_LEXICAL);
1854
+
1855
+ return this.finishNode(node, "ImportSpecifier")
1856
+ };
1857
+
1858
+ pp$8.parseImportDefaultSpecifier = function() {
1859
+ // import defaultObj, { x, y as z } from '...'
1860
+ var node = this.startNode();
1861
+ node.local = this.parseIdent();
1862
+ this.checkLValSimple(node.local, BIND_LEXICAL);
1863
+ return this.finishNode(node, "ImportDefaultSpecifier")
1864
+ };
1865
+
1866
+ pp$8.parseImportNamespaceSpecifier = function() {
1867
+ var node = this.startNode();
1868
+ this.next();
1869
+ this.expectContextual("as");
1870
+ node.local = this.parseIdent();
1871
+ this.checkLValSimple(node.local, BIND_LEXICAL);
1872
+ return this.finishNode(node, "ImportNamespaceSpecifier")
1873
+ };
1874
+
1809
1875
  pp$8.parseImportSpecifiers = function() {
1810
1876
  var nodes = [], first = true;
1811
1877
  if (this.type === types$1.name) {
1812
- // import defaultObj, { x, y as z } from '...'
1813
- var node = this.startNode();
1814
- node.local = this.parseIdent();
1815
- this.checkLValSimple(node.local, BIND_LEXICAL);
1816
- nodes.push(this.finishNode(node, "ImportDefaultSpecifier"));
1878
+ nodes.push(this.parseImportDefaultSpecifier());
1817
1879
  if (!this.eat(types$1.comma)) { return nodes }
1818
1880
  }
1819
1881
  if (this.type === types$1.star) {
1820
- var node$1 = this.startNode();
1821
- this.next();
1822
- this.expectContextual("as");
1823
- node$1.local = this.parseIdent();
1824
- this.checkLValSimple(node$1.local, BIND_LEXICAL);
1825
- nodes.push(this.finishNode(node$1, "ImportNamespaceSpecifier"));
1882
+ nodes.push(this.parseImportNamespaceSpecifier());
1826
1883
  return nodes
1827
1884
  }
1828
1885
  this.expect(types$1.braceL);
@@ -1832,16 +1889,7 @@ pp$8.parseImportSpecifiers = function() {
1832
1889
  if (this.afterTrailingComma(types$1.braceR)) { break }
1833
1890
  } else { first = false; }
1834
1891
 
1835
- var node$2 = this.startNode();
1836
- node$2.imported = this.parseModuleExportName();
1837
- if (this.eatContextual("as")) {
1838
- node$2.local = this.parseIdent();
1839
- } else {
1840
- this.checkUnreserved(node$2.imported);
1841
- node$2.local = node$2.imported;
1842
- }
1843
- this.checkLValSimple(node$2.local, BIND_LEXICAL);
1844
- nodes.push(this.finishNode(node$2, "ImportSpecifier"));
1892
+ nodes.push(this.parseImportSpecifier());
1845
1893
  }
1846
1894
  return nodes
1847
1895
  };
@@ -2014,7 +2062,7 @@ pp$7.parseBindingAtom = function() {
2014
2062
  return this.parseIdent()
2015
2063
  };
2016
2064
 
2017
- pp$7.parseBindingList = function(close, allowEmpty, allowTrailingComma) {
2065
+ pp$7.parseBindingList = function(close, allowEmpty, allowTrailingComma, allowModifiers) {
2018
2066
  var elts = [], first = true;
2019
2067
  while (!this.eat(close)) {
2020
2068
  if (first) { first = false; }
@@ -2027,18 +2075,22 @@ pp$7.parseBindingList = function(close, allowEmpty, allowTrailingComma) {
2027
2075
  var rest = this.parseRestBinding();
2028
2076
  this.parseBindingListItem(rest);
2029
2077
  elts.push(rest);
2030
- if (this.type === types$1.comma) { this.raise(this.start, "Comma is not permitted after the rest element"); }
2078
+ if (this.type === types$1.comma) { this.raiseRecoverable(this.start, "Comma is not permitted after the rest element"); }
2031
2079
  this.expect(close);
2032
2080
  break
2033
2081
  } else {
2034
- var elem = this.parseMaybeDefault(this.start, this.startLoc);
2035
- this.parseBindingListItem(elem);
2036
- elts.push(elem);
2082
+ elts.push(this.parseAssignableListItem(allowModifiers));
2037
2083
  }
2038
2084
  }
2039
2085
  return elts
2040
2086
  };
2041
2087
 
2088
+ pp$7.parseAssignableListItem = function(allowModifiers) {
2089
+ var elem = this.parseMaybeDefault(this.start, this.startLoc);
2090
+ this.parseBindingListItem(elem);
2091
+ return elem
2092
+ };
2093
+
2042
2094
  pp$7.parseBindingListItem = function(param) {
2043
2095
  return param
2044
2096
  };
@@ -2204,6 +2256,9 @@ pp$7.checkLValInnerPattern = function(expr, bindingType, checkClashes) {
2204
2256
  };
2205
2257
 
2206
2258
  // The algorithm used to determine whether a regexp can appear at a
2259
+ // given point in the program is loosely based on sweet.js' approach.
2260
+ // See https://github.com/mozilla/sweet.js/wiki/design
2261
+
2207
2262
 
2208
2263
  var TokContext = function TokContext(token, isExpr, preserveSpace, override, generator) {
2209
2264
  this.token = token;
@@ -2359,6 +2414,23 @@ types$1.name.updateContext = function(prevType) {
2359
2414
  };
2360
2415
 
2361
2416
  // A recursive descent parser operates by defining functions for all
2417
+ // syntactic elements, and recursively calling those, each function
2418
+ // advancing the input stream and returning an AST node. Precedence
2419
+ // of constructs (for example, the fact that `!x[1]` means `!(x[1])`
2420
+ // instead of `(!x)[1]` is handled by the fact that the parser
2421
+ // function that parses unary prefix operators is called first, and
2422
+ // in turn calls the function that parses `[]` subscripts — that
2423
+ // way, it'll receive the node for `x[1]` already parsed, and wraps
2424
+ // *that* in the unary operator node.
2425
+ //
2426
+ // Acorn uses an [operator precedence parser][opp] to handle binary
2427
+ // operator precedence, because it is much more compact than using
2428
+ // the technique outlined above, which uses different, nesting
2429
+ // functions to specify precedence, for all of the ten binary
2430
+ // precedence levels that JavaScript defines.
2431
+ //
2432
+ // [opp]: http://en.wikipedia.org/wiki/Operator-precedence_parser
2433
+
2362
2434
 
2363
2435
  var pp$5 = Parser.prototype;
2364
2436
 
@@ -2588,7 +2660,7 @@ pp$5.parseMaybeUnary = function(refDestructuringErrors, sawUnary, incDec, forIni
2588
2660
  else { sawUnary = true; }
2589
2661
  expr = this.finishNode(node, update ? "UpdateExpression" : "UnaryExpression");
2590
2662
  } else if (!sawUnary && this.type === types$1.privateId) {
2591
- if (forInit || this.privateNameStack.length === 0) { this.unexpected(); }
2663
+ if ((forInit || this.privateNameStack.length === 0) && this.options.checkPrivateFields) { this.unexpected(); }
2592
2664
  expr = this.parsePrivateIdent();
2593
2665
  // only could be private fields in 'in', such as #x in obj
2594
2666
  if (this.type !== types$1._in) { this.unexpected(); }
@@ -2662,6 +2734,14 @@ pp$5.parseSubscripts = function(base, startPos, startLoc, noCalls, forInit) {
2662
2734
  }
2663
2735
  };
2664
2736
 
2737
+ pp$5.shouldParseAsyncArrow = function() {
2738
+ return !this.canInsertSemicolon() && this.eat(types$1.arrow)
2739
+ };
2740
+
2741
+ pp$5.parseSubscriptAsyncArrow = function(startPos, startLoc, exprList, forInit) {
2742
+ return this.parseArrowExpression(this.startNodeAt(startPos, startLoc), exprList, true, forInit)
2743
+ };
2744
+
2665
2745
  pp$5.parseSubscript = function(base, startPos, startLoc, noCalls, maybeAsyncArrow, optionalChained, forInit) {
2666
2746
  var optionalSupported = this.options.ecmaVersion >= 11;
2667
2747
  var optional = optionalSupported && this.eat(types$1.questionDot);
@@ -2690,7 +2770,7 @@ pp$5.parseSubscript = function(base, startPos, startLoc, noCalls, maybeAsyncArro
2690
2770
  this.awaitPos = 0;
2691
2771
  this.awaitIdentPos = 0;
2692
2772
  var exprList = this.parseExprList(types$1.parenR, this.options.ecmaVersion >= 8, false, refDestructuringErrors);
2693
- if (maybeAsyncArrow && !optional && !this.canInsertSemicolon() && this.eat(types$1.arrow)) {
2773
+ if (maybeAsyncArrow && !optional && this.shouldParseAsyncArrow()) {
2694
2774
  this.checkPatternErrors(refDestructuringErrors, false);
2695
2775
  this.checkYieldAwaitInDefaultParams();
2696
2776
  if (this.awaitIdentPos > 0)
@@ -2698,7 +2778,7 @@ pp$5.parseSubscript = function(base, startPos, startLoc, noCalls, maybeAsyncArro
2698
2778
  this.yieldPos = oldYieldPos;
2699
2779
  this.awaitPos = oldAwaitPos;
2700
2780
  this.awaitIdentPos = oldAwaitIdentPos;
2701
- return this.parseArrowExpression(this.startNodeAt(startPos, startLoc), exprList, true, forInit)
2781
+ return this.parseSubscriptAsyncArrow(startPos, startLoc, exprList, forInit)
2702
2782
  }
2703
2783
  this.checkExpressionErrors(refDestructuringErrors, true);
2704
2784
  this.yieldPos = oldYieldPos || this.yieldPos;
@@ -2728,7 +2808,7 @@ pp$5.parseSubscript = function(base, startPos, startLoc, noCalls, maybeAsyncArro
2728
2808
  // `new`, or an expression wrapped in punctuation like `()`, `[]`,
2729
2809
  // or `{}`.
2730
2810
 
2731
- pp$5.parseExprAtom = function(refDestructuringErrors, forInit) {
2811
+ pp$5.parseExprAtom = function(refDestructuringErrors, forInit, forNew) {
2732
2812
  // If a division operator appears in an expression position, the
2733
2813
  // tokenizer got confused, and we force it to read a regexp instead.
2734
2814
  if (this.type === types$1.slash) { this.readRegexp(); }
@@ -2829,17 +2909,21 @@ pp$5.parseExprAtom = function(refDestructuringErrors, forInit) {
2829
2909
 
2830
2910
  case types$1._import:
2831
2911
  if (this.options.ecmaVersion >= 11) {
2832
- return this.parseExprImport()
2912
+ return this.parseExprImport(forNew)
2833
2913
  } else {
2834
2914
  return this.unexpected()
2835
2915
  }
2836
2916
 
2837
2917
  default:
2838
- this.unexpected();
2918
+ return this.parseExprAtomDefault()
2839
2919
  }
2840
2920
  };
2841
2921
 
2842
- pp$5.parseExprImport = function() {
2922
+ pp$5.parseExprAtomDefault = function() {
2923
+ this.unexpected();
2924
+ };
2925
+
2926
+ pp$5.parseExprImport = function(forNew) {
2843
2927
  var node = this.startNode();
2844
2928
 
2845
2929
  // Consume `import` as an identifier for `import.meta`.
@@ -2847,13 +2931,12 @@ pp$5.parseExprImport = function() {
2847
2931
  if (this.containsEsc) { this.raiseRecoverable(this.start, "Escape sequence in keyword import"); }
2848
2932
  var meta = this.parseIdent(true);
2849
2933
 
2850
- switch (this.type) {
2851
- case types$1.parenL:
2934
+ if (this.type === types$1.parenL && !forNew) {
2852
2935
  return this.parseDynamicImport(node)
2853
- case types$1.dot:
2936
+ } else if (this.type === types$1.dot) {
2854
2937
  node.meta = meta;
2855
2938
  return this.parseImportMeta(node)
2856
- default:
2939
+ } else {
2857
2940
  this.unexpected();
2858
2941
  }
2859
2942
  };
@@ -2909,6 +2992,10 @@ pp$5.parseParenExpression = function() {
2909
2992
  return val
2910
2993
  };
2911
2994
 
2995
+ pp$5.shouldParseArrow = function(exprList) {
2996
+ return !this.canInsertSemicolon()
2997
+ };
2998
+
2912
2999
  pp$5.parseParenAndDistinguishExpression = function(canBeArrow, forInit) {
2913
3000
  var startPos = this.start, startLoc = this.startLoc, val, allowTrailingComma = this.options.ecmaVersion >= 8;
2914
3001
  if (this.options.ecmaVersion >= 6) {
@@ -2928,7 +3015,12 @@ pp$5.parseParenAndDistinguishExpression = function(canBeArrow, forInit) {
2928
3015
  } else if (this.type === types$1.ellipsis) {
2929
3016
  spreadStart = this.start;
2930
3017
  exprList.push(this.parseParenItem(this.parseRestBinding()));
2931
- if (this.type === types$1.comma) { this.raise(this.start, "Comma is not permitted after the rest element"); }
3018
+ if (this.type === types$1.comma) {
3019
+ this.raiseRecoverable(
3020
+ this.start,
3021
+ "Comma is not permitted after the rest element"
3022
+ );
3023
+ }
2932
3024
  break
2933
3025
  } else {
2934
3026
  exprList.push(this.parseMaybeAssign(false, refDestructuringErrors, this.parseParenItem));
@@ -2937,7 +3029,7 @@ pp$5.parseParenAndDistinguishExpression = function(canBeArrow, forInit) {
2937
3029
  var innerEndPos = this.lastTokEnd, innerEndLoc = this.lastTokEndLoc;
2938
3030
  this.expect(types$1.parenR);
2939
3031
 
2940
- if (canBeArrow && !this.canInsertSemicolon() && this.eat(types$1.arrow)) {
3032
+ if (canBeArrow && this.shouldParseArrow(exprList) && this.eat(types$1.arrow)) {
2941
3033
  this.checkPatternErrors(refDestructuringErrors, false);
2942
3034
  this.checkYieldAwaitInDefaultParams();
2943
3035
  this.yieldPos = oldYieldPos;
@@ -3003,11 +3095,8 @@ pp$5.parseNew = function() {
3003
3095
  { this.raiseRecoverable(node.start, "'new.target' can only be used in functions and class static block"); }
3004
3096
  return this.finishNode(node, "MetaProperty")
3005
3097
  }
3006
- var startPos = this.start, startLoc = this.startLoc, isImport = this.type === types$1._import;
3007
- node.callee = this.parseSubscripts(this.parseExprAtom(), startPos, startLoc, true, false);
3008
- if (isImport && node.callee.type === "ImportExpression") {
3009
- this.raise(startPos, "Cannot use new with import()");
3010
- }
3098
+ var startPos = this.start, startLoc = this.startLoc;
3099
+ node.callee = this.parseSubscripts(this.parseExprAtom(null, false, true), startPos, startLoc, true, false);
3011
3100
  if (this.eat(types$1.parenL)) { node.arguments = this.parseExprList(types$1.parenR, this.options.ecmaVersion >= 8, false); }
3012
3101
  else { node.arguments = empty; }
3013
3102
  return this.finishNode(node, "NewExpression")
@@ -3089,7 +3178,7 @@ pp$5.parseProperty = function(isPattern, refDestructuringErrors) {
3089
3178
  if (isPattern) {
3090
3179
  prop.argument = this.parseIdent(false);
3091
3180
  if (this.type === types$1.comma) {
3092
- this.raise(this.start, "Comma is not permitted after the rest element");
3181
+ this.raiseRecoverable(this.start, "Comma is not permitted after the rest element");
3093
3182
  }
3094
3183
  return this.finishNode(prop, "RestElement")
3095
3184
  }
@@ -3125,6 +3214,23 @@ pp$5.parseProperty = function(isPattern, refDestructuringErrors) {
3125
3214
  return this.finishNode(prop, "Property")
3126
3215
  };
3127
3216
 
3217
+ pp$5.parseGetterSetter = function(prop) {
3218
+ prop.kind = prop.key.name;
3219
+ this.parsePropertyName(prop);
3220
+ prop.value = this.parseMethod(false);
3221
+ var paramCount = prop.kind === "get" ? 0 : 1;
3222
+ if (prop.value.params.length !== paramCount) {
3223
+ var start = prop.value.start;
3224
+ if (prop.kind === "get")
3225
+ { this.raiseRecoverable(start, "getter should have no params"); }
3226
+ else
3227
+ { this.raiseRecoverable(start, "setter should have exactly one param"); }
3228
+ } else {
3229
+ if (prop.kind === "set" && prop.value.params[0].type === "RestElement")
3230
+ { this.raiseRecoverable(prop.value.params[0].start, "Setter cannot use rest params"); }
3231
+ }
3232
+ };
3233
+
3128
3234
  pp$5.parsePropertyValue = function(prop, isPattern, isGenerator, isAsync, startPos, startLoc, refDestructuringErrors, containsEsc) {
3129
3235
  if ((isGenerator || isAsync) && this.type === types$1.colon)
3130
3236
  { this.unexpected(); }
@@ -3142,20 +3248,7 @@ pp$5.parsePropertyValue = function(prop, isPattern, isGenerator, isAsync, startP
3142
3248
  (prop.key.name === "get" || prop.key.name === "set") &&
3143
3249
  (this.type !== types$1.comma && this.type !== types$1.braceR && this.type !== types$1.eq)) {
3144
3250
  if (isGenerator || isAsync) { this.unexpected(); }
3145
- prop.kind = prop.key.name;
3146
- this.parsePropertyName(prop);
3147
- prop.value = this.parseMethod(false);
3148
- var paramCount = prop.kind === "get" ? 0 : 1;
3149
- if (prop.value.params.length !== paramCount) {
3150
- var start = prop.value.start;
3151
- if (prop.kind === "get")
3152
- { this.raiseRecoverable(start, "getter should have no params"); }
3153
- else
3154
- { this.raiseRecoverable(start, "setter should have exactly one param"); }
3155
- } else {
3156
- if (prop.kind === "set" && prop.value.params[0].type === "RestElement")
3157
- { this.raiseRecoverable(prop.value.params[0].start, "Setter cannot use rest params"); }
3158
- }
3251
+ this.parseGetterSetter(prop);
3159
3252
  } else if (this.options.ecmaVersion >= 6 && !prop.computed && prop.key.type === "Identifier") {
3160
3253
  if (isGenerator || isAsync) { this.unexpected(); }
3161
3254
  this.checkUnreserved(prop.key);
@@ -3367,6 +3460,18 @@ pp$5.checkUnreserved = function(ref) {
3367
3460
  // identifiers.
3368
3461
 
3369
3462
  pp$5.parseIdent = function(liberal) {
3463
+ var node = this.parseIdentNode();
3464
+ this.next(!!liberal);
3465
+ this.finishNode(node, "Identifier");
3466
+ if (!liberal) {
3467
+ this.checkUnreserved(node);
3468
+ if (node.name === "await" && !this.awaitIdentPos)
3469
+ { this.awaitIdentPos = node.start; }
3470
+ }
3471
+ return node
3472
+ };
3473
+
3474
+ pp$5.parseIdentNode = function() {
3370
3475
  var node = this.startNode();
3371
3476
  if (this.type === types$1.name) {
3372
3477
  node.name = this.value;
@@ -3378,19 +3483,12 @@ pp$5.parseIdent = function(liberal) {
3378
3483
  // But there is no chance to pop the context if the keyword is consumed as an identifier such as a property name.
3379
3484
  // If the previous token is a dot, this does not apply because the context-managing code already ignored the keyword
3380
3485
  if ((node.name === "class" || node.name === "function") &&
3381
- (this.lastTokEnd !== this.lastTokStart + 1 || this.input.charCodeAt(this.lastTokStart) !== 46)) {
3486
+ (this.lastTokEnd !== this.lastTokStart + 1 || this.input.charCodeAt(this.lastTokStart) !== 46)) {
3382
3487
  this.context.pop();
3383
3488
  }
3384
3489
  } else {
3385
3490
  this.unexpected();
3386
3491
  }
3387
- this.next(!!liberal);
3388
- this.finishNode(node, "Identifier");
3389
- if (!liberal) {
3390
- this.checkUnreserved(node);
3391
- if (node.name === "await" && !this.awaitIdentPos)
3392
- { this.awaitIdentPos = node.start; }
3393
- }
3394
3492
  return node
3395
3493
  };
3396
3494
 
@@ -3405,10 +3503,12 @@ pp$5.parsePrivateIdent = function() {
3405
3503
  this.finishNode(node, "PrivateIdentifier");
3406
3504
 
3407
3505
  // For validating existence
3408
- if (this.privateNameStack.length === 0) {
3409
- this.raise(node.start, ("Private field '#" + (node.name) + "' must be declared in an enclosing class"));
3410
- } else {
3411
- this.privateNameStack[this.privateNameStack.length - 1].used.push(node);
3506
+ if (this.options.checkPrivateFields) {
3507
+ if (this.privateNameStack.length === 0) {
3508
+ this.raise(node.start, ("Private field '#" + (node.name) + "' must be declared in an enclosing class"));
3509
+ } else {
3510
+ this.privateNameStack[this.privateNameStack.length - 1].used.push(node);
3511
+ }
3412
3512
  }
3413
3513
 
3414
3514
  return node
@@ -3630,6 +3730,18 @@ var unicodeBinaryProperties = {
3630
3730
  14: ecma14BinaryProperties
3631
3731
  };
3632
3732
 
3733
+ // #table-binary-unicode-properties-of-strings
3734
+ 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";
3735
+
3736
+ var unicodeBinaryPropertiesOfStrings = {
3737
+ 9: "",
3738
+ 10: "",
3739
+ 11: "",
3740
+ 12: "",
3741
+ 13: "",
3742
+ 14: ecma14BinaryPropertiesOfStrings
3743
+ };
3744
+
3633
3745
  // #table-unicode-general-category-values
3634
3746
  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";
3635
3747
 
@@ -3639,7 +3751,7 @@ var ecma10ScriptValues = ecma9ScriptValues + " Dogra Dogr Gunjala_Gondi Gong Han
3639
3751
  var ecma11ScriptValues = ecma10ScriptValues + " Elymaic Elym Nandinagari Nand Nyiakeng_Puachue_Hmong Hmnp Wancho Wcho";
3640
3752
  var ecma12ScriptValues = ecma11ScriptValues + " Chorasmian Chrs Diak Dives_Akuru Khitan_Small_Script Kits Yezi Yezidi";
3641
3753
  var ecma13ScriptValues = ecma12ScriptValues + " Cypro_Minoan Cpmn Old_Uyghur Ougr Tangsa Tnsa Toto Vithkuqi Vith";
3642
- var ecma14ScriptValues = ecma13ScriptValues + " Kawi Nag_Mundari Nagm";
3754
+ var ecma14ScriptValues = ecma13ScriptValues + " Hrkt Katakana_Or_Hiragana Kawi Nag_Mundari Nagm Unknown Zzzz";
3643
3755
 
3644
3756
  var unicodeScriptValues = {
3645
3757
  9: ecma9ScriptValues,
@@ -3654,6 +3766,7 @@ var data = {};
3654
3766
  function buildUnicodeData(ecmaVersion) {
3655
3767
  var d = data[ecmaVersion] = {
3656
3768
  binary: wordsRegexp(unicodeBinaryProperties[ecmaVersion] + " " + unicodeGeneralCategoryValues),
3769
+ binaryOfStrings: wordsRegexp(unicodeBinaryPropertiesOfStrings[ecmaVersion]),
3657
3770
  nonBinary: {
3658
3771
  General_Category: wordsRegexp(unicodeGeneralCategoryValues),
3659
3772
  Script: wordsRegexp(unicodeScriptValues[ecmaVersion])
@@ -3676,12 +3789,13 @@ var pp$1 = Parser.prototype;
3676
3789
 
3677
3790
  var RegExpValidationState = function RegExpValidationState(parser) {
3678
3791
  this.parser = parser;
3679
- this.validFlags = "gim" + (parser.options.ecmaVersion >= 6 ? "uy" : "") + (parser.options.ecmaVersion >= 9 ? "s" : "") + (parser.options.ecmaVersion >= 13 ? "d" : "");
3792
+ this.validFlags = "gim" + (parser.options.ecmaVersion >= 6 ? "uy" : "") + (parser.options.ecmaVersion >= 9 ? "s" : "") + (parser.options.ecmaVersion >= 13 ? "d" : "") + (parser.options.ecmaVersion >= 15 ? "v" : "");
3680
3793
  this.unicodeProperties = data[parser.options.ecmaVersion >= 14 ? 14 : parser.options.ecmaVersion];
3681
3794
  this.source = "";
3682
3795
  this.flags = "";
3683
3796
  this.start = 0;
3684
3797
  this.switchU = false;
3798
+ this.switchV = false;
3685
3799
  this.switchN = false;
3686
3800
  this.pos = 0;
3687
3801
  this.lastIntValue = 0;
@@ -3694,12 +3808,20 @@ var RegExpValidationState = function RegExpValidationState(parser) {
3694
3808
  };
3695
3809
 
3696
3810
  RegExpValidationState.prototype.reset = function reset (start, pattern, flags) {
3811
+ var unicodeSets = flags.indexOf("v") !== -1;
3697
3812
  var unicode = flags.indexOf("u") !== -1;
3698
3813
  this.start = start | 0;
3699
3814
  this.source = pattern + "";
3700
3815
  this.flags = flags;
3701
- this.switchU = unicode && this.parser.options.ecmaVersion >= 6;
3702
- this.switchN = unicode && this.parser.options.ecmaVersion >= 9;
3816
+ if (unicodeSets && this.parser.options.ecmaVersion >= 15) {
3817
+ this.switchU = true;
3818
+ this.switchV = true;
3819
+ this.switchN = true;
3820
+ } else {
3821
+ this.switchU = unicode && this.parser.options.ecmaVersion >= 6;
3822
+ this.switchV = false;
3823
+ this.switchN = unicode && this.parser.options.ecmaVersion >= 9;
3824
+ }
3703
3825
  };
3704
3826
 
3705
3827
  RegExpValidationState.prototype.raise = function raise (message) {
@@ -3768,6 +3890,23 @@ RegExpValidationState.prototype.eat = function eat (ch, forceU) {
3768
3890
  return false
3769
3891
  };
3770
3892
 
3893
+ RegExpValidationState.prototype.eatChars = function eatChars (chs, forceU) {
3894
+ if ( forceU === void 0 ) forceU = false;
3895
+
3896
+ var pos = this.pos;
3897
+ for (var i = 0, list = chs; i < list.length; i += 1) {
3898
+ var ch = list[i];
3899
+
3900
+ var current = this.at(pos, forceU);
3901
+ if (current === -1 || current !== ch) {
3902
+ return false
3903
+ }
3904
+ pos = this.nextIndex(pos, forceU);
3905
+ }
3906
+ this.pos = pos;
3907
+ return true
3908
+ };
3909
+
3771
3910
  /**
3772
3911
  * Validate the flags part of a given RegExpLiteral.
3773
3912
  *
@@ -3778,6 +3917,9 @@ pp$1.validateRegExpFlags = function(state) {
3778
3917
  var validFlags = state.validFlags;
3779
3918
  var flags = state.flags;
3780
3919
 
3920
+ var u = false;
3921
+ var v = false;
3922
+
3781
3923
  for (var i = 0; i < flags.length; i++) {
3782
3924
  var flag = flags.charAt(i);
3783
3925
  if (validFlags.indexOf(flag) === -1) {
@@ -3786,6 +3928,11 @@ pp$1.validateRegExpFlags = function(state) {
3786
3928
  if (flags.indexOf(flag, i + 1) > -1) {
3787
3929
  this.raise(state.start, "Duplicate regular expression flag");
3788
3930
  }
3931
+ if (flag === "u") { u = true; }
3932
+ if (flag === "v") { v = true; }
3933
+ }
3934
+ if (this.options.ecmaVersion >= 15 && u && v) {
3935
+ this.raise(state.start, "Invalid regular expression flag");
3789
3936
  }
3790
3937
  };
3791
3938
 
@@ -4404,6 +4551,12 @@ pp$1.regexp_eatDecimalEscape = function(state) {
4404
4551
  return false
4405
4552
  };
4406
4553
 
4554
+ // Return values used by character set parsing methods, needed to
4555
+ // forbid negation of sets that can match strings.
4556
+ var CharSetNone = 0; // Nothing parsed
4557
+ var CharSetOk = 1; // Construct parsed, cannot contain strings
4558
+ var CharSetString = 2; // Construct parsed, can contain strings
4559
+
4407
4560
  // https://www.ecma-international.org/ecma-262/8.0/#prod-CharacterClassEscape
4408
4561
  pp$1.regexp_eatCharacterClassEscape = function(state) {
4409
4562
  var ch = state.current();
@@ -4411,28 +4564,32 @@ pp$1.regexp_eatCharacterClassEscape = function(state) {
4411
4564
  if (isCharacterClassEscape(ch)) {
4412
4565
  state.lastIntValue = -1;
4413
4566
  state.advance();
4414
- return true
4567
+ return CharSetOk
4415
4568
  }
4416
4569
 
4570
+ var negate = false;
4417
4571
  if (
4418
4572
  state.switchU &&
4419
4573
  this.options.ecmaVersion >= 9 &&
4420
- (ch === 0x50 /* P */ || ch === 0x70 /* p */)
4574
+ ((negate = ch === 0x50 /* P */) || ch === 0x70 /* p */)
4421
4575
  ) {
4422
4576
  state.lastIntValue = -1;
4423
4577
  state.advance();
4578
+ var result;
4424
4579
  if (
4425
4580
  state.eat(0x7B /* { */) &&
4426
- this.regexp_eatUnicodePropertyValueExpression(state) &&
4581
+ (result = this.regexp_eatUnicodePropertyValueExpression(state)) &&
4427
4582
  state.eat(0x7D /* } */)
4428
4583
  ) {
4429
- return true
4584
+ if (negate && result === CharSetString) { state.raise("Invalid property name"); }
4585
+ return result
4430
4586
  }
4431
4587
  state.raise("Invalid property name");
4432
4588
  }
4433
4589
 
4434
- return false
4590
+ return CharSetNone
4435
4591
  };
4592
+
4436
4593
  function isCharacterClassEscape(ch) {
4437
4594
  return (
4438
4595
  ch === 0x64 /* d */ ||
@@ -4456,7 +4613,7 @@ pp$1.regexp_eatUnicodePropertyValueExpression = function(state) {
4456
4613
  if (this.regexp_eatUnicodePropertyValue(state)) {
4457
4614
  var value = state.lastStringValue;
4458
4615
  this.regexp_validateUnicodePropertyNameAndValue(state, name, value);
4459
- return true
4616
+ return CharSetOk
4460
4617
  }
4461
4618
  }
4462
4619
  state.pos = start;
@@ -4464,20 +4621,22 @@ pp$1.regexp_eatUnicodePropertyValueExpression = function(state) {
4464
4621
  // LoneUnicodePropertyNameOrValue
4465
4622
  if (this.regexp_eatLoneUnicodePropertyNameOrValue(state)) {
4466
4623
  var nameOrValue = state.lastStringValue;
4467
- this.regexp_validateUnicodePropertyNameOrValue(state, nameOrValue);
4468
- return true
4624
+ return this.regexp_validateUnicodePropertyNameOrValue(state, nameOrValue)
4469
4625
  }
4470
- return false
4626
+ return CharSetNone
4471
4627
  };
4628
+
4472
4629
  pp$1.regexp_validateUnicodePropertyNameAndValue = function(state, name, value) {
4473
4630
  if (!hasOwn(state.unicodeProperties.nonBinary, name))
4474
4631
  { state.raise("Invalid property name"); }
4475
4632
  if (!state.unicodeProperties.nonBinary[name].test(value))
4476
4633
  { state.raise("Invalid property value"); }
4477
4634
  };
4635
+
4478
4636
  pp$1.regexp_validateUnicodePropertyNameOrValue = function(state, nameOrValue) {
4479
- if (!state.unicodeProperties.binary.test(nameOrValue))
4480
- { state.raise("Invalid property name"); }
4637
+ if (state.unicodeProperties.binary.test(nameOrValue)) { return CharSetOk }
4638
+ if (state.switchV && state.unicodeProperties.binaryOfStrings.test(nameOrValue)) { return CharSetString }
4639
+ state.raise("Invalid property name");
4481
4640
  };
4482
4641
 
4483
4642
  // UnicodePropertyName ::
@@ -4491,6 +4650,7 @@ pp$1.regexp_eatUnicodePropertyName = function(state) {
4491
4650
  }
4492
4651
  return state.lastStringValue !== ""
4493
4652
  };
4653
+
4494
4654
  function isUnicodePropertyNameCharacter(ch) {
4495
4655
  return isControlLetter(ch) || ch === 0x5F /* _ */
4496
4656
  }
@@ -4519,21 +4679,29 @@ pp$1.regexp_eatLoneUnicodePropertyNameOrValue = function(state) {
4519
4679
  // https://www.ecma-international.org/ecma-262/8.0/#prod-CharacterClass
4520
4680
  pp$1.regexp_eatCharacterClass = function(state) {
4521
4681
  if (state.eat(0x5B /* [ */)) {
4522
- state.eat(0x5E /* ^ */);
4523
- this.regexp_classRanges(state);
4524
- if (state.eat(0x5D /* ] */)) {
4525
- return true
4526
- }
4527
- // Unreachable since it threw "unterminated regular expression" error before.
4528
- state.raise("Unterminated character class");
4682
+ var negate = state.eat(0x5E /* ^ */);
4683
+ var result = this.regexp_classContents(state);
4684
+ if (!state.eat(0x5D /* ] */))
4685
+ { state.raise("Unterminated character class"); }
4686
+ if (negate && result === CharSetString)
4687
+ { state.raise("Negated character class may contain strings"); }
4688
+ return true
4529
4689
  }
4530
4690
  return false
4531
4691
  };
4532
4692
 
4693
+ // https://tc39.es/ecma262/#prod-ClassContents
4533
4694
  // https://www.ecma-international.org/ecma-262/8.0/#prod-ClassRanges
4695
+ pp$1.regexp_classContents = function(state) {
4696
+ if (state.current() === 0x5D /* ] */) { return CharSetOk }
4697
+ if (state.switchV) { return this.regexp_classSetExpression(state) }
4698
+ this.regexp_nonEmptyClassRanges(state);
4699
+ return CharSetOk
4700
+ };
4701
+
4534
4702
  // https://www.ecma-international.org/ecma-262/8.0/#prod-NonemptyClassRanges
4535
4703
  // https://www.ecma-international.org/ecma-262/8.0/#prod-NonemptyClassRangesNoDash
4536
- pp$1.regexp_classRanges = function(state) {
4704
+ pp$1.regexp_nonEmptyClassRanges = function(state) {
4537
4705
  while (this.regexp_eatClassAtom(state)) {
4538
4706
  var left = state.lastIntValue;
4539
4707
  if (state.eat(0x2D /* - */) && this.regexp_eatClassAtom(state)) {
@@ -4605,6 +4773,205 @@ pp$1.regexp_eatClassEscape = function(state) {
4605
4773
  )
4606
4774
  };
4607
4775
 
4776
+ // https://tc39.es/ecma262/#prod-ClassSetExpression
4777
+ // https://tc39.es/ecma262/#prod-ClassUnion
4778
+ // https://tc39.es/ecma262/#prod-ClassIntersection
4779
+ // https://tc39.es/ecma262/#prod-ClassSubtraction
4780
+ pp$1.regexp_classSetExpression = function(state) {
4781
+ var result = CharSetOk, subResult;
4782
+ if (this.regexp_eatClassSetRange(state)) ; else if (subResult = this.regexp_eatClassSetOperand(state)) {
4783
+ if (subResult === CharSetString) { result = CharSetString; }
4784
+ // https://tc39.es/ecma262/#prod-ClassIntersection
4785
+ var start = state.pos;
4786
+ while (state.eatChars([0x26, 0x26] /* && */)) {
4787
+ if (
4788
+ state.current() !== 0x26 /* & */ &&
4789
+ (subResult = this.regexp_eatClassSetOperand(state))
4790
+ ) {
4791
+ if (subResult !== CharSetString) { result = CharSetOk; }
4792
+ continue
4793
+ }
4794
+ state.raise("Invalid character in character class");
4795
+ }
4796
+ if (start !== state.pos) { return result }
4797
+ // https://tc39.es/ecma262/#prod-ClassSubtraction
4798
+ while (state.eatChars([0x2D, 0x2D] /* -- */)) {
4799
+ if (this.regexp_eatClassSetOperand(state)) { continue }
4800
+ state.raise("Invalid character in character class");
4801
+ }
4802
+ if (start !== state.pos) { return result }
4803
+ } else {
4804
+ state.raise("Invalid character in character class");
4805
+ }
4806
+ // https://tc39.es/ecma262/#prod-ClassUnion
4807
+ for (;;) {
4808
+ if (this.regexp_eatClassSetRange(state)) { continue }
4809
+ subResult = this.regexp_eatClassSetOperand(state);
4810
+ if (!subResult) { return result }
4811
+ if (subResult === CharSetString) { result = CharSetString; }
4812
+ }
4813
+ };
4814
+
4815
+ // https://tc39.es/ecma262/#prod-ClassSetRange
4816
+ pp$1.regexp_eatClassSetRange = function(state) {
4817
+ var start = state.pos;
4818
+ if (this.regexp_eatClassSetCharacter(state)) {
4819
+ var left = state.lastIntValue;
4820
+ if (state.eat(0x2D /* - */) && this.regexp_eatClassSetCharacter(state)) {
4821
+ var right = state.lastIntValue;
4822
+ if (left !== -1 && right !== -1 && left > right) {
4823
+ state.raise("Range out of order in character class");
4824
+ }
4825
+ return true
4826
+ }
4827
+ state.pos = start;
4828
+ }
4829
+ return false
4830
+ };
4831
+
4832
+ // https://tc39.es/ecma262/#prod-ClassSetOperand
4833
+ pp$1.regexp_eatClassSetOperand = function(state) {
4834
+ if (this.regexp_eatClassSetCharacter(state)) { return CharSetOk }
4835
+ return this.regexp_eatClassStringDisjunction(state) || this.regexp_eatNestedClass(state)
4836
+ };
4837
+
4838
+ // https://tc39.es/ecma262/#prod-NestedClass
4839
+ pp$1.regexp_eatNestedClass = function(state) {
4840
+ var start = state.pos;
4841
+ if (state.eat(0x5B /* [ */)) {
4842
+ var negate = state.eat(0x5E /* ^ */);
4843
+ var result = this.regexp_classContents(state);
4844
+ if (state.eat(0x5D /* ] */)) {
4845
+ if (negate && result === CharSetString) {
4846
+ state.raise("Negated character class may contain strings");
4847
+ }
4848
+ return result
4849
+ }
4850
+ state.pos = start;
4851
+ }
4852
+ if (state.eat(0x5C /* \ */)) {
4853
+ var result$1 = this.regexp_eatCharacterClassEscape(state);
4854
+ if (result$1) {
4855
+ return result$1
4856
+ }
4857
+ state.pos = start;
4858
+ }
4859
+ return null
4860
+ };
4861
+
4862
+ // https://tc39.es/ecma262/#prod-ClassStringDisjunction
4863
+ pp$1.regexp_eatClassStringDisjunction = function(state) {
4864
+ var start = state.pos;
4865
+ if (state.eatChars([0x5C, 0x71] /* \q */)) {
4866
+ if (state.eat(0x7B /* { */)) {
4867
+ var result = this.regexp_classStringDisjunctionContents(state);
4868
+ if (state.eat(0x7D /* } */)) {
4869
+ return result
4870
+ }
4871
+ } else {
4872
+ // Make the same message as V8.
4873
+ state.raise("Invalid escape");
4874
+ }
4875
+ state.pos = start;
4876
+ }
4877
+ return null
4878
+ };
4879
+
4880
+ // https://tc39.es/ecma262/#prod-ClassStringDisjunctionContents
4881
+ pp$1.regexp_classStringDisjunctionContents = function(state) {
4882
+ var result = this.regexp_classString(state);
4883
+ while (state.eat(0x7C /* | */)) {
4884
+ if (this.regexp_classString(state) === CharSetString) { result = CharSetString; }
4885
+ }
4886
+ return result
4887
+ };
4888
+
4889
+ // https://tc39.es/ecma262/#prod-ClassString
4890
+ // https://tc39.es/ecma262/#prod-NonEmptyClassString
4891
+ pp$1.regexp_classString = function(state) {
4892
+ var count = 0;
4893
+ while (this.regexp_eatClassSetCharacter(state)) { count++; }
4894
+ return count === 1 ? CharSetOk : CharSetString
4895
+ };
4896
+
4897
+ // https://tc39.es/ecma262/#prod-ClassSetCharacter
4898
+ pp$1.regexp_eatClassSetCharacter = function(state) {
4899
+ var start = state.pos;
4900
+ if (state.eat(0x5C /* \ */)) {
4901
+ if (
4902
+ this.regexp_eatCharacterEscape(state) ||
4903
+ this.regexp_eatClassSetReservedPunctuator(state)
4904
+ ) {
4905
+ return true
4906
+ }
4907
+ if (state.eat(0x62 /* b */)) {
4908
+ state.lastIntValue = 0x08; /* <BS> */
4909
+ return true
4910
+ }
4911
+ state.pos = start;
4912
+ return false
4913
+ }
4914
+ var ch = state.current();
4915
+ if (ch < 0 || ch === state.lookahead() && isClassSetReservedDoublePunctuatorCharacter(ch)) { return false }
4916
+ if (isClassSetSyntaxCharacter(ch)) { return false }
4917
+ state.advance();
4918
+ state.lastIntValue = ch;
4919
+ return true
4920
+ };
4921
+
4922
+ // https://tc39.es/ecma262/#prod-ClassSetReservedDoublePunctuator
4923
+ function isClassSetReservedDoublePunctuatorCharacter(ch) {
4924
+ return (
4925
+ ch === 0x21 /* ! */ ||
4926
+ ch >= 0x23 /* # */ && ch <= 0x26 /* & */ ||
4927
+ ch >= 0x2A /* * */ && ch <= 0x2C /* , */ ||
4928
+ ch === 0x2E /* . */ ||
4929
+ ch >= 0x3A /* : */ && ch <= 0x40 /* @ */ ||
4930
+ ch === 0x5E /* ^ */ ||
4931
+ ch === 0x60 /* ` */ ||
4932
+ ch === 0x7E /* ~ */
4933
+ )
4934
+ }
4935
+
4936
+ // https://tc39.es/ecma262/#prod-ClassSetSyntaxCharacter
4937
+ function isClassSetSyntaxCharacter(ch) {
4938
+ return (
4939
+ ch === 0x28 /* ( */ ||
4940
+ ch === 0x29 /* ) */ ||
4941
+ ch === 0x2D /* - */ ||
4942
+ ch === 0x2F /* / */ ||
4943
+ ch >= 0x5B /* [ */ && ch <= 0x5D /* ] */ ||
4944
+ ch >= 0x7B /* { */ && ch <= 0x7D /* } */
4945
+ )
4946
+ }
4947
+
4948
+ // https://tc39.es/ecma262/#prod-ClassSetReservedPunctuator
4949
+ pp$1.regexp_eatClassSetReservedPunctuator = function(state) {
4950
+ var ch = state.current();
4951
+ if (isClassSetReservedPunctuator(ch)) {
4952
+ state.lastIntValue = ch;
4953
+ state.advance();
4954
+ return true
4955
+ }
4956
+ return false
4957
+ };
4958
+
4959
+ // https://tc39.es/ecma262/#prod-ClassSetReservedPunctuator
4960
+ function isClassSetReservedPunctuator(ch) {
4961
+ return (
4962
+ ch === 0x21 /* ! */ ||
4963
+ ch === 0x23 /* # */ ||
4964
+ ch === 0x25 /* % */ ||
4965
+ ch === 0x26 /* & */ ||
4966
+ ch === 0x2C /* , */ ||
4967
+ ch === 0x2D /* - */ ||
4968
+ ch >= 0x3A /* : */ && ch <= 0x3E /* > */ ||
4969
+ ch === 0x40 /* @ */ ||
4970
+ ch === 0x60 /* ` */ ||
4971
+ ch === 0x7E /* ~ */
4972
+ )
4973
+ }
4974
+
4608
4975
  // https://www.ecma-international.org/ecma-262/8.0/#prod-annexB-ClassControlLetter
4609
4976
  pp$1.regexp_eatClassControlLetter = function(state) {
4610
4977
  var ch = state.current();
@@ -5525,8 +5892,23 @@ pp.readWord = function() {
5525
5892
  };
5526
5893
 
5527
5894
  // Acorn is a tiny, fast JavaScript parser written in JavaScript.
5895
+ //
5896
+ // Acorn was written by Marijn Haverbeke, Ingvar Stepanyan, and
5897
+ // various contributors and released under an MIT license.
5898
+ //
5899
+ // Git repositories for Acorn are available at
5900
+ //
5901
+ // http://marijnhaverbeke.nl/git/acorn
5902
+ // https://github.com/acornjs/acorn.git
5903
+ //
5904
+ // Please use the [github bug tracker][ghbt] to report issues.
5905
+ //
5906
+ // [ghbt]: https://github.com/acornjs/acorn/issues
5907
+ //
5908
+ // [walk]: util/walk.js
5909
+
5528
5910
 
5529
- var version = "8.8.2";
5911
+ var version = "8.10.0";
5530
5912
 
5531
5913
  Parser.acorn = {
5532
5914
  Parser: Parser,