rollup 3.25.0 → 3.25.2
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/LICENSE.md +1 -1
- package/dist/bin/rollup +2 -2
- package/dist/es/rollup.js +2 -2
- package/dist/es/shared/node-entry.js +599 -184
- package/dist/es/shared/watch.js +2 -2
- package/dist/loadConfigFile.js +2 -2
- package/dist/rollup.d.ts +1 -1
- package/dist/rollup.js +2 -2
- package/dist/shared/fsevents-importer.js +2 -2
- package/dist/shared/index.js +2 -2
- package/dist/shared/loadConfigFile.js +2 -2
- package/dist/shared/rollup.js +599 -184
- package/dist/shared/watch-cli.js +2 -2
- package/dist/shared/watch-proxy.js +2 -2
- package/dist/shared/watch.js +2 -2
- package/package.json +22 -19
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/*
|
|
2
2
|
@license
|
|
3
|
-
Rollup.js v3.25.
|
|
4
|
-
|
|
3
|
+
Rollup.js v3.25.2
|
|
4
|
+
Sat, 24 Jun 2023 20:37:46 GMT - commit 91bf079599b84f97ea694dd1ecd0108ecf53fc97
|
|
5
5
|
|
|
6
6
|
https://github.com/rollup/rollup
|
|
7
7
|
|
|
@@ -15,7 +15,7 @@ import { createHash as createHash$1 } from 'node:crypto';
|
|
|
15
15
|
import { lstat, realpath, readdir, readFile, mkdir, writeFile } from 'node:fs/promises';
|
|
16
16
|
import * as tty from 'tty';
|
|
17
17
|
|
|
18
|
-
var version$1 = "3.25.
|
|
18
|
+
var version$1 = "3.25.2";
|
|
19
19
|
|
|
20
20
|
const comma = ','.charCodeAt(0);
|
|
21
21
|
const semicolon = ';'.charCodeAt(0);
|
|
@@ -2054,45 +2054,77 @@ const logLevelPriority = {
|
|
|
2054
2054
|
[LOGLEVEL_WARN]: 2
|
|
2055
2055
|
};
|
|
2056
2056
|
|
|
2057
|
-
|
|
2058
|
-
|
|
2059
|
-
|
|
2060
|
-
|
|
2061
|
-
|
|
2062
|
-
|
|
2063
|
-
|
|
2064
|
-
|
|
2065
|
-
|
|
2066
|
-
|
|
2067
|
-
|
|
2068
|
-
|
|
2069
|
-
|
|
2070
|
-
|
|
2071
|
-
|
|
2072
|
-
|
|
2073
|
-
|
|
2074
|
-
|
|
2075
|
-
|
|
2076
|
-
|
|
2077
|
-
|
|
2078
|
-
|
|
2079
|
-
|
|
2080
|
-
|
|
2081
|
-
|
|
2082
|
-
|
|
2083
|
-
|
|
2084
|
-
|
|
2085
|
-
|
|
2086
|
-
|
|
2087
|
-
|
|
2088
|
-
|
|
2089
|
-
|
|
2057
|
+
/** @typedef {import('./types').Location} Location */
|
|
2058
|
+
|
|
2059
|
+
/**
|
|
2060
|
+
* @param {import('./types').Range} range
|
|
2061
|
+
* @param {number} index
|
|
2062
|
+
*/
|
|
2063
|
+
function rangeContains(range, index) {
|
|
2064
|
+
return range.start <= index && index < range.end;
|
|
2065
|
+
}
|
|
2066
|
+
|
|
2067
|
+
/**
|
|
2068
|
+
* @param {string} source
|
|
2069
|
+
* @param {import('./types').Options} [options]
|
|
2070
|
+
*/
|
|
2071
|
+
function getLocator(source, options = {}) {
|
|
2072
|
+
const { offsetLine = 0, offsetColumn = 0 } = options;
|
|
2073
|
+
|
|
2074
|
+
let start = 0;
|
|
2075
|
+
const ranges = source.split('\n').map((line, i) => {
|
|
2076
|
+
const end = start + line.length + 1;
|
|
2077
|
+
|
|
2078
|
+
/** @type {import('./types').Range} */
|
|
2079
|
+
const range = { start, end, line: i };
|
|
2080
|
+
|
|
2081
|
+
start = end;
|
|
2082
|
+
return range;
|
|
2083
|
+
});
|
|
2084
|
+
|
|
2085
|
+
let i = 0;
|
|
2086
|
+
|
|
2087
|
+
/**
|
|
2088
|
+
* @param {string | number} search
|
|
2089
|
+
* @param {number} [index]
|
|
2090
|
+
* @returns {Location | undefined}
|
|
2091
|
+
*/
|
|
2092
|
+
function locator(search, index) {
|
|
2093
|
+
if (typeof search === 'string') {
|
|
2094
|
+
search = source.indexOf(search, index ?? 0);
|
|
2095
|
+
}
|
|
2096
|
+
|
|
2097
|
+
if (search === -1) return undefined;
|
|
2098
|
+
|
|
2099
|
+
let range = ranges[i];
|
|
2100
|
+
|
|
2101
|
+
const d = search >= range.end ? 1 : -1;
|
|
2102
|
+
|
|
2103
|
+
while (range) {
|
|
2104
|
+
if (rangeContains(range, search)) {
|
|
2105
|
+
return {
|
|
2106
|
+
line: offsetLine + range.line,
|
|
2107
|
+
column: offsetColumn + search - range.start,
|
|
2108
|
+
character: search
|
|
2109
|
+
};
|
|
2110
|
+
}
|
|
2111
|
+
|
|
2112
|
+
i += d;
|
|
2113
|
+
range = ranges[i];
|
|
2114
|
+
}
|
|
2115
|
+
}
|
|
2116
|
+
|
|
2117
|
+
return locator;
|
|
2090
2118
|
}
|
|
2119
|
+
|
|
2120
|
+
/**
|
|
2121
|
+
* @param {string} source
|
|
2122
|
+
* @param {string | number} search
|
|
2123
|
+
* @param {import('./types').Options} [options]
|
|
2124
|
+
* @returns {Location | undefined}
|
|
2125
|
+
*/
|
|
2091
2126
|
function locate(source, search, options) {
|
|
2092
|
-
|
|
2093
|
-
throw new Error('locate takes a { startIndex, offsetLine, offsetColumn } object as the third argument');
|
|
2094
|
-
}
|
|
2095
|
-
return getLocator(source, options)(search, options && options.startIndex);
|
|
2127
|
+
return getLocator(source, options)(search, options && options.startIndex);
|
|
2096
2128
|
}
|
|
2097
2129
|
|
|
2098
2130
|
function spaces(index) {
|
|
@@ -2630,8 +2662,11 @@ function logParseError(error, moduleId) {
|
|
|
2630
2662
|
};
|
|
2631
2663
|
}
|
|
2632
2664
|
function logPluginError(error, plugin, { hook, id } = {}) {
|
|
2633
|
-
|
|
2634
|
-
|
|
2665
|
+
const code = error.code;
|
|
2666
|
+
if (!error.pluginCode &&
|
|
2667
|
+
code != null &&
|
|
2668
|
+
(typeof code !== 'string' || (typeof code === 'string' && !code.startsWith('PLUGIN_')))) {
|
|
2669
|
+
error.pluginCode = code;
|
|
2635
2670
|
}
|
|
2636
2671
|
error.code = PLUGIN_ERROR;
|
|
2637
2672
|
error.plugin = plugin;
|
|
@@ -8731,6 +8766,9 @@ class FunctionBase extends NodeBase {
|
|
|
8731
8766
|
if (path.length > 0 || interaction.type !== INTERACTION_CALLED) {
|
|
8732
8767
|
return this.getObjectEntity().hasEffectsOnInteractionAtPath(path, interaction, context);
|
|
8733
8768
|
}
|
|
8769
|
+
if (this.annotationNoSideEffects) {
|
|
8770
|
+
return false;
|
|
8771
|
+
}
|
|
8734
8772
|
if (this.async) {
|
|
8735
8773
|
const { propertyReadSideEffects } = this.context.options
|
|
8736
8774
|
.treeshake;
|
|
@@ -8794,12 +8832,13 @@ class ArrowFunctionExpression extends FunctionBase {
|
|
|
8794
8832
|
return false;
|
|
8795
8833
|
}
|
|
8796
8834
|
hasEffectsOnInteractionAtPath(path, interaction, context) {
|
|
8797
|
-
if (super.hasEffectsOnInteractionAtPath(path, interaction, context))
|
|
8835
|
+
if (super.hasEffectsOnInteractionAtPath(path, interaction, context)) {
|
|
8798
8836
|
return true;
|
|
8837
|
+
}
|
|
8838
|
+
if (this.annotationNoSideEffects) {
|
|
8839
|
+
return false;
|
|
8840
|
+
}
|
|
8799
8841
|
if (interaction.type === INTERACTION_CALLED) {
|
|
8800
|
-
if (this.annotationNoSideEffects) {
|
|
8801
|
-
return false;
|
|
8802
|
-
}
|
|
8803
8842
|
const { ignore, brokenFlow } = context;
|
|
8804
8843
|
context.ignore = {
|
|
8805
8844
|
breaks: false,
|
|
@@ -17819,6 +17858,9 @@ var nonASCIIidentifierChars = "\u200c\u200d\xb7\u0300-\u036f\u0387\u0483-\u0487\
|
|
|
17819
17858
|
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";
|
|
17820
17859
|
|
|
17821
17860
|
// These are a run-length and offset encoded representation of the
|
|
17861
|
+
// >0xffff code points that are a valid part of identifiers. The
|
|
17862
|
+
// offset starts at 0x10000, and each pair of numbers represents an
|
|
17863
|
+
// offset to the next range, and then a size of the range.
|
|
17822
17864
|
|
|
17823
17865
|
// Reserved word lists for various dialects of the language
|
|
17824
17866
|
|
|
@@ -18937,6 +18979,16 @@ pp$8.parseThrowStatement = function(node) {
|
|
|
18937
18979
|
|
|
18938
18980
|
var empty$1 = [];
|
|
18939
18981
|
|
|
18982
|
+
pp$8.parseCatchClauseParam = function() {
|
|
18983
|
+
var param = this.parseBindingAtom();
|
|
18984
|
+
var simple = param.type === "Identifier";
|
|
18985
|
+
this.enterScope(simple ? SCOPE_SIMPLE_CATCH : 0);
|
|
18986
|
+
this.checkLValPattern(param, simple ? BIND_SIMPLE_CATCH : BIND_LEXICAL);
|
|
18987
|
+
this.expect(types$1.parenR);
|
|
18988
|
+
|
|
18989
|
+
return param
|
|
18990
|
+
};
|
|
18991
|
+
|
|
18940
18992
|
pp$8.parseTryStatement = function(node) {
|
|
18941
18993
|
this.next();
|
|
18942
18994
|
node.block = this.parseBlock();
|
|
@@ -18945,11 +18997,7 @@ pp$8.parseTryStatement = function(node) {
|
|
|
18945
18997
|
var clause = this.startNode();
|
|
18946
18998
|
this.next();
|
|
18947
18999
|
if (this.eat(types$1.parenL)) {
|
|
18948
|
-
clause.param = this.
|
|
18949
|
-
var simple = clause.param.type === "Identifier";
|
|
18950
|
-
this.enterScope(simple ? SCOPE_SIMPLE_CATCH : 0);
|
|
18951
|
-
this.checkLValPattern(clause.param, simple ? BIND_SIMPLE_CATCH : BIND_LEXICAL);
|
|
18952
|
-
this.expect(types$1.parenR);
|
|
19000
|
+
clause.param = this.parseCatchClauseParam();
|
|
18953
19001
|
} else {
|
|
18954
19002
|
if (this.options.ecmaVersion < 10) { this.unexpected(); }
|
|
18955
19003
|
clause.param = null;
|
|
@@ -18965,9 +19013,9 @@ pp$8.parseTryStatement = function(node) {
|
|
|
18965
19013
|
return this.finishNode(node, "TryStatement")
|
|
18966
19014
|
};
|
|
18967
19015
|
|
|
18968
|
-
pp$8.parseVarStatement = function(node, kind) {
|
|
19016
|
+
pp$8.parseVarStatement = function(node, kind, allowMissingInitializer) {
|
|
18969
19017
|
this.next();
|
|
18970
|
-
this.parseVar(node, false, kind);
|
|
19018
|
+
this.parseVar(node, false, kind, allowMissingInitializer);
|
|
18971
19019
|
this.semicolon();
|
|
18972
19020
|
return this.finishNode(node, "VariableDeclaration")
|
|
18973
19021
|
};
|
|
@@ -19096,7 +19144,7 @@ pp$8.parseForIn = function(node, init) {
|
|
|
19096
19144
|
|
|
19097
19145
|
// Parse a list of variable declarations.
|
|
19098
19146
|
|
|
19099
|
-
pp$8.parseVar = function(node, isFor, kind) {
|
|
19147
|
+
pp$8.parseVar = function(node, isFor, kind, allowMissingInitializer) {
|
|
19100
19148
|
node.declarations = [];
|
|
19101
19149
|
node.kind = kind;
|
|
19102
19150
|
for (;;) {
|
|
@@ -19104,9 +19152,9 @@ pp$8.parseVar = function(node, isFor, kind) {
|
|
|
19104
19152
|
this.parseVarId(decl, kind);
|
|
19105
19153
|
if (this.eat(types$1.eq)) {
|
|
19106
19154
|
decl.init = this.parseMaybeAssign(isFor);
|
|
19107
|
-
} else if (kind === "const" && !(this.type === types$1._in || (this.options.ecmaVersion >= 6 && this.isContextual("of")))) {
|
|
19155
|
+
} else if (!allowMissingInitializer && kind === "const" && !(this.type === types$1._in || (this.options.ecmaVersion >= 6 && this.isContextual("of")))) {
|
|
19108
19156
|
this.unexpected();
|
|
19109
|
-
} else if (decl.id.type !== "Identifier" && !(isFor && (this.type === types$1._in || this.isContextual("of")))) {
|
|
19157
|
+
} else if (!allowMissingInitializer && decl.id.type !== "Identifier" && !(isFor && (this.type === types$1._in || this.isContextual("of")))) {
|
|
19110
19158
|
this.raise(this.lastTokEnd, "Complex binding patterns require an initialization value");
|
|
19111
19159
|
} else {
|
|
19112
19160
|
decl.init = null;
|
|
@@ -19195,7 +19243,7 @@ pp$8.parseClass = function(node, isStatement) {
|
|
|
19195
19243
|
if (element) {
|
|
19196
19244
|
classBody.body.push(element);
|
|
19197
19245
|
if (element.type === "MethodDefinition" && element.kind === "constructor") {
|
|
19198
|
-
if (hadConstructor) { this.
|
|
19246
|
+
if (hadConstructor) { this.raiseRecoverable(element.start, "Duplicate constructor in the same class"); }
|
|
19199
19247
|
hadConstructor = true;
|
|
19200
19248
|
} else if (element.key && element.key.type === "PrivateIdentifier" && isPrivateNameConflicted(privateNameMap, element)) {
|
|
19201
19249
|
this.raiseRecoverable(element.key.start, ("Identifier '#" + (element.key.name) + "' has already been declared"));
|
|
@@ -19444,44 +19492,36 @@ function checkKeyName(node, name) {
|
|
|
19444
19492
|
|
|
19445
19493
|
// Parses module export declaration.
|
|
19446
19494
|
|
|
19495
|
+
pp$8.parseExportAllDeclaration = function(node, exports) {
|
|
19496
|
+
if (this.options.ecmaVersion >= 11) {
|
|
19497
|
+
if (this.eatContextual("as")) {
|
|
19498
|
+
node.exported = this.parseModuleExportName();
|
|
19499
|
+
this.checkExport(exports, node.exported, this.lastTokStart);
|
|
19500
|
+
} else {
|
|
19501
|
+
node.exported = null;
|
|
19502
|
+
}
|
|
19503
|
+
}
|
|
19504
|
+
this.expectContextual("from");
|
|
19505
|
+
if (this.type !== types$1.string) { this.unexpected(); }
|
|
19506
|
+
node.source = this.parseExprAtom();
|
|
19507
|
+
this.semicolon();
|
|
19508
|
+
return this.finishNode(node, "ExportAllDeclaration")
|
|
19509
|
+
};
|
|
19510
|
+
|
|
19447
19511
|
pp$8.parseExport = function(node, exports) {
|
|
19448
19512
|
this.next();
|
|
19449
19513
|
// export * from '...'
|
|
19450
19514
|
if (this.eat(types$1.star)) {
|
|
19451
|
-
|
|
19452
|
-
if (this.eatContextual("as")) {
|
|
19453
|
-
node.exported = this.parseModuleExportName();
|
|
19454
|
-
this.checkExport(exports, node.exported, this.lastTokStart);
|
|
19455
|
-
} else {
|
|
19456
|
-
node.exported = null;
|
|
19457
|
-
}
|
|
19458
|
-
}
|
|
19459
|
-
this.expectContextual("from");
|
|
19460
|
-
if (this.type !== types$1.string) { this.unexpected(); }
|
|
19461
|
-
node.source = this.parseExprAtom();
|
|
19462
|
-
this.semicolon();
|
|
19463
|
-
return this.finishNode(node, "ExportAllDeclaration")
|
|
19515
|
+
return this.parseExportAllDeclaration(node, exports)
|
|
19464
19516
|
}
|
|
19465
19517
|
if (this.eat(types$1._default)) { // export default ...
|
|
19466
19518
|
this.checkExport(exports, "default", this.lastTokStart);
|
|
19467
|
-
|
|
19468
|
-
if (this.type === types$1._function || (isAsync = this.isAsyncFunction())) {
|
|
19469
|
-
var fNode = this.startNode();
|
|
19470
|
-
this.next();
|
|
19471
|
-
if (isAsync) { this.next(); }
|
|
19472
|
-
node.declaration = this.parseFunction(fNode, FUNC_STATEMENT$1 | FUNC_NULLABLE_ID$1, false, isAsync);
|
|
19473
|
-
} else if (this.type === types$1._class) {
|
|
19474
|
-
var cNode = this.startNode();
|
|
19475
|
-
node.declaration = this.parseClass(cNode, "nullableID");
|
|
19476
|
-
} else {
|
|
19477
|
-
node.declaration = this.parseMaybeAssign();
|
|
19478
|
-
this.semicolon();
|
|
19479
|
-
}
|
|
19519
|
+
node.declaration = this.parseExportDefaultDeclaration();
|
|
19480
19520
|
return this.finishNode(node, "ExportDefaultDeclaration")
|
|
19481
19521
|
}
|
|
19482
19522
|
// export var|const|let|function|class ...
|
|
19483
19523
|
if (this.shouldParseExportStatement()) {
|
|
19484
|
-
node.declaration = this.
|
|
19524
|
+
node.declaration = this.parseExportDeclaration(node);
|
|
19485
19525
|
if (node.declaration.type === "VariableDeclaration")
|
|
19486
19526
|
{ this.checkVariableExport(exports, node.declaration.declarations); }
|
|
19487
19527
|
else
|
|
@@ -19515,6 +19555,27 @@ pp$8.parseExport = function(node, exports) {
|
|
|
19515
19555
|
return this.finishNode(node, "ExportNamedDeclaration")
|
|
19516
19556
|
};
|
|
19517
19557
|
|
|
19558
|
+
pp$8.parseExportDeclaration = function(node) {
|
|
19559
|
+
return this.parseStatement(null)
|
|
19560
|
+
};
|
|
19561
|
+
|
|
19562
|
+
pp$8.parseExportDefaultDeclaration = function() {
|
|
19563
|
+
var isAsync;
|
|
19564
|
+
if (this.type === types$1._function || (isAsync = this.isAsyncFunction())) {
|
|
19565
|
+
var fNode = this.startNode();
|
|
19566
|
+
this.next();
|
|
19567
|
+
if (isAsync) { this.next(); }
|
|
19568
|
+
return this.parseFunction(fNode, FUNC_STATEMENT$1 | FUNC_NULLABLE_ID$1, false, isAsync)
|
|
19569
|
+
} else if (this.type === types$1._class) {
|
|
19570
|
+
var cNode = this.startNode();
|
|
19571
|
+
return this.parseClass(cNode, "nullableID")
|
|
19572
|
+
} else {
|
|
19573
|
+
var declaration = this.parseMaybeAssign();
|
|
19574
|
+
this.semicolon();
|
|
19575
|
+
return declaration
|
|
19576
|
+
}
|
|
19577
|
+
};
|
|
19578
|
+
|
|
19518
19579
|
pp$8.checkExport = function(exports, name, pos) {
|
|
19519
19580
|
if (!exports) { return }
|
|
19520
19581
|
if (typeof name !== "string")
|
|
@@ -19572,6 +19633,20 @@ pp$8.shouldParseExportStatement = function() {
|
|
|
19572
19633
|
|
|
19573
19634
|
// Parses a comma-separated list of module exports.
|
|
19574
19635
|
|
|
19636
|
+
pp$8.parseExportSpecifier = function(exports) {
|
|
19637
|
+
var node = this.startNode();
|
|
19638
|
+
node.local = this.parseModuleExportName();
|
|
19639
|
+
|
|
19640
|
+
node.exported = this.eatContextual("as") ? this.parseModuleExportName() : node.local;
|
|
19641
|
+
this.checkExport(
|
|
19642
|
+
exports,
|
|
19643
|
+
node.exported,
|
|
19644
|
+
node.exported.start
|
|
19645
|
+
);
|
|
19646
|
+
|
|
19647
|
+
return this.finishNode(node, "ExportSpecifier")
|
|
19648
|
+
};
|
|
19649
|
+
|
|
19575
19650
|
pp$8.parseExportSpecifiers = function(exports) {
|
|
19576
19651
|
var nodes = [], first = true;
|
|
19577
19652
|
// export { x, y as z } [from '...']
|
|
@@ -19582,15 +19657,7 @@ pp$8.parseExportSpecifiers = function(exports) {
|
|
|
19582
19657
|
if (this.afterTrailingComma(types$1.braceR)) { break }
|
|
19583
19658
|
} else { first = false; }
|
|
19584
19659
|
|
|
19585
|
-
|
|
19586
|
-
node.local = this.parseModuleExportName();
|
|
19587
|
-
node.exported = this.eatContextual("as") ? this.parseModuleExportName() : node.local;
|
|
19588
|
-
this.checkExport(
|
|
19589
|
-
exports,
|
|
19590
|
-
node.exported,
|
|
19591
|
-
node.exported.start
|
|
19592
|
-
);
|
|
19593
|
-
nodes.push(this.finishNode(node, "ExportSpecifier"));
|
|
19660
|
+
nodes.push(this.parseExportSpecifier(exports));
|
|
19594
19661
|
}
|
|
19595
19662
|
return nodes
|
|
19596
19663
|
};
|
|
@@ -19599,6 +19666,7 @@ pp$8.parseExportSpecifiers = function(exports) {
|
|
|
19599
19666
|
|
|
19600
19667
|
pp$8.parseImport = function(node) {
|
|
19601
19668
|
this.next();
|
|
19669
|
+
|
|
19602
19670
|
// import '...'
|
|
19603
19671
|
if (this.type === types$1.string) {
|
|
19604
19672
|
node.specifiers = empty$1;
|
|
@@ -19614,23 +19682,46 @@ pp$8.parseImport = function(node) {
|
|
|
19614
19682
|
|
|
19615
19683
|
// Parses a comma-separated list of module imports.
|
|
19616
19684
|
|
|
19685
|
+
pp$8.parseImportSpecifier = function() {
|
|
19686
|
+
var node = this.startNode();
|
|
19687
|
+
node.imported = this.parseModuleExportName();
|
|
19688
|
+
|
|
19689
|
+
if (this.eatContextual("as")) {
|
|
19690
|
+
node.local = this.parseIdent();
|
|
19691
|
+
} else {
|
|
19692
|
+
this.checkUnreserved(node.imported);
|
|
19693
|
+
node.local = node.imported;
|
|
19694
|
+
}
|
|
19695
|
+
this.checkLValSimple(node.local, BIND_LEXICAL);
|
|
19696
|
+
|
|
19697
|
+
return this.finishNode(node, "ImportSpecifier")
|
|
19698
|
+
};
|
|
19699
|
+
|
|
19700
|
+
pp$8.parseImportDefaultSpecifier = function() {
|
|
19701
|
+
// import defaultObj, { x, y as z } from '...'
|
|
19702
|
+
var node = this.startNode();
|
|
19703
|
+
node.local = this.parseIdent();
|
|
19704
|
+
this.checkLValSimple(node.local, BIND_LEXICAL);
|
|
19705
|
+
return this.finishNode(node, "ImportDefaultSpecifier")
|
|
19706
|
+
};
|
|
19707
|
+
|
|
19708
|
+
pp$8.parseImportNamespaceSpecifier = function() {
|
|
19709
|
+
var node = this.startNode();
|
|
19710
|
+
this.next();
|
|
19711
|
+
this.expectContextual("as");
|
|
19712
|
+
node.local = this.parseIdent();
|
|
19713
|
+
this.checkLValSimple(node.local, BIND_LEXICAL);
|
|
19714
|
+
return this.finishNode(node, "ImportNamespaceSpecifier")
|
|
19715
|
+
};
|
|
19716
|
+
|
|
19617
19717
|
pp$8.parseImportSpecifiers = function() {
|
|
19618
19718
|
var nodes = [], first = true;
|
|
19619
19719
|
if (this.type === types$1.name) {
|
|
19620
|
-
|
|
19621
|
-
var node = this.startNode();
|
|
19622
|
-
node.local = this.parseIdent();
|
|
19623
|
-
this.checkLValSimple(node.local, BIND_LEXICAL);
|
|
19624
|
-
nodes.push(this.finishNode(node, "ImportDefaultSpecifier"));
|
|
19720
|
+
nodes.push(this.parseImportDefaultSpecifier());
|
|
19625
19721
|
if (!this.eat(types$1.comma)) { return nodes }
|
|
19626
19722
|
}
|
|
19627
19723
|
if (this.type === types$1.star) {
|
|
19628
|
-
|
|
19629
|
-
this.next();
|
|
19630
|
-
this.expectContextual("as");
|
|
19631
|
-
node$1.local = this.parseIdent();
|
|
19632
|
-
this.checkLValSimple(node$1.local, BIND_LEXICAL);
|
|
19633
|
-
nodes.push(this.finishNode(node$1, "ImportNamespaceSpecifier"));
|
|
19724
|
+
nodes.push(this.parseImportNamespaceSpecifier());
|
|
19634
19725
|
return nodes
|
|
19635
19726
|
}
|
|
19636
19727
|
this.expect(types$1.braceL);
|
|
@@ -19640,16 +19731,7 @@ pp$8.parseImportSpecifiers = function() {
|
|
|
19640
19731
|
if (this.afterTrailingComma(types$1.braceR)) { break }
|
|
19641
19732
|
} else { first = false; }
|
|
19642
19733
|
|
|
19643
|
-
|
|
19644
|
-
node$2.imported = this.parseModuleExportName();
|
|
19645
|
-
if (this.eatContextual("as")) {
|
|
19646
|
-
node$2.local = this.parseIdent();
|
|
19647
|
-
} else {
|
|
19648
|
-
this.checkUnreserved(node$2.imported);
|
|
19649
|
-
node$2.local = node$2.imported;
|
|
19650
|
-
}
|
|
19651
|
-
this.checkLValSimple(node$2.local, BIND_LEXICAL);
|
|
19652
|
-
nodes.push(this.finishNode(node$2, "ImportSpecifier"));
|
|
19734
|
+
nodes.push(this.parseImportSpecifier());
|
|
19653
19735
|
}
|
|
19654
19736
|
return nodes
|
|
19655
19737
|
};
|
|
@@ -19822,7 +19904,7 @@ pp$7.parseBindingAtom = function() {
|
|
|
19822
19904
|
return this.parseIdent()
|
|
19823
19905
|
};
|
|
19824
19906
|
|
|
19825
|
-
pp$7.parseBindingList = function(close, allowEmpty, allowTrailingComma) {
|
|
19907
|
+
pp$7.parseBindingList = function(close, allowEmpty, allowTrailingComma, allowModifiers) {
|
|
19826
19908
|
var elts = [], first = true;
|
|
19827
19909
|
while (!this.eat(close)) {
|
|
19828
19910
|
if (first) { first = false; }
|
|
@@ -19835,18 +19917,22 @@ pp$7.parseBindingList = function(close, allowEmpty, allowTrailingComma) {
|
|
|
19835
19917
|
var rest = this.parseRestBinding();
|
|
19836
19918
|
this.parseBindingListItem(rest);
|
|
19837
19919
|
elts.push(rest);
|
|
19838
|
-
if (this.type === types$1.comma) { this.
|
|
19920
|
+
if (this.type === types$1.comma) { this.raiseRecoverable(this.start, "Comma is not permitted after the rest element"); }
|
|
19839
19921
|
this.expect(close);
|
|
19840
19922
|
break
|
|
19841
19923
|
} else {
|
|
19842
|
-
|
|
19843
|
-
this.parseBindingListItem(elem);
|
|
19844
|
-
elts.push(elem);
|
|
19924
|
+
elts.push(this.parseAssignableListItem(allowModifiers));
|
|
19845
19925
|
}
|
|
19846
19926
|
}
|
|
19847
19927
|
return elts
|
|
19848
19928
|
};
|
|
19849
19929
|
|
|
19930
|
+
pp$7.parseAssignableListItem = function(allowModifiers) {
|
|
19931
|
+
var elem = this.parseMaybeDefault(this.start, this.startLoc);
|
|
19932
|
+
this.parseBindingListItem(elem);
|
|
19933
|
+
return elem
|
|
19934
|
+
};
|
|
19935
|
+
|
|
19850
19936
|
pp$7.parseBindingListItem = function(param) {
|
|
19851
19937
|
return param
|
|
19852
19938
|
};
|
|
@@ -20012,6 +20098,9 @@ pp$7.checkLValInnerPattern = function(expr, bindingType, checkClashes) {
|
|
|
20012
20098
|
};
|
|
20013
20099
|
|
|
20014
20100
|
// The algorithm used to determine whether a regexp can appear at a
|
|
20101
|
+
// given point in the program is loosely based on sweet.js' approach.
|
|
20102
|
+
// See https://github.com/mozilla/sweet.js/wiki/design
|
|
20103
|
+
|
|
20015
20104
|
|
|
20016
20105
|
var TokContext = function TokContext(token, isExpr, preserveSpace, override, generator) {
|
|
20017
20106
|
this.token = token;
|
|
@@ -20167,6 +20256,23 @@ types$1.name.updateContext = function(prevType) {
|
|
|
20167
20256
|
};
|
|
20168
20257
|
|
|
20169
20258
|
// A recursive descent parser operates by defining functions for all
|
|
20259
|
+
// syntactic elements, and recursively calling those, each function
|
|
20260
|
+
// advancing the input stream and returning an AST node. Precedence
|
|
20261
|
+
// of constructs (for example, the fact that `!x[1]` means `!(x[1])`
|
|
20262
|
+
// instead of `(!x)[1]` is handled by the fact that the parser
|
|
20263
|
+
// function that parses unary prefix operators is called first, and
|
|
20264
|
+
// in turn calls the function that parses `[]` subscripts — that
|
|
20265
|
+
// way, it'll receive the node for `x[1]` already parsed, and wraps
|
|
20266
|
+
// *that* in the unary operator node.
|
|
20267
|
+
//
|
|
20268
|
+
// Acorn uses an [operator precedence parser][opp] to handle binary
|
|
20269
|
+
// operator precedence, because it is much more compact than using
|
|
20270
|
+
// the technique outlined above, which uses different, nesting
|
|
20271
|
+
// functions to specify precedence, for all of the ten binary
|
|
20272
|
+
// precedence levels that JavaScript defines.
|
|
20273
|
+
//
|
|
20274
|
+
// [opp]: http://en.wikipedia.org/wiki/Operator-precedence_parser
|
|
20275
|
+
|
|
20170
20276
|
|
|
20171
20277
|
var pp$5 = Parser.prototype;
|
|
20172
20278
|
|
|
@@ -20470,6 +20576,14 @@ pp$5.parseSubscripts = function(base, startPos, startLoc, noCalls, forInit) {
|
|
|
20470
20576
|
}
|
|
20471
20577
|
};
|
|
20472
20578
|
|
|
20579
|
+
pp$5.shouldParseAsyncArrow = function() {
|
|
20580
|
+
return !this.canInsertSemicolon() && this.eat(types$1.arrow)
|
|
20581
|
+
};
|
|
20582
|
+
|
|
20583
|
+
pp$5.parseSubscriptAsyncArrow = function(startPos, startLoc, exprList, forInit) {
|
|
20584
|
+
return this.parseArrowExpression(this.startNodeAt(startPos, startLoc), exprList, true, forInit)
|
|
20585
|
+
};
|
|
20586
|
+
|
|
20473
20587
|
pp$5.parseSubscript = function(base, startPos, startLoc, noCalls, maybeAsyncArrow, optionalChained, forInit) {
|
|
20474
20588
|
var optionalSupported = this.options.ecmaVersion >= 11;
|
|
20475
20589
|
var optional = optionalSupported && this.eat(types$1.questionDot);
|
|
@@ -20498,7 +20612,7 @@ pp$5.parseSubscript = function(base, startPos, startLoc, noCalls, maybeAsyncArro
|
|
|
20498
20612
|
this.awaitPos = 0;
|
|
20499
20613
|
this.awaitIdentPos = 0;
|
|
20500
20614
|
var exprList = this.parseExprList(types$1.parenR, this.options.ecmaVersion >= 8, false, refDestructuringErrors);
|
|
20501
|
-
if (maybeAsyncArrow && !optional &&
|
|
20615
|
+
if (maybeAsyncArrow && !optional && this.shouldParseAsyncArrow()) {
|
|
20502
20616
|
this.checkPatternErrors(refDestructuringErrors, false);
|
|
20503
20617
|
this.checkYieldAwaitInDefaultParams();
|
|
20504
20618
|
if (this.awaitIdentPos > 0)
|
|
@@ -20506,7 +20620,7 @@ pp$5.parseSubscript = function(base, startPos, startLoc, noCalls, maybeAsyncArro
|
|
|
20506
20620
|
this.yieldPos = oldYieldPos;
|
|
20507
20621
|
this.awaitPos = oldAwaitPos;
|
|
20508
20622
|
this.awaitIdentPos = oldAwaitIdentPos;
|
|
20509
|
-
return this.
|
|
20623
|
+
return this.parseSubscriptAsyncArrow(startPos, startLoc, exprList, forInit)
|
|
20510
20624
|
}
|
|
20511
20625
|
this.checkExpressionErrors(refDestructuringErrors, true);
|
|
20512
20626
|
this.yieldPos = oldYieldPos || this.yieldPos;
|
|
@@ -20536,7 +20650,7 @@ pp$5.parseSubscript = function(base, startPos, startLoc, noCalls, maybeAsyncArro
|
|
|
20536
20650
|
// `new`, or an expression wrapped in punctuation like `()`, `[]`,
|
|
20537
20651
|
// or `{}`.
|
|
20538
20652
|
|
|
20539
|
-
pp$5.parseExprAtom = function(refDestructuringErrors, forInit) {
|
|
20653
|
+
pp$5.parseExprAtom = function(refDestructuringErrors, forInit, forNew) {
|
|
20540
20654
|
// If a division operator appears in an expression position, the
|
|
20541
20655
|
// tokenizer got confused, and we force it to read a regexp instead.
|
|
20542
20656
|
if (this.type === types$1.slash) { this.readRegexp(); }
|
|
@@ -20637,17 +20751,21 @@ pp$5.parseExprAtom = function(refDestructuringErrors, forInit) {
|
|
|
20637
20751
|
|
|
20638
20752
|
case types$1._import:
|
|
20639
20753
|
if (this.options.ecmaVersion >= 11) {
|
|
20640
|
-
return this.parseExprImport()
|
|
20754
|
+
return this.parseExprImport(forNew)
|
|
20641
20755
|
} else {
|
|
20642
20756
|
return this.unexpected()
|
|
20643
20757
|
}
|
|
20644
20758
|
|
|
20645
20759
|
default:
|
|
20646
|
-
this.
|
|
20760
|
+
return this.parseExprAtomDefault()
|
|
20647
20761
|
}
|
|
20648
20762
|
};
|
|
20649
20763
|
|
|
20650
|
-
pp$5.
|
|
20764
|
+
pp$5.parseExprAtomDefault = function() {
|
|
20765
|
+
this.unexpected();
|
|
20766
|
+
};
|
|
20767
|
+
|
|
20768
|
+
pp$5.parseExprImport = function(forNew) {
|
|
20651
20769
|
var node = this.startNode();
|
|
20652
20770
|
|
|
20653
20771
|
// Consume `import` as an identifier for `import.meta`.
|
|
@@ -20655,13 +20773,12 @@ pp$5.parseExprImport = function() {
|
|
|
20655
20773
|
if (this.containsEsc) { this.raiseRecoverable(this.start, "Escape sequence in keyword import"); }
|
|
20656
20774
|
var meta = this.parseIdent(true);
|
|
20657
20775
|
|
|
20658
|
-
|
|
20659
|
-
case types$1.parenL:
|
|
20776
|
+
if (this.type === types$1.parenL && !forNew) {
|
|
20660
20777
|
return this.parseDynamicImport(node)
|
|
20661
|
-
|
|
20778
|
+
} else if (this.type === types$1.dot) {
|
|
20662
20779
|
node.meta = meta;
|
|
20663
20780
|
return this.parseImportMeta(node)
|
|
20664
|
-
|
|
20781
|
+
} else {
|
|
20665
20782
|
this.unexpected();
|
|
20666
20783
|
}
|
|
20667
20784
|
};
|
|
@@ -20717,6 +20834,10 @@ pp$5.parseParenExpression = function() {
|
|
|
20717
20834
|
return val
|
|
20718
20835
|
};
|
|
20719
20836
|
|
|
20837
|
+
pp$5.shouldParseArrow = function(exprList) {
|
|
20838
|
+
return !this.canInsertSemicolon()
|
|
20839
|
+
};
|
|
20840
|
+
|
|
20720
20841
|
pp$5.parseParenAndDistinguishExpression = function(canBeArrow, forInit) {
|
|
20721
20842
|
var startPos = this.start, startLoc = this.startLoc, val, allowTrailingComma = this.options.ecmaVersion >= 8;
|
|
20722
20843
|
if (this.options.ecmaVersion >= 6) {
|
|
@@ -20736,7 +20857,12 @@ pp$5.parseParenAndDistinguishExpression = function(canBeArrow, forInit) {
|
|
|
20736
20857
|
} else if (this.type === types$1.ellipsis) {
|
|
20737
20858
|
spreadStart = this.start;
|
|
20738
20859
|
exprList.push(this.parseParenItem(this.parseRestBinding()));
|
|
20739
|
-
if (this.type === types$1.comma) {
|
|
20860
|
+
if (this.type === types$1.comma) {
|
|
20861
|
+
this.raiseRecoverable(
|
|
20862
|
+
this.start,
|
|
20863
|
+
"Comma is not permitted after the rest element"
|
|
20864
|
+
);
|
|
20865
|
+
}
|
|
20740
20866
|
break
|
|
20741
20867
|
} else {
|
|
20742
20868
|
exprList.push(this.parseMaybeAssign(false, refDestructuringErrors, this.parseParenItem));
|
|
@@ -20745,7 +20871,7 @@ pp$5.parseParenAndDistinguishExpression = function(canBeArrow, forInit) {
|
|
|
20745
20871
|
var innerEndPos = this.lastTokEnd, innerEndLoc = this.lastTokEndLoc;
|
|
20746
20872
|
this.expect(types$1.parenR);
|
|
20747
20873
|
|
|
20748
|
-
if (canBeArrow &&
|
|
20874
|
+
if (canBeArrow && this.shouldParseArrow(exprList) && this.eat(types$1.arrow)) {
|
|
20749
20875
|
this.checkPatternErrors(refDestructuringErrors, false);
|
|
20750
20876
|
this.checkYieldAwaitInDefaultParams();
|
|
20751
20877
|
this.yieldPos = oldYieldPos;
|
|
@@ -20811,11 +20937,8 @@ pp$5.parseNew = function() {
|
|
|
20811
20937
|
{ this.raiseRecoverable(node.start, "'new.target' can only be used in functions and class static block"); }
|
|
20812
20938
|
return this.finishNode(node, "MetaProperty")
|
|
20813
20939
|
}
|
|
20814
|
-
var startPos = this.start, startLoc = this.startLoc
|
|
20815
|
-
node.callee = this.parseSubscripts(this.parseExprAtom(), startPos, startLoc, true, false);
|
|
20816
|
-
if (isImport && node.callee.type === "ImportExpression") {
|
|
20817
|
-
this.raise(startPos, "Cannot use new with import()");
|
|
20818
|
-
}
|
|
20940
|
+
var startPos = this.start, startLoc = this.startLoc;
|
|
20941
|
+
node.callee = this.parseSubscripts(this.parseExprAtom(null, false, true), startPos, startLoc, true, false);
|
|
20819
20942
|
if (this.eat(types$1.parenL)) { node.arguments = this.parseExprList(types$1.parenR, this.options.ecmaVersion >= 8, false); }
|
|
20820
20943
|
else { node.arguments = empty; }
|
|
20821
20944
|
return this.finishNode(node, "NewExpression")
|
|
@@ -20897,7 +21020,7 @@ pp$5.parseProperty = function(isPattern, refDestructuringErrors) {
|
|
|
20897
21020
|
if (isPattern) {
|
|
20898
21021
|
prop.argument = this.parseIdent(false);
|
|
20899
21022
|
if (this.type === types$1.comma) {
|
|
20900
|
-
this.
|
|
21023
|
+
this.raiseRecoverable(this.start, "Comma is not permitted after the rest element");
|
|
20901
21024
|
}
|
|
20902
21025
|
return this.finishNode(prop, "RestElement")
|
|
20903
21026
|
}
|
|
@@ -20933,6 +21056,23 @@ pp$5.parseProperty = function(isPattern, refDestructuringErrors) {
|
|
|
20933
21056
|
return this.finishNode(prop, "Property")
|
|
20934
21057
|
};
|
|
20935
21058
|
|
|
21059
|
+
pp$5.parseGetterSetter = function(prop) {
|
|
21060
|
+
prop.kind = prop.key.name;
|
|
21061
|
+
this.parsePropertyName(prop);
|
|
21062
|
+
prop.value = this.parseMethod(false);
|
|
21063
|
+
var paramCount = prop.kind === "get" ? 0 : 1;
|
|
21064
|
+
if (prop.value.params.length !== paramCount) {
|
|
21065
|
+
var start = prop.value.start;
|
|
21066
|
+
if (prop.kind === "get")
|
|
21067
|
+
{ this.raiseRecoverable(start, "getter should have no params"); }
|
|
21068
|
+
else
|
|
21069
|
+
{ this.raiseRecoverable(start, "setter should have exactly one param"); }
|
|
21070
|
+
} else {
|
|
21071
|
+
if (prop.kind === "set" && prop.value.params[0].type === "RestElement")
|
|
21072
|
+
{ this.raiseRecoverable(prop.value.params[0].start, "Setter cannot use rest params"); }
|
|
21073
|
+
}
|
|
21074
|
+
};
|
|
21075
|
+
|
|
20936
21076
|
pp$5.parsePropertyValue = function(prop, isPattern, isGenerator, isAsync, startPos, startLoc, refDestructuringErrors, containsEsc) {
|
|
20937
21077
|
if ((isGenerator || isAsync) && this.type === types$1.colon)
|
|
20938
21078
|
{ this.unexpected(); }
|
|
@@ -20950,20 +21090,7 @@ pp$5.parsePropertyValue = function(prop, isPattern, isGenerator, isAsync, startP
|
|
|
20950
21090
|
(prop.key.name === "get" || prop.key.name === "set") &&
|
|
20951
21091
|
(this.type !== types$1.comma && this.type !== types$1.braceR && this.type !== types$1.eq)) {
|
|
20952
21092
|
if (isGenerator || isAsync) { this.unexpected(); }
|
|
20953
|
-
|
|
20954
|
-
this.parsePropertyName(prop);
|
|
20955
|
-
prop.value = this.parseMethod(false);
|
|
20956
|
-
var paramCount = prop.kind === "get" ? 0 : 1;
|
|
20957
|
-
if (prop.value.params.length !== paramCount) {
|
|
20958
|
-
var start = prop.value.start;
|
|
20959
|
-
if (prop.kind === "get")
|
|
20960
|
-
{ this.raiseRecoverable(start, "getter should have no params"); }
|
|
20961
|
-
else
|
|
20962
|
-
{ this.raiseRecoverable(start, "setter should have exactly one param"); }
|
|
20963
|
-
} else {
|
|
20964
|
-
if (prop.kind === "set" && prop.value.params[0].type === "RestElement")
|
|
20965
|
-
{ this.raiseRecoverable(prop.value.params[0].start, "Setter cannot use rest params"); }
|
|
20966
|
-
}
|
|
21093
|
+
this.parseGetterSetter(prop);
|
|
20967
21094
|
} else if (this.options.ecmaVersion >= 6 && !prop.computed && prop.key.type === "Identifier") {
|
|
20968
21095
|
if (isGenerator || isAsync) { this.unexpected(); }
|
|
20969
21096
|
this.checkUnreserved(prop.key);
|
|
@@ -21175,6 +21302,18 @@ pp$5.checkUnreserved = function(ref) {
|
|
|
21175
21302
|
// identifiers.
|
|
21176
21303
|
|
|
21177
21304
|
pp$5.parseIdent = function(liberal) {
|
|
21305
|
+
var node = this.parseIdentNode();
|
|
21306
|
+
this.next(!!liberal);
|
|
21307
|
+
this.finishNode(node, "Identifier");
|
|
21308
|
+
if (!liberal) {
|
|
21309
|
+
this.checkUnreserved(node);
|
|
21310
|
+
if (node.name === "await" && !this.awaitIdentPos)
|
|
21311
|
+
{ this.awaitIdentPos = node.start; }
|
|
21312
|
+
}
|
|
21313
|
+
return node
|
|
21314
|
+
};
|
|
21315
|
+
|
|
21316
|
+
pp$5.parseIdentNode = function() {
|
|
21178
21317
|
var node = this.startNode();
|
|
21179
21318
|
if (this.type === types$1.name) {
|
|
21180
21319
|
node.name = this.value;
|
|
@@ -21186,19 +21325,12 @@ pp$5.parseIdent = function(liberal) {
|
|
|
21186
21325
|
// But there is no chance to pop the context if the keyword is consumed as an identifier such as a property name.
|
|
21187
21326
|
// If the previous token is a dot, this does not apply because the context-managing code already ignored the keyword
|
|
21188
21327
|
if ((node.name === "class" || node.name === "function") &&
|
|
21189
|
-
|
|
21328
|
+
(this.lastTokEnd !== this.lastTokStart + 1 || this.input.charCodeAt(this.lastTokStart) !== 46)) {
|
|
21190
21329
|
this.context.pop();
|
|
21191
21330
|
}
|
|
21192
21331
|
} else {
|
|
21193
21332
|
this.unexpected();
|
|
21194
21333
|
}
|
|
21195
|
-
this.next(!!liberal);
|
|
21196
|
-
this.finishNode(node, "Identifier");
|
|
21197
|
-
if (!liberal) {
|
|
21198
|
-
this.checkUnreserved(node);
|
|
21199
|
-
if (node.name === "await" && !this.awaitIdentPos)
|
|
21200
|
-
{ this.awaitIdentPos = node.start; }
|
|
21201
|
-
}
|
|
21202
21334
|
return node
|
|
21203
21335
|
};
|
|
21204
21336
|
|
|
@@ -21438,6 +21570,18 @@ var unicodeBinaryProperties = {
|
|
|
21438
21570
|
14: ecma14BinaryProperties
|
|
21439
21571
|
};
|
|
21440
21572
|
|
|
21573
|
+
// #table-binary-unicode-properties-of-strings
|
|
21574
|
+
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";
|
|
21575
|
+
|
|
21576
|
+
var unicodeBinaryPropertiesOfStrings = {
|
|
21577
|
+
9: "",
|
|
21578
|
+
10: "",
|
|
21579
|
+
11: "",
|
|
21580
|
+
12: "",
|
|
21581
|
+
13: "",
|
|
21582
|
+
14: ecma14BinaryPropertiesOfStrings
|
|
21583
|
+
};
|
|
21584
|
+
|
|
21441
21585
|
// #table-unicode-general-category-values
|
|
21442
21586
|
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";
|
|
21443
21587
|
|
|
@@ -21447,7 +21591,7 @@ var ecma10ScriptValues = ecma9ScriptValues + " Dogra Dogr Gunjala_Gondi Gong Han
|
|
|
21447
21591
|
var ecma11ScriptValues = ecma10ScriptValues + " Elymaic Elym Nandinagari Nand Nyiakeng_Puachue_Hmong Hmnp Wancho Wcho";
|
|
21448
21592
|
var ecma12ScriptValues = ecma11ScriptValues + " Chorasmian Chrs Diak Dives_Akuru Khitan_Small_Script Kits Yezi Yezidi";
|
|
21449
21593
|
var ecma13ScriptValues = ecma12ScriptValues + " Cypro_Minoan Cpmn Old_Uyghur Ougr Tangsa Tnsa Toto Vithkuqi Vith";
|
|
21450
|
-
var ecma14ScriptValues = ecma13ScriptValues + " Kawi Nag_Mundari Nagm";
|
|
21594
|
+
var ecma14ScriptValues = ecma13ScriptValues + " Hrkt Katakana_Or_Hiragana Kawi Nag_Mundari Nagm Unknown Zzzz";
|
|
21451
21595
|
|
|
21452
21596
|
var unicodeScriptValues = {
|
|
21453
21597
|
9: ecma9ScriptValues,
|
|
@@ -21462,6 +21606,7 @@ var data = {};
|
|
|
21462
21606
|
function buildUnicodeData(ecmaVersion) {
|
|
21463
21607
|
var d = data[ecmaVersion] = {
|
|
21464
21608
|
binary: wordsRegexp(unicodeBinaryProperties[ecmaVersion] + " " + unicodeGeneralCategoryValues),
|
|
21609
|
+
binaryOfStrings: wordsRegexp(unicodeBinaryPropertiesOfStrings[ecmaVersion]),
|
|
21465
21610
|
nonBinary: {
|
|
21466
21611
|
General_Category: wordsRegexp(unicodeGeneralCategoryValues),
|
|
21467
21612
|
Script: wordsRegexp(unicodeScriptValues[ecmaVersion])
|
|
@@ -21484,12 +21629,13 @@ var pp$1 = Parser.prototype;
|
|
|
21484
21629
|
|
|
21485
21630
|
var RegExpValidationState = function RegExpValidationState(parser) {
|
|
21486
21631
|
this.parser = parser;
|
|
21487
|
-
this.validFlags = "gim" + (parser.options.ecmaVersion >= 6 ? "uy" : "") + (parser.options.ecmaVersion >= 9 ? "s" : "") + (parser.options.ecmaVersion >= 13 ? "d" : "");
|
|
21632
|
+
this.validFlags = "gim" + (parser.options.ecmaVersion >= 6 ? "uy" : "") + (parser.options.ecmaVersion >= 9 ? "s" : "") + (parser.options.ecmaVersion >= 13 ? "d" : "") + (parser.options.ecmaVersion >= 15 ? "v" : "");
|
|
21488
21633
|
this.unicodeProperties = data[parser.options.ecmaVersion >= 14 ? 14 : parser.options.ecmaVersion];
|
|
21489
21634
|
this.source = "";
|
|
21490
21635
|
this.flags = "";
|
|
21491
21636
|
this.start = 0;
|
|
21492
21637
|
this.switchU = false;
|
|
21638
|
+
this.switchV = false;
|
|
21493
21639
|
this.switchN = false;
|
|
21494
21640
|
this.pos = 0;
|
|
21495
21641
|
this.lastIntValue = 0;
|
|
@@ -21502,12 +21648,20 @@ var RegExpValidationState = function RegExpValidationState(parser) {
|
|
|
21502
21648
|
};
|
|
21503
21649
|
|
|
21504
21650
|
RegExpValidationState.prototype.reset = function reset (start, pattern, flags) {
|
|
21651
|
+
var unicodeSets = flags.indexOf("v") !== -1;
|
|
21505
21652
|
var unicode = flags.indexOf("u") !== -1;
|
|
21506
21653
|
this.start = start | 0;
|
|
21507
21654
|
this.source = pattern + "";
|
|
21508
21655
|
this.flags = flags;
|
|
21509
|
-
|
|
21510
|
-
|
|
21656
|
+
if (unicodeSets && this.parser.options.ecmaVersion >= 15) {
|
|
21657
|
+
this.switchU = true;
|
|
21658
|
+
this.switchV = true;
|
|
21659
|
+
this.switchN = true;
|
|
21660
|
+
} else {
|
|
21661
|
+
this.switchU = unicode && this.parser.options.ecmaVersion >= 6;
|
|
21662
|
+
this.switchV = false;
|
|
21663
|
+
this.switchN = unicode && this.parser.options.ecmaVersion >= 9;
|
|
21664
|
+
}
|
|
21511
21665
|
};
|
|
21512
21666
|
|
|
21513
21667
|
RegExpValidationState.prototype.raise = function raise (message) {
|
|
@@ -21576,6 +21730,23 @@ RegExpValidationState.prototype.eat = function eat (ch, forceU) {
|
|
|
21576
21730
|
return false
|
|
21577
21731
|
};
|
|
21578
21732
|
|
|
21733
|
+
RegExpValidationState.prototype.eatChars = function eatChars (chs, forceU) {
|
|
21734
|
+
if ( forceU === void 0 ) forceU = false;
|
|
21735
|
+
|
|
21736
|
+
var pos = this.pos;
|
|
21737
|
+
for (var i = 0, list = chs; i < list.length; i += 1) {
|
|
21738
|
+
var ch = list[i];
|
|
21739
|
+
|
|
21740
|
+
var current = this.at(pos, forceU);
|
|
21741
|
+
if (current === -1 || current !== ch) {
|
|
21742
|
+
return false
|
|
21743
|
+
}
|
|
21744
|
+
pos = this.nextIndex(pos, forceU);
|
|
21745
|
+
}
|
|
21746
|
+
this.pos = pos;
|
|
21747
|
+
return true
|
|
21748
|
+
};
|
|
21749
|
+
|
|
21579
21750
|
/**
|
|
21580
21751
|
* Validate the flags part of a given RegExpLiteral.
|
|
21581
21752
|
*
|
|
@@ -21586,6 +21757,9 @@ pp$1.validateRegExpFlags = function(state) {
|
|
|
21586
21757
|
var validFlags = state.validFlags;
|
|
21587
21758
|
var flags = state.flags;
|
|
21588
21759
|
|
|
21760
|
+
var u = false;
|
|
21761
|
+
var v = false;
|
|
21762
|
+
|
|
21589
21763
|
for (var i = 0; i < flags.length; i++) {
|
|
21590
21764
|
var flag = flags.charAt(i);
|
|
21591
21765
|
if (validFlags.indexOf(flag) === -1) {
|
|
@@ -21594,6 +21768,11 @@ pp$1.validateRegExpFlags = function(state) {
|
|
|
21594
21768
|
if (flags.indexOf(flag, i + 1) > -1) {
|
|
21595
21769
|
this.raise(state.start, "Duplicate regular expression flag");
|
|
21596
21770
|
}
|
|
21771
|
+
if (flag === "u") { u = true; }
|
|
21772
|
+
if (flag === "v") { v = true; }
|
|
21773
|
+
}
|
|
21774
|
+
if (this.options.ecmaVersion >= 15 && u && v) {
|
|
21775
|
+
this.raise(state.start, "Invalid regular expression flag");
|
|
21597
21776
|
}
|
|
21598
21777
|
};
|
|
21599
21778
|
|
|
@@ -22212,6 +22391,12 @@ pp$1.regexp_eatDecimalEscape = function(state) {
|
|
|
22212
22391
|
return false
|
|
22213
22392
|
};
|
|
22214
22393
|
|
|
22394
|
+
// Return values used by character set parsing methods, needed to
|
|
22395
|
+
// forbid negation of sets that can match strings.
|
|
22396
|
+
var CharSetNone = 0; // Nothing parsed
|
|
22397
|
+
var CharSetOk = 1; // Construct parsed, cannot contain strings
|
|
22398
|
+
var CharSetString = 2; // Construct parsed, can contain strings
|
|
22399
|
+
|
|
22215
22400
|
// https://www.ecma-international.org/ecma-262/8.0/#prod-CharacterClassEscape
|
|
22216
22401
|
pp$1.regexp_eatCharacterClassEscape = function(state) {
|
|
22217
22402
|
var ch = state.current();
|
|
@@ -22219,28 +22404,32 @@ pp$1.regexp_eatCharacterClassEscape = function(state) {
|
|
|
22219
22404
|
if (isCharacterClassEscape(ch)) {
|
|
22220
22405
|
state.lastIntValue = -1;
|
|
22221
22406
|
state.advance();
|
|
22222
|
-
return
|
|
22407
|
+
return CharSetOk
|
|
22223
22408
|
}
|
|
22224
22409
|
|
|
22410
|
+
var negate = false;
|
|
22225
22411
|
if (
|
|
22226
22412
|
state.switchU &&
|
|
22227
22413
|
this.options.ecmaVersion >= 9 &&
|
|
22228
|
-
(ch === 0x50 /* P */ || ch === 0x70 /* p */)
|
|
22414
|
+
((negate = ch === 0x50 /* P */) || ch === 0x70 /* p */)
|
|
22229
22415
|
) {
|
|
22230
22416
|
state.lastIntValue = -1;
|
|
22231
22417
|
state.advance();
|
|
22418
|
+
var result;
|
|
22232
22419
|
if (
|
|
22233
22420
|
state.eat(0x7B /* { */) &&
|
|
22234
|
-
this.regexp_eatUnicodePropertyValueExpression(state) &&
|
|
22421
|
+
(result = this.regexp_eatUnicodePropertyValueExpression(state)) &&
|
|
22235
22422
|
state.eat(0x7D /* } */)
|
|
22236
22423
|
) {
|
|
22237
|
-
|
|
22424
|
+
if (negate && result === CharSetString) { state.raise("Invalid property name"); }
|
|
22425
|
+
return result
|
|
22238
22426
|
}
|
|
22239
22427
|
state.raise("Invalid property name");
|
|
22240
22428
|
}
|
|
22241
22429
|
|
|
22242
|
-
return
|
|
22430
|
+
return CharSetNone
|
|
22243
22431
|
};
|
|
22432
|
+
|
|
22244
22433
|
function isCharacterClassEscape(ch) {
|
|
22245
22434
|
return (
|
|
22246
22435
|
ch === 0x64 /* d */ ||
|
|
@@ -22264,7 +22453,7 @@ pp$1.regexp_eatUnicodePropertyValueExpression = function(state) {
|
|
|
22264
22453
|
if (this.regexp_eatUnicodePropertyValue(state)) {
|
|
22265
22454
|
var value = state.lastStringValue;
|
|
22266
22455
|
this.regexp_validateUnicodePropertyNameAndValue(state, name, value);
|
|
22267
|
-
return
|
|
22456
|
+
return CharSetOk
|
|
22268
22457
|
}
|
|
22269
22458
|
}
|
|
22270
22459
|
state.pos = start;
|
|
@@ -22272,20 +22461,22 @@ pp$1.regexp_eatUnicodePropertyValueExpression = function(state) {
|
|
|
22272
22461
|
// LoneUnicodePropertyNameOrValue
|
|
22273
22462
|
if (this.regexp_eatLoneUnicodePropertyNameOrValue(state)) {
|
|
22274
22463
|
var nameOrValue = state.lastStringValue;
|
|
22275
|
-
this.regexp_validateUnicodePropertyNameOrValue(state, nameOrValue)
|
|
22276
|
-
return true
|
|
22464
|
+
return this.regexp_validateUnicodePropertyNameOrValue(state, nameOrValue)
|
|
22277
22465
|
}
|
|
22278
|
-
return
|
|
22466
|
+
return CharSetNone
|
|
22279
22467
|
};
|
|
22468
|
+
|
|
22280
22469
|
pp$1.regexp_validateUnicodePropertyNameAndValue = function(state, name, value) {
|
|
22281
22470
|
if (!hasOwn(state.unicodeProperties.nonBinary, name))
|
|
22282
22471
|
{ state.raise("Invalid property name"); }
|
|
22283
22472
|
if (!state.unicodeProperties.nonBinary[name].test(value))
|
|
22284
22473
|
{ state.raise("Invalid property value"); }
|
|
22285
22474
|
};
|
|
22475
|
+
|
|
22286
22476
|
pp$1.regexp_validateUnicodePropertyNameOrValue = function(state, nameOrValue) {
|
|
22287
|
-
if (
|
|
22288
|
-
|
|
22477
|
+
if (state.unicodeProperties.binary.test(nameOrValue)) { return CharSetOk }
|
|
22478
|
+
if (state.switchV && state.unicodeProperties.binaryOfStrings.test(nameOrValue)) { return CharSetString }
|
|
22479
|
+
state.raise("Invalid property name");
|
|
22289
22480
|
};
|
|
22290
22481
|
|
|
22291
22482
|
// UnicodePropertyName ::
|
|
@@ -22299,6 +22490,7 @@ pp$1.regexp_eatUnicodePropertyName = function(state) {
|
|
|
22299
22490
|
}
|
|
22300
22491
|
return state.lastStringValue !== ""
|
|
22301
22492
|
};
|
|
22493
|
+
|
|
22302
22494
|
function isUnicodePropertyNameCharacter(ch) {
|
|
22303
22495
|
return isControlLetter(ch) || ch === 0x5F /* _ */
|
|
22304
22496
|
}
|
|
@@ -22327,21 +22519,29 @@ pp$1.regexp_eatLoneUnicodePropertyNameOrValue = function(state) {
|
|
|
22327
22519
|
// https://www.ecma-international.org/ecma-262/8.0/#prod-CharacterClass
|
|
22328
22520
|
pp$1.regexp_eatCharacterClass = function(state) {
|
|
22329
22521
|
if (state.eat(0x5B /* [ */)) {
|
|
22330
|
-
state.eat(0x5E /* ^ */);
|
|
22331
|
-
this.
|
|
22332
|
-
if (state.eat(0x5D /* ] */))
|
|
22333
|
-
|
|
22334
|
-
|
|
22335
|
-
|
|
22336
|
-
|
|
22522
|
+
var negate = state.eat(0x5E /* ^ */);
|
|
22523
|
+
var result = this.regexp_classContents(state);
|
|
22524
|
+
if (!state.eat(0x5D /* ] */))
|
|
22525
|
+
{ state.raise("Unterminated character class"); }
|
|
22526
|
+
if (negate && result === CharSetString)
|
|
22527
|
+
{ state.raise("Negated character class may contain strings"); }
|
|
22528
|
+
return true
|
|
22337
22529
|
}
|
|
22338
22530
|
return false
|
|
22339
22531
|
};
|
|
22340
22532
|
|
|
22533
|
+
// https://tc39.es/ecma262/#prod-ClassContents
|
|
22341
22534
|
// https://www.ecma-international.org/ecma-262/8.0/#prod-ClassRanges
|
|
22535
|
+
pp$1.regexp_classContents = function(state) {
|
|
22536
|
+
if (state.current() === 0x5D /* ] */) { return CharSetOk }
|
|
22537
|
+
if (state.switchV) { return this.regexp_classSetExpression(state) }
|
|
22538
|
+
this.regexp_nonEmptyClassRanges(state);
|
|
22539
|
+
return CharSetOk
|
|
22540
|
+
};
|
|
22541
|
+
|
|
22342
22542
|
// https://www.ecma-international.org/ecma-262/8.0/#prod-NonemptyClassRanges
|
|
22343
22543
|
// https://www.ecma-international.org/ecma-262/8.0/#prod-NonemptyClassRangesNoDash
|
|
22344
|
-
pp$1.
|
|
22544
|
+
pp$1.regexp_nonEmptyClassRanges = function(state) {
|
|
22345
22545
|
while (this.regexp_eatClassAtom(state)) {
|
|
22346
22546
|
var left = state.lastIntValue;
|
|
22347
22547
|
if (state.eat(0x2D /* - */) && this.regexp_eatClassAtom(state)) {
|
|
@@ -22413,6 +22613,205 @@ pp$1.regexp_eatClassEscape = function(state) {
|
|
|
22413
22613
|
)
|
|
22414
22614
|
};
|
|
22415
22615
|
|
|
22616
|
+
// https://tc39.es/ecma262/#prod-ClassSetExpression
|
|
22617
|
+
// https://tc39.es/ecma262/#prod-ClassUnion
|
|
22618
|
+
// https://tc39.es/ecma262/#prod-ClassIntersection
|
|
22619
|
+
// https://tc39.es/ecma262/#prod-ClassSubtraction
|
|
22620
|
+
pp$1.regexp_classSetExpression = function(state) {
|
|
22621
|
+
var result = CharSetOk, subResult;
|
|
22622
|
+
if (this.regexp_eatClassSetRange(state)) ; else if (subResult = this.regexp_eatClassSetOperand(state)) {
|
|
22623
|
+
if (subResult === CharSetString) { result = CharSetString; }
|
|
22624
|
+
// https://tc39.es/ecma262/#prod-ClassIntersection
|
|
22625
|
+
var start = state.pos;
|
|
22626
|
+
while (state.eatChars([0x26, 0x26] /* && */)) {
|
|
22627
|
+
if (
|
|
22628
|
+
state.current() !== 0x26 /* & */ &&
|
|
22629
|
+
(subResult = this.regexp_eatClassSetOperand(state))
|
|
22630
|
+
) {
|
|
22631
|
+
if (subResult !== CharSetString) { result = CharSetOk; }
|
|
22632
|
+
continue
|
|
22633
|
+
}
|
|
22634
|
+
state.raise("Invalid character in character class");
|
|
22635
|
+
}
|
|
22636
|
+
if (start !== state.pos) { return result }
|
|
22637
|
+
// https://tc39.es/ecma262/#prod-ClassSubtraction
|
|
22638
|
+
while (state.eatChars([0x2D, 0x2D] /* -- */)) {
|
|
22639
|
+
if (this.regexp_eatClassSetOperand(state)) { continue }
|
|
22640
|
+
state.raise("Invalid character in character class");
|
|
22641
|
+
}
|
|
22642
|
+
if (start !== state.pos) { return result }
|
|
22643
|
+
} else {
|
|
22644
|
+
state.raise("Invalid character in character class");
|
|
22645
|
+
}
|
|
22646
|
+
// https://tc39.es/ecma262/#prod-ClassUnion
|
|
22647
|
+
for (;;) {
|
|
22648
|
+
if (this.regexp_eatClassSetRange(state)) { continue }
|
|
22649
|
+
subResult = this.regexp_eatClassSetOperand(state);
|
|
22650
|
+
if (!subResult) { return result }
|
|
22651
|
+
if (subResult === CharSetString) { result = CharSetString; }
|
|
22652
|
+
}
|
|
22653
|
+
};
|
|
22654
|
+
|
|
22655
|
+
// https://tc39.es/ecma262/#prod-ClassSetRange
|
|
22656
|
+
pp$1.regexp_eatClassSetRange = function(state) {
|
|
22657
|
+
var start = state.pos;
|
|
22658
|
+
if (this.regexp_eatClassSetCharacter(state)) {
|
|
22659
|
+
var left = state.lastIntValue;
|
|
22660
|
+
if (state.eat(0x2D /* - */) && this.regexp_eatClassSetCharacter(state)) {
|
|
22661
|
+
var right = state.lastIntValue;
|
|
22662
|
+
if (left !== -1 && right !== -1 && left > right) {
|
|
22663
|
+
state.raise("Range out of order in character class");
|
|
22664
|
+
}
|
|
22665
|
+
return true
|
|
22666
|
+
}
|
|
22667
|
+
state.pos = start;
|
|
22668
|
+
}
|
|
22669
|
+
return false
|
|
22670
|
+
};
|
|
22671
|
+
|
|
22672
|
+
// https://tc39.es/ecma262/#prod-ClassSetOperand
|
|
22673
|
+
pp$1.regexp_eatClassSetOperand = function(state) {
|
|
22674
|
+
if (this.regexp_eatClassSetCharacter(state)) { return CharSetOk }
|
|
22675
|
+
return this.regexp_eatClassStringDisjunction(state) || this.regexp_eatNestedClass(state)
|
|
22676
|
+
};
|
|
22677
|
+
|
|
22678
|
+
// https://tc39.es/ecma262/#prod-NestedClass
|
|
22679
|
+
pp$1.regexp_eatNestedClass = function(state) {
|
|
22680
|
+
var start = state.pos;
|
|
22681
|
+
if (state.eat(0x5B /* [ */)) {
|
|
22682
|
+
var negate = state.eat(0x5E /* ^ */);
|
|
22683
|
+
var result = this.regexp_classContents(state);
|
|
22684
|
+
if (state.eat(0x5D /* ] */)) {
|
|
22685
|
+
if (negate && result === CharSetString) {
|
|
22686
|
+
state.raise("Negated character class may contain strings");
|
|
22687
|
+
}
|
|
22688
|
+
return result
|
|
22689
|
+
}
|
|
22690
|
+
state.pos = start;
|
|
22691
|
+
}
|
|
22692
|
+
if (state.eat(0x5C /* \ */)) {
|
|
22693
|
+
var result$1 = this.regexp_eatCharacterClassEscape(state);
|
|
22694
|
+
if (result$1) {
|
|
22695
|
+
return result$1
|
|
22696
|
+
}
|
|
22697
|
+
state.pos = start;
|
|
22698
|
+
}
|
|
22699
|
+
return null
|
|
22700
|
+
};
|
|
22701
|
+
|
|
22702
|
+
// https://tc39.es/ecma262/#prod-ClassStringDisjunction
|
|
22703
|
+
pp$1.regexp_eatClassStringDisjunction = function(state) {
|
|
22704
|
+
var start = state.pos;
|
|
22705
|
+
if (state.eatChars([0x5C, 0x71] /* \q */)) {
|
|
22706
|
+
if (state.eat(0x7B /* { */)) {
|
|
22707
|
+
var result = this.regexp_classStringDisjunctionContents(state);
|
|
22708
|
+
if (state.eat(0x7D /* } */)) {
|
|
22709
|
+
return result
|
|
22710
|
+
}
|
|
22711
|
+
} else {
|
|
22712
|
+
// Make the same message as V8.
|
|
22713
|
+
state.raise("Invalid escape");
|
|
22714
|
+
}
|
|
22715
|
+
state.pos = start;
|
|
22716
|
+
}
|
|
22717
|
+
return null
|
|
22718
|
+
};
|
|
22719
|
+
|
|
22720
|
+
// https://tc39.es/ecma262/#prod-ClassStringDisjunctionContents
|
|
22721
|
+
pp$1.regexp_classStringDisjunctionContents = function(state) {
|
|
22722
|
+
var result = this.regexp_classString(state);
|
|
22723
|
+
while (state.eat(0x7C /* | */)) {
|
|
22724
|
+
if (this.regexp_classString(state) === CharSetString) { result = CharSetString; }
|
|
22725
|
+
}
|
|
22726
|
+
return result
|
|
22727
|
+
};
|
|
22728
|
+
|
|
22729
|
+
// https://tc39.es/ecma262/#prod-ClassString
|
|
22730
|
+
// https://tc39.es/ecma262/#prod-NonEmptyClassString
|
|
22731
|
+
pp$1.regexp_classString = function(state) {
|
|
22732
|
+
var count = 0;
|
|
22733
|
+
while (this.regexp_eatClassSetCharacter(state)) { count++; }
|
|
22734
|
+
return count === 1 ? CharSetOk : CharSetString
|
|
22735
|
+
};
|
|
22736
|
+
|
|
22737
|
+
// https://tc39.es/ecma262/#prod-ClassSetCharacter
|
|
22738
|
+
pp$1.regexp_eatClassSetCharacter = function(state) {
|
|
22739
|
+
var start = state.pos;
|
|
22740
|
+
if (state.eat(0x5C /* \ */)) {
|
|
22741
|
+
if (
|
|
22742
|
+
this.regexp_eatCharacterEscape(state) ||
|
|
22743
|
+
this.regexp_eatClassSetReservedPunctuator(state)
|
|
22744
|
+
) {
|
|
22745
|
+
return true
|
|
22746
|
+
}
|
|
22747
|
+
if (state.eat(0x62 /* b */)) {
|
|
22748
|
+
state.lastIntValue = 0x08; /* <BS> */
|
|
22749
|
+
return true
|
|
22750
|
+
}
|
|
22751
|
+
state.pos = start;
|
|
22752
|
+
return false
|
|
22753
|
+
}
|
|
22754
|
+
var ch = state.current();
|
|
22755
|
+
if (ch < 0 || ch === state.lookahead() && isClassSetReservedDoublePunctuatorCharacter(ch)) { return false }
|
|
22756
|
+
if (isClassSetSyntaxCharacter(ch)) { return false }
|
|
22757
|
+
state.advance();
|
|
22758
|
+
state.lastIntValue = ch;
|
|
22759
|
+
return true
|
|
22760
|
+
};
|
|
22761
|
+
|
|
22762
|
+
// https://tc39.es/ecma262/#prod-ClassSetReservedDoublePunctuator
|
|
22763
|
+
function isClassSetReservedDoublePunctuatorCharacter(ch) {
|
|
22764
|
+
return (
|
|
22765
|
+
ch === 0x21 /* ! */ ||
|
|
22766
|
+
ch >= 0x23 /* # */ && ch <= 0x26 /* & */ ||
|
|
22767
|
+
ch >= 0x2A /* * */ && ch <= 0x2C /* , */ ||
|
|
22768
|
+
ch === 0x2E /* . */ ||
|
|
22769
|
+
ch >= 0x3A /* : */ && ch <= 0x40 /* @ */ ||
|
|
22770
|
+
ch === 0x5E /* ^ */ ||
|
|
22771
|
+
ch === 0x60 /* ` */ ||
|
|
22772
|
+
ch === 0x7E /* ~ */
|
|
22773
|
+
)
|
|
22774
|
+
}
|
|
22775
|
+
|
|
22776
|
+
// https://tc39.es/ecma262/#prod-ClassSetSyntaxCharacter
|
|
22777
|
+
function isClassSetSyntaxCharacter(ch) {
|
|
22778
|
+
return (
|
|
22779
|
+
ch === 0x28 /* ( */ ||
|
|
22780
|
+
ch === 0x29 /* ) */ ||
|
|
22781
|
+
ch === 0x2D /* - */ ||
|
|
22782
|
+
ch === 0x2F /* / */ ||
|
|
22783
|
+
ch >= 0x5B /* [ */ && ch <= 0x5D /* ] */ ||
|
|
22784
|
+
ch >= 0x7B /* { */ && ch <= 0x7D /* } */
|
|
22785
|
+
)
|
|
22786
|
+
}
|
|
22787
|
+
|
|
22788
|
+
// https://tc39.es/ecma262/#prod-ClassSetReservedPunctuator
|
|
22789
|
+
pp$1.regexp_eatClassSetReservedPunctuator = function(state) {
|
|
22790
|
+
var ch = state.current();
|
|
22791
|
+
if (isClassSetReservedPunctuator(ch)) {
|
|
22792
|
+
state.lastIntValue = ch;
|
|
22793
|
+
state.advance();
|
|
22794
|
+
return true
|
|
22795
|
+
}
|
|
22796
|
+
return false
|
|
22797
|
+
};
|
|
22798
|
+
|
|
22799
|
+
// https://tc39.es/ecma262/#prod-ClassSetReservedPunctuator
|
|
22800
|
+
function isClassSetReservedPunctuator(ch) {
|
|
22801
|
+
return (
|
|
22802
|
+
ch === 0x21 /* ! */ ||
|
|
22803
|
+
ch === 0x23 /* # */ ||
|
|
22804
|
+
ch === 0x25 /* % */ ||
|
|
22805
|
+
ch === 0x26 /* & */ ||
|
|
22806
|
+
ch === 0x2C /* , */ ||
|
|
22807
|
+
ch === 0x2D /* - */ ||
|
|
22808
|
+
ch >= 0x3A /* : */ && ch <= 0x3E /* > */ ||
|
|
22809
|
+
ch === 0x40 /* @ */ ||
|
|
22810
|
+
ch === 0x60 /* ` */ ||
|
|
22811
|
+
ch === 0x7E /* ~ */
|
|
22812
|
+
)
|
|
22813
|
+
}
|
|
22814
|
+
|
|
22416
22815
|
// https://www.ecma-international.org/ecma-262/8.0/#prod-annexB-ClassControlLetter
|
|
22417
22816
|
pp$1.regexp_eatClassControlLetter = function(state) {
|
|
22418
22817
|
var ch = state.current();
|
|
@@ -23333,8 +23732,23 @@ pp.readWord = function() {
|
|
|
23333
23732
|
};
|
|
23334
23733
|
|
|
23335
23734
|
// Acorn is a tiny, fast JavaScript parser written in JavaScript.
|
|
23735
|
+
//
|
|
23736
|
+
// Acorn was written by Marijn Haverbeke, Ingvar Stepanyan, and
|
|
23737
|
+
// various contributors and released under an MIT license.
|
|
23738
|
+
//
|
|
23739
|
+
// Git repositories for Acorn are available at
|
|
23740
|
+
//
|
|
23741
|
+
// http://marijnhaverbeke.nl/git/acorn
|
|
23742
|
+
// https://github.com/acornjs/acorn.git
|
|
23743
|
+
//
|
|
23744
|
+
// Please use the [github bug tracker][ghbt] to report issues.
|
|
23745
|
+
//
|
|
23746
|
+
// [ghbt]: https://github.com/acornjs/acorn/issues
|
|
23747
|
+
//
|
|
23748
|
+
// [walk]: util/walk.js
|
|
23749
|
+
|
|
23336
23750
|
|
|
23337
|
-
var version = "8.
|
|
23751
|
+
var version = "8.9.0";
|
|
23338
23752
|
|
|
23339
23753
|
Parser.acorn = {
|
|
23340
23754
|
Parser: Parser,
|
|
@@ -23764,7 +24178,7 @@ async function transform(source, module, pluginDriver, log) {
|
|
|
23764
24178
|
let customTransformCache = false;
|
|
23765
24179
|
const useCustomTransformCache = () => (customTransformCache = true);
|
|
23766
24180
|
let pluginName = '';
|
|
23767
|
-
|
|
24181
|
+
let currentSource = source.code;
|
|
23768
24182
|
function transformReducer(previousCode, result, plugin) {
|
|
23769
24183
|
let code;
|
|
23770
24184
|
let map;
|
|
@@ -23792,6 +24206,7 @@ async function transform(source, module, pluginDriver, log) {
|
|
|
23792
24206
|
plugin: plugin.name
|
|
23793
24207
|
});
|
|
23794
24208
|
}
|
|
24209
|
+
currentSource = code;
|
|
23795
24210
|
return code;
|
|
23796
24211
|
}
|
|
23797
24212
|
const getLogHandler = (handler) => (log, pos) => {
|