summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2019-09-06 02:51:17 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2019-09-06 03:00:04 +0000
commit22e8fa20fa93dd83f4f32b05905149ca38835187 (patch)
tree7dd2eb797b3b3be81fd264e0e80071918e1a2cac
parentReleasing progress-linux version 6.1.1+ds+~0.3.1+~4.0.0+~1.0.0+~5.0.1+ds+~1.6... (diff)
downloadacorn-22e8fa20fa93dd83f4f32b05905149ca38835187.tar.xz
acorn-22e8fa20fa93dd83f4f32b05905149ca38835187.zip
Merging upstream version 6.2.1+ds+~0.4.0+~4.0.0+really4.0.0+~1.0.0+~5.0.1+ds+~1.7.0+ds+~0.1.1+~0.3.1+~0.2.0+~0.1.0+~0.3.0+~0.3.0.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
-rw-r--r--.npmrc1
-rw-r--r--.travis.yml8
-rw-r--r--acorn-loose/CHANGELOG.md8
-rw-r--r--acorn-loose/package.json4
-rw-r--r--acorn-loose/rollup.config.js29
-rw-r--r--acorn-loose/src/expression.js14
-rw-r--r--acorn-loose/src/statement.js6
-rw-r--r--acorn-walk/CHANGELOG.md6
-rw-r--r--acorn-walk/package.json2
-rw-r--r--acorn-walk/rollup.config.js21
-rw-r--r--acorn-walk/src/index.js2
-rw-r--r--acorn/CHANGELOG.md24
-rw-r--r--acorn/README.md5
-rw-r--r--acorn/dist/acorn.d.ts2
-rw-r--r--acorn/package.json2
-rw-r--r--acorn/rollup.config.bin.js12
-rw-r--r--acorn/rollup.config.js21
-rw-r--r--acorn/src/.eslintrc3
-rw-r--r--acorn/src/bin/acorn.js2
-rw-r--r--acorn/src/expression.js34
-rw-r--r--acorn/src/identifier.js9
-rw-r--r--acorn/src/index.js2
-rw-r--r--acorn/src/lval.js4
-rw-r--r--acorn/src/regexp.js2
-rw-r--r--acorn/src/state.js2
-rw-r--r--acorn/src/statement.js45
-rw-r--r--acorn/src/tokenize.js13
-rw-r--r--acorn/src/tokentype.js2
-rw-r--r--acorn/src/unicode-property-data.js11
-rw-r--r--bin/generate-identifier-regex.js2
-rw-r--r--node-acorn-bigint/CHANGELOG.md4
-rw-r--r--node-acorn-bigint/index.js12
-rw-r--r--node-acorn-bigint/package.json14
-rw-r--r--node-acorn-class-fields/.eslintrc.json294
-rw-r--r--node-acorn-class-fields/.gitignore1
-rw-r--r--node-acorn-class-fields/CHANGELOG.md28
-rw-r--r--node-acorn-class-fields/LICENSE19
-rw-r--r--node-acorn-class-fields/README.md21
-rw-r--r--node-acorn-class-fields/index.js61
-rw-r--r--node-acorn-class-fields/package.json36
-rw-r--r--node-acorn-class-fields/run_test262.js26
-rw-r--r--node-acorn-class-fields/test/.eslintrc.json5
-rw-r--r--node-acorn-class-fields/test/test.js342
-rw-r--r--node-acorn-class-fields/test262.whitelist0
-rw-r--r--node-acorn-export-ns-from/.eslintrc.json295
-rw-r--r--node-acorn-export-ns-from/.gitignore2
-rw-r--r--node-acorn-export-ns-from/CHANGELOG.md3
-rw-r--r--node-acorn-export-ns-from/LICENSE19
-rw-r--r--node-acorn-export-ns-from/README.md21
-rw-r--r--node-acorn-export-ns-from/index.js31
-rw-r--r--node-acorn-export-ns-from/package.json33
-rw-r--r--node-acorn-export-ns-from/run_test262.js17
-rw-r--r--node-acorn-export-ns-from/test/.eslintrc.json5
-rw-r--r--node-acorn-export-ns-from/test/test.js69
-rw-r--r--node-acorn-export-ns-from/test262.whitelist0
-rw-r--r--node-acorn-node/CHANGELOG.md20
-rw-r--r--node-acorn-node/README.md9
-rw-r--r--node-acorn-node/build.js13
-rw-r--r--node-acorn-node/index.js3
-rw-r--r--node-acorn-node/package.json12
-rw-r--r--node-acorn-node/test/index.js35
-rw-r--r--node-acorn-numeric-separator/.eslintrc.json294
-rw-r--r--node-acorn-numeric-separator/.gitignore1
-rw-r--r--node-acorn-numeric-separator/CHANGELOG.md16
-rw-r--r--node-acorn-numeric-separator/LICENSE19
-rw-r--r--node-acorn-numeric-separator/README.md21
-rw-r--r--node-acorn-numeric-separator/index.js49
-rw-r--r--node-acorn-numeric-separator/package.json33
-rw-r--r--node-acorn-numeric-separator/run_test262.js27
-rw-r--r--node-acorn-numeric-separator/test/.eslintrc.json5
-rw-r--r--node-acorn-numeric-separator/test/test.js270
-rw-r--r--node-acorn-private-class-elements/.eslintrc.json296
-rw-r--r--node-acorn-private-class-elements/.gitignore1
-rw-r--r--node-acorn-private-class-elements/CHANGELOG.md7
-rw-r--r--node-acorn-private-class-elements/LICENSE19
-rw-r--r--node-acorn-private-class-elements/README.md11
-rw-r--r--node-acorn-private-class-elements/index.js123
-rw-r--r--node-acorn-private-class-elements/package.json32
-rw-r--r--node-acorn-private-class-elements/test/.eslintrc.json5
-rw-r--r--node-acorn-private-class-elements/test/test.js15
-rw-r--r--node-acorn-private-methods/.eslintrc.json294
-rw-r--r--node-acorn-private-methods/.gitignore1
-rw-r--r--node-acorn-private-methods/CHANGELOG.md29
-rw-r--r--node-acorn-private-methods/LICENSE19
-rw-r--r--node-acorn-private-methods/README.md21
-rw-r--r--node-acorn-private-methods/index.js25
-rw-r--r--node-acorn-private-methods/package.json36
-rw-r--r--node-acorn-private-methods/run_test262.js30
-rw-r--r--node-acorn-private-methods/test/.eslintrc.json5
-rw-r--r--node-acorn-private-methods/test/test.js285
-rw-r--r--node-acorn-private-methods/test262.whitelist0
-rw-r--r--node-acorn-static-class-features/.eslintrc.json294
-rw-r--r--node-acorn-static-class-features/.gitignore1
-rw-r--r--node-acorn-static-class-features/CHANGELOG.md11
-rw-r--r--node-acorn-static-class-features/LICENSE19
-rw-r--r--node-acorn-static-class-features/README.md21
-rw-r--r--node-acorn-static-class-features/index.js126
-rw-r--r--node-acorn-static-class-features/package.json36
-rw-r--r--node-acorn-static-class-features/run_test262.js28
-rw-r--r--node-acorn-static-class-features/test/.eslintrc.json5
-rw-r--r--node-acorn-static-class-features/test/test.js409
-rw-r--r--node-acorn-static-class-features/test262.whitelist0
-rw-r--r--package.json11
-rw-r--r--test/driver.js2
-rw-r--r--test/run.js2
-rw-r--r--test/tests-bigint.js197
-rw-r--r--test/tests-dynamic-import.js128
-rw-r--r--test/tests-harmony.js123
108 files changed, 4957 insertions, 193 deletions
diff --git a/.npmrc b/.npmrc
new file mode 100644
index 0000000..7715576
--- /dev/null
+++ b/.npmrc
@@ -0,0 +1 @@
+package-lock = false \ No newline at end of file
diff --git a/.travis.yml b/.travis.yml
index 27e8b82..731ec89 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -3,14 +3,12 @@ sudo: false
cache: npm
matrix:
include:
- - node_js: '0.12'
- - node_js: '4'
- - node_js: '5'
- node_js: '6'
- - node_js: '7'
- - node_js: '8'
- node_js: '8'
+ - node_js: '10'
+ - node_js: '10'
env: TEST_SUITE=test262
+ - node_js: '12'
script: >
if [ "$TEST_SUITE" != "test262" ]; then
npm test
diff --git a/acorn-loose/CHANGELOG.md b/acorn-loose/CHANGELOG.md
index 014309b..495184e 100644
--- a/acorn-loose/CHANGELOG.md
+++ b/acorn-loose/CHANGELOG.md
@@ -1,3 +1,11 @@
+## 6.1.0 (2019-07-04)
+
+## New features
+
+Support bigint syntax.
+
+Support dynamic import.
+
## 6.0.0 (2018-09-14)
### Breaking changes
diff --git a/acorn-loose/package.json b/acorn-loose/package.json
index 08f564e..5adabfc 100644
--- a/acorn-loose/package.json
+++ b/acorn-loose/package.json
@@ -4,10 +4,10 @@
"homepage": "https://github.com/acornjs/acorn",
"main": "dist/acorn-loose.js",
"module": "dist/acorn-loose.mjs",
- "version": "6.0.0",
+ "version": "6.1.0",
"engines": {"node": ">=0.4.0"},
"dependencies": {
- "acorn": "^6.0.0"
+ "acorn": "^6.2.0"
},
"maintainers": [
{
diff --git a/acorn-loose/rollup.config.js b/acorn-loose/rollup.config.js
index e5cbc30..32f6d8a 100644
--- a/acorn-loose/rollup.config.js
+++ b/acorn-loose/rollup.config.js
@@ -1,16 +1,25 @@
import buble from "rollup-plugin-buble"
export default {
- entry: "./acorn-loose/src/index.js",
- moduleName: "acorn.loose",
+ input: "./acorn-loose/src/index.js",
+ output: [
+ {
+ file: "acorn-loose/dist/acorn-loose.js",
+ format: "umd",
+ name: "acorn.loose",
+ sourceMap: true,
+ external: ["acorn"],
+ globals: {acorn: "acorn"}
+ },
+ {
+ file: "acorn-loose/dist/acorn-loose.mjs",
+ format: "es",
+ sourceMap: true,
+ external: ["acorn"],
+ globals: {acorn: "acorn"}
+ }
+ ],
plugins: [
buble({transforms: {dangerousForOf: true}})
- ],
- sourceMap: true,
- targets: [
- {dest: "acorn-loose/dist/acorn-loose.js", format: "umd"},
- {dest: "acorn-loose/dist/acorn-loose.mjs", format: "es"}
- ],
- external: ["acorn"],
- globals: {acorn: "acorn"}
+ ]
}
diff --git a/acorn-loose/src/expression.js b/acorn-loose/src/expression.js
index d5dba4e..fe338d9 100644
--- a/acorn-loose/src/expression.js
+++ b/acorn-loose/src/expression.js
@@ -244,6 +244,7 @@ lp.parseExprAtom = function() {
node = this.startNode()
node.value = this.tok.value
node.raw = this.input.slice(this.tok.start, this.tok.end)
+ if (this.tok.type === tt.num && node.raw.charCodeAt(node.raw.length - 1) === 110) node.bigint = node.raw.slice(0, -1)
this.next()
return this.finishNode(node, "Literal")
@@ -295,11 +296,24 @@ lp.parseExprAtom = function() {
case tt.backQuote:
return this.parseTemplate()
+ case tt._import:
+ if (this.options.ecmaVersion > 10) {
+ return this.parseDynamicImport()
+ } else {
+ return this.dummyIdent()
+ }
+
default:
return this.dummyIdent()
}
}
+lp.parseDynamicImport = function() {
+ const node = this.startNode()
+ this.next()
+ return this.finishNode(node, "Import")
+}
+
lp.parseNew = function() {
let node = this.startNode(), startIndent = this.curIndent, line = this.curLineStart
let meta = this.parseIdent(true)
diff --git a/acorn-loose/src/statement.js b/acorn-loose/src/statement.js
index c3701f7..ac20842 100644
--- a/acorn-loose/src/statement.js
+++ b/acorn-loose/src/statement.js
@@ -178,6 +178,12 @@ lp.parseStatement = function() {
return this.parseClass(true)
case tt._import:
+ if (this.options.ecmaVersion > 10 && this.lookAhead(1).type === tt.parenL) {
+ node.expression = this.parseExpression()
+ this.semicolon()
+ return this.finishNode(node, "ExpressionStatement")
+ }
+
return this.parseImport()
case tt._export:
diff --git a/acorn-walk/CHANGELOG.md b/acorn-walk/CHANGELOG.md
index 525950b..c02dbd7 100644
--- a/acorn-walk/CHANGELOG.md
+++ b/acorn-walk/CHANGELOG.md
@@ -1,3 +1,9 @@
+## 6.2.0 (2017-07-04)
+
+### New features
+
+Add support for `Import` nodes.
+
## 6.1.0 (2018-09-28)
### New features
diff --git a/acorn-walk/package.json b/acorn-walk/package.json
index aee3f25..239e6c7 100644
--- a/acorn-walk/package.json
+++ b/acorn-walk/package.json
@@ -4,7 +4,7 @@
"homepage": "https://github.com/acornjs/acorn",
"main": "dist/walk.js",
"module": "dist/walk.mjs",
- "version": "6.1.1",
+ "version": "6.2.0",
"engines": {"node": ">=0.4.0"},
"maintainers": [
{
diff --git a/acorn-walk/rollup.config.js b/acorn-walk/rollup.config.js
index 2588b1c..36f9064 100644
--- a/acorn-walk/rollup.config.js
+++ b/acorn-walk/rollup.config.js
@@ -1,14 +1,21 @@
import buble from "rollup-plugin-buble"
export default {
- entry: "acorn-walk/src/index.js",
- moduleName: "acorn.walk",
+ input: "acorn-walk/src/index.js",
+ output: [
+ {
+ file: "acorn-walk/dist/walk.js",
+ format: "umd",
+ name: "acorn.walk",
+ sourceMap: true
+ },
+ {
+ file: "acorn-walk/dist/walk.mjs",
+ format: "es",
+ sourceMap: true
+ }
+ ],
plugins: [
buble({transforms: {dangerousForOf: true}})
- ],
- sourceMap: true,
- targets: [
- {dest: "acorn-walk/dist/walk.js", format: "umd"},
- {dest: "acorn-walk/dist/walk.mjs", format: "es"}
]
}
diff --git a/acorn-walk/src/index.js b/acorn-walk/src/index.js
index 25f5166..fb34150 100644
--- a/acorn-walk/src/index.js
+++ b/acorn-walk/src/index.js
@@ -360,7 +360,7 @@ base.ImportDeclaration = (node, st, c) => {
c(spec, st)
c(node.source, st, "Expression")
}
-base.ImportSpecifier = base.ImportDefaultSpecifier = base.ImportNamespaceSpecifier = base.Identifier = base.Literal = ignore
+base.ImportSpecifier = base.ImportDefaultSpecifier = base.ImportNamespaceSpecifier = base.Identifier = base.Literal = base.Import = ignore
base.TaggedTemplateExpression = (node, st, c) => {
c(node.tag, st, "Expression")
diff --git a/acorn/CHANGELOG.md b/acorn/CHANGELOG.md
index 1c8f79c..f2cd6a4 100644
--- a/acorn/CHANGELOG.md
+++ b/acorn/CHANGELOG.md
@@ -1,3 +1,27 @@
+## 6.2.1 (2019-07-21)
+
+### Bug fixes
+
+Fix bug causing Acorn to treat some characters as identifier characters that shouldn't be treated as such.
+
+Fix issue where setting the `allowReserved` option to `"never"` allowed reserved words in some circumstances.
+
+## 6.2.0 (2019-07-04)
+
+### Bug fixes
+
+Improve valid assignment checking in `for`/`in` and `for`/`of` loops.
+
+Disallow binding `let` in patterns.
+
+### New features
+
+Support bigint syntax with `ecmaVersion` >= 10.
+
+Support dynamic `import` syntax with `ecmaVersion` >= 10.
+
+Upgrade to Unicode version 12.
+
## 6.1.1 (2019-02-27)
### Bug fixes
diff --git a/acorn/README.md b/acorn/README.md
index 3e5f58d..fa372ee 100644
--- a/acorn/README.md
+++ b/acorn/README.md
@@ -54,7 +54,7 @@ an object containing any of these fields:
- **ecmaVersion**: Indicates the ECMAScript version to parse. Must be
either 3, 5, 6 (2015), 7 (2016), 8 (2017), 9 (2018) or 10 (2019, partial
support). This influences support for strict mode, the set of
- reserved words, and support for new syntax features. Default is 7.
+ reserved words, and support for new syntax features. Default is 9.
**NOTE**: Only 'stage 4' (finalized) ECMAScript features are being
implemented by Acorn. Other proposed new features can be implemented
@@ -260,10 +260,7 @@ The utility spits out the syntax tree as JSON data.
Plugins for ECMAScript proposals:
- [`acorn-stage3`](https://github.com/acornjs/acorn-stage3): Parse most stage 3 proposals, bundling:
- - [`acorn-async-iteration`](https://github.com/acornjs/acorn-async-iteration): Parse [async iteration proposal](https://github.com/tc39/proposal-async-iteration)
- - [`acorn-bigint`](https://github.com/acornjs/acorn-bigint): Parse [BigInt proposal](https://github.com/tc39/proposal-bigint)
- [`acorn-class-fields`](https://github.com/acornjs/acorn-class-fields): Parse [class fields proposal](https://github.com/tc39/proposal-class-fields)
- - [`acorn-dynamic-import`](https://github.com/kesne/acorn-dynamic-import): Parse [import() proposal](https://github.com/tc39/proposal-dynamic-import)
- [`acorn-import-meta`](https://github.com/acornjs/acorn-import-meta): Parse [import.meta proposal](https://github.com/tc39/proposal-import-meta)
- [`acorn-numeric-separator`](https://github.com/acornjs/acorn-numeric-separator): Parse [numeric separator proposal](https://github.com/tc39/proposal-numeric-separator)
- [`acorn-private-methods`](https://github.com/acornjs/acorn-private-methods): parse [private methods, getters and setters proposal](https://github.com/tc39/proposal-private-methods)n
diff --git a/acorn/dist/acorn.d.ts b/acorn/dist/acorn.d.ts
index c6f9841..9d6bb78 100644
--- a/acorn/dist/acorn.d.ts
+++ b/acorn/dist/acorn.d.ts
@@ -16,7 +16,7 @@ declare namespace acorn {
sourceType?: 'script' | 'module'
onInsertedSemicolon?: (lastTokEnd: number, lastTokEndLoc?: Position) => void
onTrailingComma?: (lastTokEnd: number, lastTokEndLoc?: Position) => void
- allowReserved?: boolean
+ allowReserved?: boolean | 'never'
allowReturnOutsideFunction?: boolean
allowImportExportEverywhere?: boolean
allowAwaitOutsideFunction?: boolean
diff --git a/acorn/package.json b/acorn/package.json
index 808d1da..c6f8123 100644
--- a/acorn/package.json
+++ b/acorn/package.json
@@ -4,7 +4,7 @@
"homepage": "https://github.com/acornjs/acorn",
"main": "dist/acorn.js",
"module": "dist/acorn.mjs",
- "version": "6.1.1",
+ "version": "6.2.1",
"engines": {"node": ">=0.4.0"},
"maintainers": [
{
diff --git a/acorn/rollup.config.bin.js b/acorn/rollup.config.bin.js
index 19234cb..8a082b0 100644
--- a/acorn/rollup.config.bin.js
+++ b/acorn/rollup.config.bin.js
@@ -1,10 +1,12 @@
import buble from "rollup-plugin-buble"
export default {
- entry: "acorn/src/bin/acorn.js",
- dest: "acorn/dist/bin.js",
- format: "cjs",
- external: ["fs", "path", "acorn"],
- paths: {acorn: "./acorn.js"},
+ input: "acorn/src/bin/acorn.js",
+ output: {
+ file: "acorn/dist/bin.js",
+ format: "cjs",
+ paths: {acorn: "./acorn.js"},
+ external: ["fs", "path", "acorn"]
+ },
plugins: [buble()]
}
diff --git a/acorn/rollup.config.js b/acorn/rollup.config.js
index 79dac8e..0705d4c 100644
--- a/acorn/rollup.config.js
+++ b/acorn/rollup.config.js
@@ -1,14 +1,21 @@
import buble from "rollup-plugin-buble"
export default {
- entry: "acorn/src/index.js",
- moduleName: "acorn",
+ input: "acorn/src/index.js",
+ output: [
+ {
+ file: "acorn/dist/acorn.js",
+ format: "umd",
+ name: "acorn",
+ sourceMap: true
+ },
+ {
+ file: "acorn/dist/acorn.mjs",
+ format: "es",
+ sourceMap: true
+ }
+ ],
plugins: [
buble({transforms: {dangerousForOf: true}})
- ],
- sourceMap: true,
- targets: [
- {dest: "acorn/dist/acorn.js", format: "umd"},
- {dest: "acorn/dist/acorn.mjs", format: "es"}
]
}
diff --git a/acorn/src/.eslintrc b/acorn/src/.eslintrc
index ea6fbdf..181c1b3 100644
--- a/acorn/src/.eslintrc
+++ b/acorn/src/.eslintrc
@@ -25,7 +25,8 @@
"space-before-function-paren": ["error", "never"]
},
"globals": {
- "Packages": false
+ "Packages": false,
+ "BigInt": false
},
"plugins": [
"import"
diff --git a/acorn/src/bin/acorn.js b/acorn/src/bin/acorn.js
index 2aa4139..9a6712c 100644
--- a/acorn/src/bin/acorn.js
+++ b/acorn/src/bin/acorn.js
@@ -46,7 +46,7 @@ function run(code) {
} while (token.type !== acorn.tokTypes.eof)
}
} catch (e) {
- console.error(e.message)
+ console.error(infile && infile !== "-" ? e.message.replace(/\(\d+:\d+\)$/, m => m.slice(0, 1) + infile + " " + m.slice(1)) : e.message)
process.exit(1)
}
if (!silent) console.log(JSON.stringify(result, null, compact ? null : 2))
diff --git a/acorn/src/expression.js b/acorn/src/expression.js
index 97c3fe6..7a4aed9 100644
--- a/acorn/src/expression.js
+++ b/acorn/src/expression.js
@@ -281,7 +281,7 @@ pp.parseSubscript = function(base, startPos, startLoc, noCalls, maybeAsyncArrow)
this.yieldPos = 0
this.awaitPos = 0
this.awaitIdentPos = 0
- let exprList = this.parseExprList(tt.parenR, this.options.ecmaVersion >= 8, false, refDestructuringErrors)
+ let exprList = this.parseExprList(tt.parenR, this.options.ecmaVersion >= 8 && base.type !== "Import", false, refDestructuringErrors)
if (maybeAsyncArrow && !this.canInsertSemicolon() && this.eat(tt.arrow)) {
this.checkPatternErrors(refDestructuringErrors, false)
this.checkYieldAwaitInDefaultParams()
@@ -299,6 +299,16 @@ pp.parseSubscript = function(base, startPos, startLoc, noCalls, maybeAsyncArrow)
let node = this.startNodeAt(startPos, startLoc)
node.callee = base
node.arguments = exprList
+ if (node.callee.type === "Import") {
+ if (node.arguments.length !== 1) {
+ this.raise(node.start, "import() requires exactly one argument")
+ }
+
+ const importArg = node.arguments[0]
+ if (importArg && importArg.type === "SpreadElement") {
+ this.raise(importArg.start, "... is not allowed in import()")
+ }
+ }
base = this.finishNode(node, "CallExpression")
} else if (this.type === tt.backQuote) {
let node = this.startNodeAt(startPos, startLoc)
@@ -409,15 +419,32 @@ pp.parseExprAtom = function(refDestructuringErrors) {
case tt.backQuote:
return this.parseTemplate()
+ case tt._import:
+ if (this.options.ecmaVersion > 10) {
+ return this.parseDynamicImport()
+ } else {
+ return this.unexpected()
+ }
+
default:
this.unexpected()
}
}
+pp.parseDynamicImport = function() {
+ const node = this.startNode()
+ this.next()
+ if (this.type !== tt.parenL) {
+ this.unexpected()
+ }
+ return this.finishNode(node, "Import")
+}
+
pp.parseLiteral = function(value) {
let node = this.startNode()
node.value = value
node.raw = this.input.slice(this.start, this.end)
+ if (node.raw.charCodeAt(node.raw.length - 1) === 110) node.bigint = node.raw.slice(0, -1)
this.next()
return this.finishNode(node, "Literal")
}
@@ -522,7 +549,10 @@ pp.parseNew = function() {
}
let startPos = this.start, startLoc = this.startLoc
node.callee = this.parseSubscripts(this.parseExprAtom(), startPos, startLoc, true)
- if (this.eat(tt.parenL)) node.arguments = this.parseExprList(tt.parenR, this.options.ecmaVersion >= 8, false)
+ if (this.options.ecmaVersion > 10 && node.callee.type === "Import") {
+ this.raise(node.callee.start, "Cannot use new with import(...)")
+ }
+ if (this.eat(tt.parenL)) node.arguments = this.parseExprList(tt.parenR, this.options.ecmaVersion >= 8 && node.callee.type !== "Import", false)
else node.arguments = empty
return this.finishNode(node, "NewExpression")
}
diff --git a/acorn/src/identifier.js b/acorn/src/identifier.js
index 2e6464d..c768a2d 100644
--- a/acorn/src/identifier.js
+++ b/acorn/src/identifier.js
@@ -26,9 +26,8 @@ export const keywordRelationalOperator = /^in(stanceof)?$/
// are only applied when a character is found to actually have a
// code point above 128.
// Generated by `bin/generate-identifier-regex.js`.
-
-let 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\u08a0-\u08b4\u08b6-\u08bd\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\u0c60\u0c61\u0c80\u0c85-\u0c8c\u0c8e-\u0c90\u0c92-\u0ca8\u0caa-\u0cb3\u0cb5-\u0cb9\u0cbd\u0cde\u0ce0\u0ce1\u0cf1\u0cf2\u0d05-\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\u0e87\u0e88\u0e8a\u0e8d\u0e94-\u0e97\u0e99-\u0e9f\u0ea1-\u0ea3\u0ea5\u0ea7\u0eaa\u0eab\u0ead-\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-\u170c\u170e-\u1711\u1720-\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-\u1b4b\u1b83-\u1ba0\u1bae\u1baf\u1bba-\u1be5\u1c00-\u1c23\u1c4d-\u1c4f\u1c5a-\u1c7d\u1c80-\u1c88\u1c90-\u1cba\u1cbd-\u1cbf\u1ce9-\u1cec\u1cee-\u1cf1\u1cf5\u1cf6\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-\u2c2e\u2c30-\u2c5e\u2c60-\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-\u31ba\u31f0-\u31ff\u3400-\u4db5\u4e00-\u9fef\ua000-\ua48c\ua4d0-\ua4fd\ua500-\ua60c\ua610-\ua61f\ua62a\ua62b\ua640-\ua66e\ua67f-\ua69d\ua6a0-\ua6ef\ua717-\ua71f\ua722-\ua788\ua78b-\ua7b9\ua7f7-\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-\uab65\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"
-let nonASCIIidentifierChars = "\u200c\u200d\xb7\u0300-\u036f\u0387\u0483-\u0487\u0591-\u05bd\u05bf\u05c1\u05c2\u05c4\u05c5\u05c7\u0610-\u061a\u064b-\u0669\u0670\u06d6-\u06dc\u06df-\u06e4\u06e7\u06e8\u06ea-\u06ed\u06f0-\u06f9\u0711\u0730-\u074a\u07a6-\u07b0\u07c0-\u07c9\u07eb-\u07f3\u07fd\u0816-\u0819\u081b-\u0823\u0825-\u0827\u0829-\u082d\u0859-\u085b\u08d3-\u08e1\u08e3-\u0903\u093a-\u093c\u093e-\u094f\u0951-\u0957\u0962\u0963\u0966-\u096f\u0981-\u0983\u09bc\u09be-\u09c4\u09c7\u09c8\u09cb-\u09cd\u09d7\u09e2\u09e3\u09e6-\u09ef\u09fe\u0a01-\u0a03\u0a3c\u0a3e-\u0a42\u0a47\u0a48\u0a4b-\u0a4d\u0a51\u0a66-\u0a71\u0a75\u0a81-\u0a83\u0abc\u0abe-\u0ac5\u0ac7-\u0ac9\u0acb-\u0acd\u0ae2\u0ae3\u0ae6-\u0aef\u0afa-\u0aff\u0b01-\u0b03\u0b3c\u0b3e-\u0b44\u0b47\u0b48\u0b4b-\u0b4d\u0b56\u0b57\u0b62\u0b63\u0b66-\u0b6f\u0b82\u0bbe-\u0bc2\u0bc6-\u0bc8\u0bca-\u0bcd\u0bd7\u0be6-\u0bef\u0c00-\u0c04\u0c3e-\u0c44\u0c46-\u0c48\u0c4a-\u0c4d\u0c55\u0c56\u0c62\u0c63\u0c66-\u0c6f\u0c81-\u0c83\u0cbc\u0cbe-\u0cc4\u0cc6-\u0cc8\u0cca-\u0ccd\u0cd5\u0cd6\u0ce2\u0ce3\u0ce6-\u0cef\u0d00-\u0d03\u0d3b\u0d3c\u0d3e-\u0d44\u0d46-\u0d48\u0d4a-\u0d4d\u0d57\u0d62\u0d63\u0d66-\u0d6f\u0d82\u0d83\u0dca\u0dcf-\u0dd4\u0dd6\u0dd8-\u0ddf\u0de6-\u0def\u0df2\u0df3\u0e31\u0e34-\u0e3a\u0e47-\u0e4e\u0e50-\u0e59\u0eb1\u0eb4-\u0eb9\u0ebb\u0ebc\u0ec8-\u0ecd\u0ed0-\u0ed9\u0f18\u0f19\u0f20-\u0f29\u0f35\u0f37\u0f39\u0f3e\u0f3f\u0f71-\u0f84\u0f86\u0f87\u0f8d-\u0f97\u0f99-\u0fbc\u0fc6\u102b-\u103e\u1040-\u1049\u1056-\u1059\u105e-\u1060\u1062-\u1064\u1067-\u106d\u1071-\u1074\u1082-\u108d\u108f-\u109d\u135d-\u135f\u1369-\u1371\u1712-\u1714\u1732-\u1734\u1752\u1753\u1772\u1773\u17b4-\u17d3\u17dd\u17e0-\u17e9\u180b-\u180d\u1810-\u1819\u18a9\u1920-\u192b\u1930-\u193b\u1946-\u194f\u19d0-\u19da\u1a17-\u1a1b\u1a55-\u1a5e\u1a60-\u1a7c\u1a7f-\u1a89\u1a90-\u1a99\u1ab0-\u1abd\u1b00-\u1b04\u1b34-\u1b44\u1b50-\u1b59\u1b6b-\u1b73\u1b80-\u1b82\u1ba1-\u1bad\u1bb0-\u1bb9\u1be6-\u1bf3\u1c24-\u1c37\u1c40-\u1c49\u1c50-\u1c59\u1cd0-\u1cd2\u1cd4-\u1ce8\u1ced\u1cf2-\u1cf4\u1cf7-\u1cf9\u1dc0-\u1df9\u1dfb-\u1dff\u203f\u2040\u2054\u20d0-\u20dc\u20e1\u20e5-\u20f0\u2cef-\u2cf1\u2d7f\u2de0-\u2dff\u302a-\u302f\u3099\u309a\ua620-\ua629\ua66f\ua674-\ua67d\ua69e\ua69f\ua6f0\ua6f1\ua802\ua806\ua80b\ua823-\ua827\ua880\ua881\ua8b4-\ua8c5\ua8d0-\ua8d9\ua8e0-\ua8f1\ua8ff-\ua909\ua926-\ua92d\ua947-\ua953\ua980-\ua983\ua9b3-\ua9c0\ua9d0-\ua9d9\ua9e5\ua9f0-\ua9f9\uaa29-\uaa36\uaa43\uaa4c\uaa4d\uaa50-\uaa59\uaa7b-\uaa7d\uaab0\uaab2-\uaab4\uaab7\uaab8\uaabe\uaabf\uaac1\uaaeb-\uaaef\uaaf5\uaaf6\uabe3-\uabea\uabec\uabed\uabf0-\uabf9\ufb1e\ufe00-\ufe0f\ufe20-\ufe2f\ufe33\ufe34\ufe4d-\ufe4f\uff10-\uff19\uff3f"
+let 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\u08a0-\u08b4\u08b6-\u08bd\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\u0c60\u0c61\u0c80\u0c85-\u0c8c\u0c8e-\u0c90\u0c92-\u0ca8\u0caa-\u0cb3\u0cb5-\u0cb9\u0cbd\u0cde\u0ce0\u0ce1\u0cf1\u0cf2\u0d05-\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-\u170c\u170e-\u1711\u1720-\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-\u1b4b\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-\u2c2e\u2c30-\u2c5e\u2c60-\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-\u31ba\u31f0-\u31ff\u3400-\u4db5\u4e00-\u9fef\ua000-\ua48c\ua4d0-\ua4fd\ua500-\ua60c\ua610-\ua61f\ua62a\ua62b\ua640-\ua66e\ua67f-\ua69d\ua6a0-\ua6ef\ua717-\ua71f\ua722-\ua788\ua78b-\ua7bf\ua7c2-\ua7c6\ua7f7-\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-\uab67\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"
+let nonASCIIidentifierChars = "\u200c\u200d\xb7\u0300-\u036f\u0387\u0483-\u0487\u0591-\u05bd\u05bf\u05c1\u05c2\u05c4\u05c5\u05c7\u0610-\u061a\u064b-\u0669\u0670\u06d6-\u06dc\u06df-\u06e4\u06e7\u06e8\u06ea-\u06ed\u06f0-\u06f9\u0711\u0730-\u074a\u07a6-\u07b0\u07c0-\u07c9\u07eb-\u07f3\u07fd\u0816-\u0819\u081b-\u0823\u0825-\u0827\u0829-\u082d\u0859-\u085b\u08d3-\u08e1\u08e3-\u0903\u093a-\u093c\u093e-\u094f\u0951-\u0957\u0962\u0963\u0966-\u096f\u0981-\u0983\u09bc\u09be-\u09c4\u09c7\u09c8\u09cb-\u09cd\u09d7\u09e2\u09e3\u09e6-\u09ef\u09fe\u0a01-\u0a03\u0a3c\u0a3e-\u0a42\u0a47\u0a48\u0a4b-\u0a4d\u0a51\u0a66-\u0a71\u0a75\u0a81-\u0a83\u0abc\u0abe-\u0ac5\u0ac7-\u0ac9\u0acb-\u0acd\u0ae2\u0ae3\u0ae6-\u0aef\u0afa-\u0aff\u0b01-\u0b03\u0b3c\u0b3e-\u0b44\u0b47\u0b48\u0b4b-\u0b4d\u0b56\u0b57\u0b62\u0b63\u0b66-\u0b6f\u0b82\u0bbe-\u0bc2\u0bc6-\u0bc8\u0bca-\u0bcd\u0bd7\u0be6-\u0bef\u0c00-\u0c04\u0c3e-\u0c44\u0c46-\u0c48\u0c4a-\u0c4d\u0c55\u0c56\u0c62\u0c63\u0c66-\u0c6f\u0c81-\u0c83\u0cbc\u0cbe-\u0cc4\u0cc6-\u0cc8\u0cca-\u0ccd\u0cd5\u0cd6\u0ce2\u0ce3\u0ce6-\u0cef\u0d00-\u0d03\u0d3b\u0d3c\u0d3e-\u0d44\u0d46-\u0d48\u0d4a-\u0d4d\u0d57\u0d62\u0d63\u0d66-\u0d6f\u0d82\u0d83\u0dca\u0dcf-\u0dd4\u0dd6\u0dd8-\u0ddf\u0de6-\u0def\u0df2\u0df3\u0e31\u0e34-\u0e3a\u0e47-\u0e4e\u0e50-\u0e59\u0eb1\u0eb4-\u0ebc\u0ec8-\u0ecd\u0ed0-\u0ed9\u0f18\u0f19\u0f20-\u0f29\u0f35\u0f37\u0f39\u0f3e\u0f3f\u0f71-\u0f84\u0f86\u0f87\u0f8d-\u0f97\u0f99-\u0fbc\u0fc6\u102b-\u103e\u1040-\u1049\u1056-\u1059\u105e-\u1060\u1062-\u1064\u1067-\u106d\u1071-\u1074\u1082-\u108d\u108f-\u109d\u135d-\u135f\u1369-\u1371\u1712-\u1714\u1732-\u1734\u1752\u1753\u1772\u1773\u17b4-\u17d3\u17dd\u17e0-\u17e9\u180b-\u180d\u1810-\u1819\u18a9\u1920-\u192b\u1930-\u193b\u1946-\u194f\u19d0-\u19da\u1a17-\u1a1b\u1a55-\u1a5e\u1a60-\u1a7c\u1a7f-\u1a89\u1a90-\u1a99\u1ab0-\u1abd\u1b00-\u1b04\u1b34-\u1b44\u1b50-\u1b59\u1b6b-\u1b73\u1b80-\u1b82\u1ba1-\u1bad\u1bb0-\u1bb9\u1be6-\u1bf3\u1c24-\u1c37\u1c40-\u1c49\u1c50-\u1c59\u1cd0-\u1cd2\u1cd4-\u1ce8\u1ced\u1cf4\u1cf7-\u1cf9\u1dc0-\u1df9\u1dfb-\u1dff\u203f\u2040\u2054\u20d0-\u20dc\u20e1\u20e5-\u20f0\u2cef-\u2cf1\u2d7f\u2de0-\u2dff\u302a-\u302f\u3099\u309a\ua620-\ua629\ua66f\ua674-\ua67d\ua69e\ua69f\ua6f0\ua6f1\ua802\ua806\ua80b\ua823-\ua827\ua880\ua881\ua8b4-\ua8c5\ua8d0-\ua8d9\ua8e0-\ua8f1\ua8ff-\ua909\ua926-\ua92d\ua947-\ua953\ua980-\ua983\ua9b3-\ua9c0\ua9d0-\ua9d9\ua9e5\ua9f0-\ua9f9\uaa29-\uaa36\uaa43\uaa4c\uaa4d\uaa50-\uaa59\uaa7b-\uaa7d\uaab0\uaab2-\uaab4\uaab7\uaab8\uaabe\uaabf\uaac1\uaaeb-\uaaef\uaaf5\uaaf6\uabe3-\uabea\uabec\uabed\uabf0-\uabf9\ufb1e\ufe00-\ufe0f\ufe20-\ufe2f\ufe33\ufe34\ufe4d-\ufe4f\uff10-\uff19\uff3f"
const nonASCIIidentifierStart = new RegExp("[" + nonASCIIidentifierStartChars + "]")
const nonASCIIidentifier = new RegExp("[" + nonASCIIidentifierStartChars + nonASCIIidentifierChars + "]")
@@ -42,10 +41,10 @@ nonASCIIidentifierStartChars = nonASCIIidentifierChars = null
// generated by bin/generate-identifier-regex.js
// eslint-disable-next-line comma-spacing
-const astralIdentifierStartCodes = [0,11,2,25,2,18,2,1,2,14,3,13,35,122,70,52,268,28,4,48,48,31,14,29,6,37,11,29,3,35,5,7,2,4,43,157,19,35,5,35,5,39,9,51,157,310,10,21,11,7,153,5,3,0,2,43,2,1,4,0,3,22,11,22,10,30,66,18,2,1,11,21,11,25,71,55,7,1,65,0,16,3,2,2,2,28,43,28,4,28,36,7,2,27,28,53,11,21,11,18,14,17,111,72,56,50,14,50,14,35,477,28,11,0,9,21,190,52,76,44,33,24,27,35,30,0,12,34,4,0,13,47,15,3,22,0,2,0,36,17,2,24,85,6,2,0,2,3,2,14,2,9,8,46,39,7,3,1,3,21,2,6,2,1,2,4,4,0,19,0,13,4,159,52,19,3,54,47,21,1,2,0,185,46,42,3,37,47,21,0,60,42,86,26,230,43,117,63,32,0,257,0,11,39,8,0,22,0,12,39,3,3,20,0,35,56,264,8,2,36,18,0,50,29,113,6,2,1,2,37,22,0,26,5,2,1,2,31,15,0,328,18,270,921,103,110,18,195,2749,1070,4050,582,8634,568,8,30,114,29,19,47,17,3,32,20,6,18,689,63,129,68,12,0,67,12,65,1,31,6129,15,754,9486,286,82,395,2309,106,6,12,4,8,8,9,5991,84,2,70,2,1,3,0,3,1,3,3,2,11,2,0,2,6,2,64,2,3,3,7,2,6,2,27,2,3,2,4,2,0,4,6,2,339,3,24,2,24,2,30,2,24,2,30,2,24,2,30,2,24,2,30,2,24,2,7,4149,196,60,67,1213,3,2,26,2,1,2,0,3,0,2,9,2,3,2,0,2,0,7,0,5,0,2,0,2,0,2,2,2,1,2,0,3,0,2,0,2,0,2,0,2,0,2,1,2,0,3,3,2,6,2,3,2,3,2,0,2,9,2,16,6,2,2,4,2,16,4421,42710,42,4148,12,221,3,5761,15,7472,3104,541]
+const astralIdentifierStartCodes = [0,11,2,25,2,18,2,1,2,14,3,13,35,122,70,52,268,28,4,48,48,31,14,29,6,37,11,29,3,35,5,7,2,4,43,157,19,35,5,35,5,39,9,51,157,310,10,21,11,7,153,5,3,0,2,43,2,1,4,0,3,22,11,22,10,30,66,18,2,1,11,21,11,25,71,55,7,1,65,0,16,3,2,2,2,28,43,28,4,28,36,7,2,27,28,53,11,21,11,18,14,17,111,72,56,50,14,50,14,35,477,28,11,0,9,21,155,22,13,52,76,44,33,24,27,35,30,0,12,34,4,0,13,47,15,3,22,0,2,0,36,17,2,24,85,6,2,0,2,3,2,14,2,9,8,46,39,7,3,1,3,21,2,6,2,1,2,4,4,0,19,0,13,4,159,52,19,3,21,0,33,47,21,1,2,0,185,46,42,3,37,47,21,0,60,42,14,0,72,26,230,43,117,63,32,0,161,7,3,38,17,0,2,0,29,0,11,39,8,0,22,0,12,45,20,0,35,56,264,8,2,36,18,0,50,29,113,6,2,1,2,37,22,0,26,5,2,1,2,31,15,0,328,18,270,921,103,110,18,195,2749,1070,4050,582,8634,568,8,30,114,29,19,47,17,3,32,20,6,18,689,63,129,74,6,0,67,12,65,1,2,0,29,6135,9,754,9486,286,50,2,18,3,9,395,2309,106,6,12,4,8,8,9,5991,84,2,70,2,1,3,0,3,1,3,3,2,11,2,0,2,6,2,64,2,3,3,7,2,6,2,27,2,3,2,4,2,0,4,6,2,339,3,24,2,24,2,30,2,24,2,30,2,24,2,30,2,24,2,30,2,24,2,7,2357,44,11,6,17,0,370,43,1301,196,60,67,8,0,1205,3,2,26,2,1,2,0,3,0,2,9,2,3,2,0,2,0,7,0,5,0,2,0,2,0,2,2,2,1,2,0,3,0,2,0,2,0,2,0,2,0,2,1,2,0,3,3,2,6,2,3,2,3,2,0,2,9,2,16,6,2,2,4,2,16,4421,42710,42,4148,12,221,3,5761,15,7472,3104,541]
// eslint-disable-next-line comma-spacing
-const astralIdentifierCodes = [509,0,227,0,150,4,294,9,1368,2,2,1,6,3,41,2,5,0,166,1,574,3,9,9,525,10,176,2,54,14,32,9,16,3,46,10,54,9,7,2,37,13,2,9,6,1,45,0,13,2,49,13,9,3,4,9,83,11,7,0,161,11,6,9,7,3,56,1,2,6,3,1,3,2,10,0,11,1,3,6,4,4,193,17,10,9,5,0,82,19,13,9,214,6,3,8,28,1,83,16,16,9,82,12,9,9,84,14,5,9,243,14,166,9,280,9,41,6,2,3,9,0,10,10,47,15,406,7,2,7,17,9,57,21,2,13,123,5,4,0,2,1,2,6,2,0,9,9,49,4,2,1,2,4,9,9,330,3,19306,9,135,4,60,6,26,9,1016,45,17,3,19723,1,5319,4,4,5,9,7,3,6,31,3,149,2,1418,49,513,54,5,49,9,0,15,0,23,4,2,14,1361,6,2,16,3,6,2,1,2,4,2214,6,110,6,6,9,792487,239]
+const astralIdentifierCodes = [509,0,227,0,150,4,294,9,1368,2,2,1,6,3,41,2,5,0,166,1,574,3,9,9,525,10,176,2,54,14,32,9,16,3,46,10,54,9,7,2,37,13,2,9,6,1,45,0,13,2,49,13,9,3,4,9,83,11,7,0,161,11,6,9,7,3,56,1,2,6,3,1,3,2,10,0,11,1,3,6,4,4,193,17,10,9,5,0,82,19,13,9,214,6,3,8,28,1,83,16,16,9,82,12,9,9,84,14,5,9,243,14,166,9,232,6,3,6,4,0,29,9,41,6,2,3,9,0,10,10,47,15,406,7,2,7,17,9,57,21,2,13,123,5,4,0,2,1,2,6,2,0,9,9,49,4,2,1,2,4,9,9,330,3,19306,9,135,4,60,6,26,9,1014,0,2,54,8,3,19723,1,5319,4,4,5,9,7,3,6,31,3,149,2,1418,49,513,54,5,49,9,0,15,0,23,4,2,14,1361,6,2,16,3,6,2,1,2,4,262,6,10,9,419,13,1495,6,110,6,6,9,792487,239]
// This has a complexity linear to the value of the code. The
// assumption is that looking up astral identifier characters is
diff --git a/acorn/src/index.js b/acorn/src/index.js
index 510648e..1fb6877 100644
--- a/acorn/src/index.js
+++ b/acorn/src/index.js
@@ -32,7 +32,7 @@ export {isIdentifierChar, isIdentifierStart} from "./identifier"
export {Token} from "./tokenize"
export {isNewLine, lineBreak, lineBreakG, nonASCIIwhitespace} from "./whitespace"
-export const version = "6.1.1"
+export const version = "6.2.1"
// The main exported interface (under `self.acorn` when in the
// browser) is a `parse` function that takes a code string and
diff --git a/acorn/src/lval.js b/acorn/src/lval.js
index dbd220f..8ad4b26 100644
--- a/acorn/src/lval.js
+++ b/acorn/src/lval.js
@@ -1,7 +1,7 @@
import {types as tt} from "./tokentype"
import {Parser} from "./state"
import {has} from "./util"
-import {BIND_NONE, BIND_OUTSIDE} from "./scopeflags"
+import {BIND_NONE, BIND_OUTSIDE, BIND_LEXICAL} from "./scopeflags"
const pp = Parser.prototype
@@ -189,6 +189,8 @@ pp.parseMaybeDefault = function(startPos, startLoc, left) {
pp.checkLVal = function(expr, bindingType = BIND_NONE, checkClashes) {
switch (expr.type) {
case "Identifier":
+ if (bindingType === BIND_LEXICAL && expr.name === "let")
+ this.raiseRecoverable(expr.start, "let is disallowed as a lexically bound name")
if (this.strict && this.reservedWordsStrictBind.test(expr.name))
this.raiseRecoverable(expr.start, (bindingType ? "Binding " : "Assigning to ") + expr.name + " in strict mode")
if (checkClashes) {
diff --git a/acorn/src/regexp.js b/acorn/src/regexp.js
index 00a4dc2..ee19bcf 100644
--- a/acorn/src/regexp.js
+++ b/acorn/src/regexp.js
@@ -9,7 +9,7 @@ export class RegExpValidationState {
constructor(parser) {
this.parser = parser
this.validFlags = `gim${parser.options.ecmaVersion >= 6 ? "uy" : ""}${parser.options.ecmaVersion >= 9 ? "s" : ""}`
- this.unicodeProperties = UNICODE_PROPERTY_VALUES[parser.options.ecmaVersion >= 10 ? 10 : parser.options.ecmaVersion]
+ this.unicodeProperties = UNICODE_PROPERTY_VALUES[parser.options.ecmaVersion >= 11 ? 11 : parser.options.ecmaVersion]
this.source = ""
this.flags = ""
this.start = 0
diff --git a/acorn/src/state.js b/acorn/src/state.js
index dce754f..73e49b9 100644
--- a/acorn/src/state.js
+++ b/acorn/src/state.js
@@ -11,7 +11,7 @@ export class Parser {
this.sourceFile = options.sourceFile
this.keywords = wordsRegexp(keywords[options.ecmaVersion >= 6 ? 6 : 5])
let reserved = ""
- if (!options.allowReserved) {
+ if (options.allowReserved !== true) {
for (let v = options.ecmaVersion;; v--)
if (reserved = reservedWords[v]) break
if (options.sourceType === "module") reserved += " await"
diff --git a/acorn/src/statement.js b/acorn/src/statement.js
index 23a9038..d423b59 100644
--- a/acorn/src/statement.js
+++ b/acorn/src/statement.js
@@ -120,6 +120,14 @@ pp.parseStatement = function(context, topLevel, exports) {
case tt.semi: return this.parseEmptyStatement(node)
case tt._export:
case tt._import:
+ if (this.options.ecmaVersion > 10 && starttype === tt._import) {
+ skipWhiteSpace.lastIndex = this.pos
+ let skip = skipWhiteSpace.exec(this.input)
+ let next = this.pos + skip[0].length, nextCh = this.input.charCodeAt(next)
+ if (nextCh === 40) // '('
+ return this.parseExpressionStatement(node, this.parseExpression())
+ }
+
if (!this.options.allowImportExportEverywhere) {
if (!topLevel)
this.raise(this.start, "'import' and 'export' may only appear at the top level")
@@ -215,8 +223,7 @@ pp.parseForStatement = function(node) {
this.next()
this.parseVar(init, true, kind)
this.finishNode(init, "VariableDeclaration")
- if ((this.type === tt._in || (this.options.ecmaVersion >= 6 && this.isContextual("of"))) && init.declarations.length === 1 &&
- !(kind !== "var" && init.declarations[0].init)) {
+ if ((this.type === tt._in || (this.options.ecmaVersion >= 6 && this.isContextual("of"))) && init.declarations.length === 1) {
if (this.options.ecmaVersion >= 9) {
if (this.type === tt._in) {
if (awaitAt > -1) this.unexpected(awaitAt)
@@ -446,21 +453,36 @@ pp.parseFor = function(node, init) {
// same from parser's perspective.
pp.parseForIn = function(node, init) {
- let type = this.type === tt._in ? "ForInStatement" : "ForOfStatement"
+ const isForIn = this.type === tt._in
this.next()
- if (type === "ForInStatement") {
- if (init.type === "AssignmentPattern" ||
- (init.type === "VariableDeclaration" && init.declarations[0].init != null &&
- (this.strict || init.declarations[0].id.type !== "Identifier")))
- this.raise(init.start, "Invalid assignment in for-in loop head")
+
+ if (
+ init.type === "VariableDeclaration" &&
+ init.declarations[0].init != null &&
+ (
+ !isForIn ||
+ this.options.ecmaVersion < 8 ||
+ this.strict ||
+ init.kind !== "var" ||
+ init.declarations[0].id.type !== "Identifier"
+ )
+ ) {
+ this.raise(
+ init.start,
+ `${
+ isForIn ? "for-in" : "for-of"
+ } loop variable declaration may not have an initializer`
+ )
+ } else if (init.type === "AssignmentPattern") {
+ this.raise(init.start, "Invalid left-hand side in for-loop")
}
node.left = init
- node.right = type === "ForInStatement" ? this.parseExpression() : this.parseMaybeAssign()
+ node.right = isForIn ? this.parseExpression() : this.parseMaybeAssign()
this.expect(tt.parenR)
node.body = this.parseStatement("for")
this.exitScope()
this.labels.pop()
- return this.finishNode(node, type)
+ return this.finishNode(node, isForIn ? "ForInStatement" : "ForOfStatement")
}
// Parse a list of variable declarations.
@@ -487,9 +509,6 @@ pp.parseVar = function(node, isFor, kind) {
}
pp.parseVarId = function(decl, kind) {
- if ((kind === "const" || kind === "let") && this.isContextual("let")) {
- this.raiseRecoverable(this.start, "let is disallowed as a lexically bound name")
- }
decl.id = this.parseBindingAtom()
this.checkLVal(decl.id, kind === "var" ? BIND_VAR : BIND_LEXICAL, false)
}
diff --git a/acorn/src/tokenize.js b/acorn/src/tokenize.js
index acb9bf6..f9f6b2f 100644
--- a/acorn/src/tokenize.js
+++ b/acorn/src/tokenize.js
@@ -427,10 +427,14 @@ pp.readInt = function(radix, len) {
}
pp.readRadixNumber = function(radix) {
+ let start = this.pos
this.pos += 2 // 0x
let val = this.readInt(radix)
if (val == null) this.raise(this.start + 2, "Expected number in radix " + radix)
- if (isIdentifierStart(this.fullCharCodeAtPos())) this.raise(this.pos, "Identifier directly after number")
+ if (this.options.ecmaVersion >= 11 && this.input.charCodeAt(this.pos) === 110) {
+ val = typeof BigInt !== "undefined" ? BigInt(this.input.slice(start, this.pos)) : null
+ ++this.pos
+ } else if (isIdentifierStart(this.fullCharCodeAtPos())) this.raise(this.pos, "Identifier directly after number")
return this.finishToken(tt.num, val)
}
@@ -443,6 +447,13 @@ pp.readNumber = function(startsWithDot) {
if (octal && this.strict) this.raise(start, "Invalid number")
if (octal && /[89]/.test(this.input.slice(start, this.pos))) octal = false
let next = this.input.charCodeAt(this.pos)
+ if (!octal && !startsWithDot && this.options.ecmaVersion >= 11 && next === 110) {
+ let str = this.input.slice(start, this.pos)
+ let val = typeof BigInt !== "undefined" ? BigInt(str) : null
+ ++this.pos
+ if (isIdentifierStart(this.fullCharCodeAtPos())) this.raise(this.pos, "Identifier directly after number")
+ return this.finishToken(tt.num, val)
+ }
if (next === 46 && !octal) { // '.'
++this.pos
this.readInt(10)
diff --git a/acorn/src/tokentype.js b/acorn/src/tokentype.js
index 76b145f..7a8c48a 100644
--- a/acorn/src/tokentype.js
+++ b/acorn/src/tokentype.js
@@ -136,7 +136,7 @@ export const types = {
_class: kw("class", startsExpr),
_extends: kw("extends", beforeExpr),
_export: kw("export"),
- _import: kw("import"),
+ _import: kw("import", startsExpr),
_null: kw("null", startsExpr),
_true: kw("true", startsExpr),
_false: kw("false", startsExpr),
diff --git a/acorn/src/unicode-property-data.js b/acorn/src/unicode-property-data.js
index a2c1258..967ed1a 100644
--- a/acorn/src/unicode-property-data.js
+++ b/acorn/src/unicode-property-data.js
@@ -6,9 +6,12 @@ import {wordsRegexp} from "./util.js"
// #table-binary-unicode-properties
const ecma9BinaryProperties = "ASCII ASCII_Hex_Digit AHex Alphabetic Alpha Any Assigned Bidi_Control Bidi_C Bidi_Mirrored Bidi_M Case_Ignorable CI Cased Changes_When_Casefolded CWCF Changes_When_Casemapped CWCM Changes_When_Lowercased CWL Changes_When_NFKC_Casefolded CWKCF Changes_When_Titlecased CWT Changes_When_Uppercased CWU Dash Default_Ignorable_Code_Point DI Deprecated Dep Diacritic Dia Emoji Emoji_Component Emoji_Modifier Emoji_Modifier_Base Emoji_Presentation Extender Ext Grapheme_Base Gr_Base Grapheme_Extend Gr_Ext Hex_Digit Hex IDS_Binary_Operator IDSB IDS_Trinary_Operator IDST ID_Continue IDC ID_Start IDS Ideographic Ideo Join_Control Join_C Logical_Order_Exception LOE Lowercase Lower Math Noncharacter_Code_Point NChar Pattern_Syntax Pat_Syn Pattern_White_Space Pat_WS Quotation_Mark QMark Radical Regional_Indicator RI Sentence_Terminal STerm Soft_Dotted SD Terminal_Punctuation Term Unified_Ideograph UIdeo Uppercase Upper Variation_Selector VS White_Space space XID_Continue XIDC XID_Start XIDS"
+const ecma10BinaryProperties = ecma9BinaryProperties + " Extended_Pictographic"
+const ecma11BinaryProperties = ecma10BinaryProperties
const unicodeBinaryProperties = {
9: ecma9BinaryProperties,
- 10: ecma9BinaryProperties + " Extended_Pictographic"
+ 10: ecma10BinaryProperties,
+ 11: ecma11BinaryProperties
}
// #table-unicode-general-category-values
@@ -16,9 +19,12 @@ const unicodeGeneralCategoryValues = "Cased_Letter LC Close_Punctuation Pe Conne
// #table-unicode-script-values
const ecma9ScriptValues = "Adlam Adlm Ahom Ahom Anatolian_Hieroglyphs Hluw Arabic Arab Armenian Armn Avestan Avst Balinese Bali Bamum Bamu Bassa_Vah Bass Batak Batk Bengali Beng Bhaiksuki Bhks Bopomofo Bopo Brahmi Brah Braille Brai Buginese Bugi Buhid Buhd Canadian_Aboriginal Cans Carian Cari Caucasian_Albanian Aghb Chakma Cakm Cham Cham Cherokee Cher Common Zyyy Coptic Copt Qaac Cuneiform Xsux Cypriot Cprt Cyrillic Cyrl Deseret Dsrt Devanagari Deva Duployan Dupl Egyptian_Hieroglyphs Egyp Elbasan Elba Ethiopic Ethi Georgian Geor Glagolitic Glag Gothic Goth Grantha Gran Greek Grek Gujarati Gujr Gurmukhi Guru Han Hani Hangul Hang Hanunoo Hano Hatran Hatr Hebrew Hebr Hiragana Hira Imperial_Aramaic Armi Inherited Zinh Qaai Inscriptional_Pahlavi Phli Inscriptional_Parthian Prti Javanese Java Kaithi Kthi Kannada Knda Katakana Kana Kayah_Li Kali Kharoshthi Khar Khmer Khmr Khojki Khoj Khudawadi Sind Lao Laoo Latin Latn Lepcha Lepc Limbu Limb Linear_A Lina Linear_B Linb Lisu Lisu Lycian Lyci Lydian Lydi Mahajani Mahj Malayalam Mlym Mandaic Mand Manichaean Mani Marchen Marc Masaram_Gondi Gonm Meetei_Mayek Mtei Mende_Kikakui Mend Meroitic_Cursive Merc Meroitic_Hieroglyphs Mero Miao Plrd Modi Modi Mongolian Mong Mro Mroo Multani Mult Myanmar Mymr Nabataean Nbat New_Tai_Lue Talu Newa Newa Nko Nkoo Nushu Nshu Ogham Ogam Ol_Chiki Olck Old_Hungarian Hung Old_Italic Ital Old_North_Arabian Narb Old_Permic Perm Old_Persian Xpeo Old_South_Arabian Sarb Old_Turkic Orkh Oriya Orya Osage Osge Osmanya Osma Pahawh_Hmong Hmng Palmyrene Palm Pau_Cin_Hau Pauc Phags_Pa Phag Phoenician Phnx Psalter_Pahlavi Phlp Rejang Rjng Runic Runr Samaritan Samr Saurashtra Saur Sharada Shrd Shavian Shaw Siddham Sidd SignWriting Sgnw Sinhala Sinh Sora_Sompeng Sora Soyombo Soyo Sundanese Sund Syloti_Nagri Sylo Syriac Syrc Tagalog Tglg Tagbanwa Tagb Tai_Le Tale Tai_Tham Lana Tai_Viet Tavt Takri Takr Tamil Taml Tangut Tang Telugu Telu Thaana Thaa Thai Thai Tibetan Tibt Tifinagh Tfng Tirhuta Tirh Ugaritic Ugar Vai Vaii Warang_Citi Wara Yi Yiii Zanabazar_Square Zanb"
+const ecma10ScriptValues = ecma9ScriptValues + " Dogra Dogr Gunjala_Gondi Gong Hanifi_Rohingya Rohg Makasar Maka Medefaidrin Medf Old_Sogdian Sogo Sogdian Sogd"
+const ecma11ScriptValues = ecma10ScriptValues + " Elymaic Elym Nandinagari Nand Nyiakeng_Puachue_Hmong Hmnp Wancho Wcho"
const unicodeScriptValues = {
9: ecma9ScriptValues,
- 10: ecma9ScriptValues + " Dogra Dogr Gunjala_Gondi Gong Hanifi_Rohingya Rohg Makasar Maka Medefaidrin Medf Old_Sogdian Sogo Sogdian Sogd"
+ 10: ecma10ScriptValues,
+ 11: ecma11ScriptValues
}
const data = {}
@@ -38,5 +44,6 @@ function buildUnicodeData(ecmaVersion) {
}
buildUnicodeData(9)
buildUnicodeData(10)
+buildUnicodeData(11)
export default data
diff --git a/bin/generate-identifier-regex.js b/bin/generate-identifier-regex.js
index 07e4540..d661d72 100644
--- a/bin/generate-identifier-regex.js
+++ b/bin/generate-identifier-regex.js
@@ -18,7 +18,7 @@ function search(arr, ch, starting) {
function esc(code) {
let hex = code.toString(16)
- return hex.length <= 2 ? hex.padStart(2, "0") : "\\u" + hex.padStart(4, "0")
+ return hex.length <= 2 ? "\\x" + hex.padStart(2, "0") : "\\u" + hex.padStart(4, "0")
}
function generate(chars) {
diff --git a/node-acorn-bigint/CHANGELOG.md b/node-acorn-bigint/CHANGELOG.md
index f0dbe2f..1d12d70 100644
--- a/node-acorn-bigint/CHANGELOG.md
+++ b/node-acorn-bigint/CHANGELOG.md
@@ -1,3 +1,7 @@
+## 0.4.0 (2019-04-04)
+
+* Make compatible with acorn-numeric-separator
+
## 0.3.1 (2018-10-06)
* Fix creation of BigInt values everywhere (Thanks, Gus Caplan!)
diff --git a/node-acorn-bigint/index.js b/node-acorn-bigint/index.js
index 236bdf7..23e0a20 100644
--- a/node-acorn-bigint/index.js
+++ b/node-acorn-bigint/index.js
@@ -8,7 +8,7 @@ module.exports = function(Parser) {
return class extends Parser {
parseLiteral(value) {
const node = super.parseLiteral(value)
- if (node.raw.charCodeAt(node.raw.length - 1) == 110) node.bigint = node.raw
+ if (node.raw.charCodeAt(node.raw.length - 1) == 110) node.bigint = this.getNumberInput(node.start, node.end)
return node
}
@@ -18,7 +18,7 @@ module.exports = function(Parser) {
let val = this.readInt(radix)
if (val === null) this.raise(this.start + 2, `Expected number in radix ${radix}`)
if (this.input.charCodeAt(this.pos) == 110) {
- let str = this.input.slice(start, this.pos)
+ let str = this.getNumberInput(start, this.pos)
val = typeof BigInt !== "undefined" ? BigInt(str) : null
++this.pos
} else if (isIdentifierStart(this.fullCharCodeAtPos())) this.raise(this.pos, "Identifier directly after number")
@@ -44,10 +44,16 @@ module.exports = function(Parser) {
return super.readNumber(startsWithDot)
}
- let str = this.input.slice(start, this.pos)
+ let str = this.getNumberInput(start, this.pos)
let val = typeof BigInt !== "undefined" ? BigInt(str) : null
++this.pos
return this.finishToken(tt.num, val)
}
+
+ // This is basically a hook for acorn-numeric-separator
+ getNumberInput(start, end) {
+ if (super.getNumberInput) return super.getNumberInput(start, end)
+ return this.input.slice(start, end)
+ }
}
}
diff --git a/node-acorn-bigint/package.json b/node-acorn-bigint/package.json
index 16afd3a..8686986 100644
--- a/node-acorn-bigint/package.json
+++ b/node-acorn-bigint/package.json
@@ -21,13 +21,13 @@
"peerDependencies": {
"acorn": "^6.0.0"
},
- "version": "0.3.1",
+ "version": "0.4.0",
"devDependencies": {
- "acorn": "^6.0.0",
- "eslint": "^5.5.0",
- "eslint-plugin-node": "^7.0.1",
- "mocha": "^5.2.0",
- "test262": "git+https://github.com/tc39/test262.git#e286bfa00086226f781a3ed4e0a6295634b8ed11",
- "test262-parser-runner": "^0.4.0"
+ "acorn": "^6.1.1",
+ "eslint": "^5.16.0",
+ "eslint-plugin-node": "^8.0.1",
+ "mocha": "^6.0.2",
+ "test262": "git+https://github.com/tc39/test262.git#611919174ffe060503691a0c7e3eb2a65b646124",
+ "test262-parser-runner": "^0.5.0"
}
}
diff --git a/node-acorn-class-fields/.eslintrc.json b/node-acorn-class-fields/.eslintrc.json
new file mode 100644
index 0000000..3981ed4
--- /dev/null
+++ b/node-acorn-class-fields/.eslintrc.json
@@ -0,0 +1,294 @@
+{
+ "env": {
+ "es6": true,
+ "node": true
+ },
+ "extends": ["eslint:recommended", "plugin:node/recommended"],
+ "plugins": ["node"],
+ "rules": {
+ "accessor-pairs": "error",
+ "array-bracket-newline": "off",
+ "array-bracket-spacing": "off",
+ "array-callback-return": "error",
+ "array-element-newline": "off",
+ "arrow-body-style": "error",
+ "arrow-parens": [
+ "error",
+ "as-needed"
+ ],
+ "arrow-spacing": [
+ "error",
+ {
+ "after": true,
+ "before": true
+ }
+ ],
+ "block-scoped-var": "error",
+ "block-spacing": "off",
+ "brace-style": [
+ "error",
+ "1tbs",
+ {
+ "allowSingleLine": true
+ }
+ ],
+ "callback-return": "error",
+ "camelcase": "error",
+ "capitalized-comments": "off",
+ "class-methods-use-this": "error",
+ "comma-dangle": "off",
+ "comma-spacing": [
+ "error",
+ {
+ "after": true,
+ "before": false
+ }
+ ],
+ "comma-style": [
+ "error",
+ "last"
+ ],
+ "complexity": "off",
+ "computed-property-spacing": [
+ "error",
+ "never"
+ ],
+ "consistent-return": "error",
+ "consistent-this": "error",
+ "curly": [ "error", "multi-line" ],
+ "default-case": "error",
+ "dot-location": "error",
+ "dot-notation": [
+ "error",
+ {
+ "allowKeywords": true
+ }
+ ],
+ "eol-last": "error",
+ "eqeqeq": "off",
+ "for-direction": "error",
+ "func-call-spacing": "error",
+ "func-name-matching": "error",
+ "func-names": [
+ "error",
+ "never"
+ ],
+ "func-style": [
+ "error",
+ "declaration",
+ { "allowArrowFunctions": true }
+ ],
+ "function-paren-newline": "off",
+ "generator-star-spacing": "error",
+ "getter-return": "error",
+ "global-require": "error",
+ "guard-for-in": "error",
+ "handle-callback-err": "error",
+ "id-blacklist": "error",
+ "id-length": "off",
+ "id-match": "error",
+ "implicit-arrow-linebreak": [
+ "error",
+ "beside"
+ ],
+ "indent": ["error", 2],
+ "indent-legacy": "off",
+ "init-declarations": "off",
+ "jsx-quotes": "error",
+ "key-spacing": "error",
+ "keyword-spacing": [
+ "error",
+ {
+ "after": true,
+ "before": true
+ }
+ ],
+ "line-comment-position": "off",
+ "linebreak-style": [
+ "error",
+ "unix"
+ ],
+ "lines-around-comment": "error",
+ "lines-around-directive": "error",
+ "lines-between-class-members": "error",
+ "max-depth": "error",
+ "max-len": "off",
+ "max-lines": "off",
+ "max-nested-callbacks": "error",
+ "max-params": "off",
+ "max-statements": "off",
+ "max-statements-per-line": "off",
+ "multiline-comment-style": [
+ "error",
+ "separate-lines"
+ ],
+ "new-cap": "error",
+ "new-parens": "error",
+ "newline-after-var": "off",
+ "newline-before-return": "off",
+ "newline-per-chained-call": "off",
+ "no-alert": "error",
+ "no-array-constructor": "error",
+ "no-await-in-loop": "error",
+ "no-bitwise": "error",
+ "no-buffer-constructor": "error",
+ "no-caller": "error",
+ "no-catch-shadow": "error",
+ "no-confusing-arrow": "error",
+ "no-continue": "off",
+ "no-div-regex": "error",
+ "no-duplicate-imports": "error",
+ "no-else-return": "error",
+ "no-empty-function": "error",
+ "no-eq-null": "error",
+ "no-eval": "error",
+ "no-extend-native": "error",
+ "no-extra-bind": "error",
+ "no-extra-label": "error",
+ "no-extra-parens": "off",
+ "no-floating-decimal": "error",
+ "no-implicit-coercion": "error",
+ "no-implicit-globals": "error",
+ "no-implied-eval": "error",
+ "no-inline-comments": "off",
+ "no-invalid-this": "off",
+ "no-iterator": "error",
+ "no-label-var": "error",
+ "no-labels": "error",
+ "no-lone-blocks": "error",
+ "no-lonely-if": "off",
+ "no-loop-func": "error",
+ "no-magic-numbers": "off",
+ "no-mixed-operators": "off",
+ "no-mixed-requires": "error",
+ "no-multi-assign": "error",
+ "no-multi-spaces": "error",
+ "no-multi-str": "error",
+ "no-multiple-empty-lines": ["error", { "max": 1, "maxEOF": 0, "maxBOF": 0 }],
+ "no-native-reassign": "error",
+ "no-negated-condition": "off",
+ "no-negated-in-lhs": "error",
+ "no-nested-ternary": "error",
+ "no-new": "error",
+ "no-new-func": "error",
+ "no-new-object": "error",
+ "no-new-require": "error",
+ "no-new-wrappers": "error",
+ "no-octal-escape": "error",
+ "no-param-reassign": "off",
+ "no-path-concat": "error",
+ "no-plusplus": "off",
+ "no-process-env": "error",
+ "no-process-exit": "error",
+ "no-proto": "error",
+ "no-prototype-builtins": "error",
+ "no-restricted-globals": "error",
+ "no-restricted-imports": "error",
+ "no-restricted-modules": "error",
+ "no-restricted-properties": "error",
+ "no-restricted-syntax": "error",
+ "no-return-assign": "error",
+ "no-return-await": "error",
+ "no-script-url": "error",
+ "no-self-compare": "error",
+ "no-sequences": "error",
+ "no-shadow": "error",
+ "no-shadow-restricted-names": "error",
+ "no-spaced-func": "error",
+ "no-sync": [
+ "error",
+ {
+ "allowAtRootLevel": true
+ }
+ ],
+ "no-tabs": "error",
+ "no-template-curly-in-string": "error",
+ "no-ternary": "off",
+ "no-throw-literal": "error",
+ "no-trailing-spaces": "error",
+ "no-undef-init": "error",
+ "no-undefined": "error",
+ "no-underscore-dangle": "off",
+ "no-unmodified-loop-condition": "error",
+ "no-unneeded-ternary": "error",
+ "no-unused-expressions": "error",
+ "no-unused-vars": ["error", {"argsIgnorePattern": "^_"}],
+ "no-use-before-define": "error",
+ "no-useless-call": "error",
+ "no-useless-computed-key": "error",
+ "no-useless-concat": "error",
+ "no-useless-constructor": "error",
+ "no-useless-rename": "error",
+ "no-useless-return": "error",
+ "no-var": "error",
+ "no-void": "error",
+ "no-warning-comments": "warn",
+ "no-whitespace-before-property": "error",
+ "no-with": "error",
+ "nonblock-statement-body-position": [
+ "error",
+ "any"
+ ],
+ "object-curly-newline": "off",
+ "object-curly-spacing": "off",
+ "object-property-newline": "off",
+ "object-shorthand": "off",
+ "one-var": "off",
+ "one-var-declaration-per-line": "off",
+ "operator-assignment": "error",
+ "operator-linebreak": "error",
+ "padded-blocks": "off",
+ "padding-line-between-statements": "error",
+ "prefer-arrow-callback": "off",
+ "prefer-const": "off",
+ "prefer-destructuring": "off",
+ "prefer-numeric-literals": "error",
+ "prefer-promise-reject-errors": "error",
+ "prefer-reflect": "off",
+ "prefer-rest-params": "off",
+ "prefer-spread": "error",
+ "prefer-template": "error",
+ "quote-props": ["error", "as-needed"],
+ "quotes": ["error", "double"],
+ "radix": "error",
+ "require-await": "error",
+ "require-jsdoc": "off",
+ "rest-spread-spacing": "error",
+ "semi": ["error", "never"],
+ "semi-spacing": "error",
+ "semi-style": [
+ "error",
+ "last"
+ ],
+ "sort-imports": "error",
+ "sort-keys": "off",
+ "sort-vars": "off",
+ "space-before-blocks": "error",
+ "space-before-function-paren": "off",
+ "space-in-parens": [
+ "error",
+ "never"
+ ],
+ "space-infix-ops": "error",
+ "space-unary-ops": "error",
+ "spaced-comment": "off",
+ "strict": "error",
+ "switch-colon-spacing": "error",
+ "symbol-description": "error",
+ "template-curly-spacing": "error",
+ "template-tag-spacing": "error",
+ "unicode-bom": [
+ "error",
+ "never"
+ ],
+ "valid-jsdoc": "error",
+ "vars-on-top": "off",
+ "wrap-regex": "error",
+ "yield-star-spacing": "error",
+ "yoda": [
+ "error",
+ "never"
+ ],
+ "node/no-unpublished-require": "off"
+ }
+}
diff --git a/node-acorn-class-fields/.gitignore b/node-acorn-class-fields/.gitignore
new file mode 100644
index 0000000..c2658d7
--- /dev/null
+++ b/node-acorn-class-fields/.gitignore
@@ -0,0 +1 @@
+node_modules/
diff --git a/node-acorn-class-fields/CHANGELOG.md b/node-acorn-class-fields/CHANGELOG.md
new file mode 100644
index 0000000..de2c66b
--- /dev/null
+++ b/node-acorn-class-fields/CHANGELOG.md
@@ -0,0 +1,28 @@
+## 0.3.1 (2019-02-09)
+
+* Restore compatibility with acorn-private-methods
+
+## 0.3.0 (2019-02-09)
+
+* Require acorn >= 6.1.0
+
+## 0.2.1 (2018-11-06)
+
+* Adapt to changes in acorn 6.0.3
+
+## 0.2.0 (2018-09-14)
+
+* Update to new acorn 6 interface
+* Change license to MIT
+
+## 0.1.2 (2018-01-26)
+
+* Don't accept whitespace between hash and private name
+
+## 0.1.1 (2018-01-17)
+
+* Correctly parse all fields named `async`
+
+## 0.1.0 (2018-01-13)
+
+Initial release
diff --git a/node-acorn-class-fields/LICENSE b/node-acorn-class-fields/LICENSE
new file mode 100644
index 0000000..7c2b27a
--- /dev/null
+++ b/node-acorn-class-fields/LICENSE
@@ -0,0 +1,19 @@
+Copyright (C) 2017-2018 by Adrian Heine
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+THE SOFTWARE.
diff --git a/node-acorn-class-fields/README.md b/node-acorn-class-fields/README.md
new file mode 100644
index 0000000..60f3463
--- /dev/null
+++ b/node-acorn-class-fields/README.md
@@ -0,0 +1,21 @@
+# Class fields support for Acorn
+
+[![NPM version](https://img.shields.io/npm/v/acorn-class-fields.svg)](https://www.npmjs.org/package/acorn-class-fields)
+
+This is a plugin for [Acorn](http://marijnhaverbeke.nl/acorn/) - a tiny, fast JavaScript parser, written completely in JavaScript.
+
+It implements support for class fields as defined in the stage 3 proposal [Class field declarations for JavaScript](https://github.com/tc39/proposal-class-fields). The emitted AST follows [an ESTree proposal](https://github.com/estree/estree/pull/180).
+
+## Usage
+
+This module provides a plugin that can be used to extend the Acorn `Parser` class:
+
+```javascript
+const {Parser} = require('acorn');
+const classFields = require('acorn-class-fields');
+Parser.extend(classFields).parse('class X { x = 0 }');
+```
+
+## License
+
+This plugin is released under an [MIT License](./LICENSE).
diff --git a/node-acorn-class-fields/index.js b/node-acorn-class-fields/index.js
new file mode 100644
index 0000000..b9372bb
--- /dev/null
+++ b/node-acorn-class-fields/index.js
@@ -0,0 +1,61 @@
+"use strict"
+
+const skipWhiteSpace = /(?:\s|\/\/.*|\/\*[^]*?\*\/)*/g
+
+const acorn = require("acorn")
+const tt = acorn.tokTypes
+const privateClassElements = require("acorn-private-class-elements")
+
+function maybeParseFieldValue(field) {
+ if (this.eat(tt.eq)) {
+ const oldInFieldValue = this._inFieldValue
+ this._inFieldValue = true
+ field.value = this.parseExpression()
+ this._inFieldValue = oldInFieldValue
+ } else field.value = null
+}
+
+module.exports = function(Parser) {
+ Parser = privateClassElements(Parser)
+ return class extends Parser {
+ // Parse fields
+ parseClassElement(_constructorAllowsSuper) {
+ if (this.options.ecmaVersion >= 8 && (this.type == tt.name || this.type == this.privateNameToken || this.type == tt.bracketL || this.type == tt.string)) {
+ const branch = this._branch()
+ if (branch.type == tt.bracketL) {
+ let count = 0
+ do {
+ if (branch.eat(tt.bracketL)) ++count
+ else if (branch.eat(tt.bracketR)) --count
+ else branch.next()
+ } while (count > 0)
+ } else branch.next()
+ if (branch.type == tt.eq || branch.canInsertSemicolon() || branch.type == tt.semi) {
+ const node = this.startNode()
+ if (this.type == this.privateNameToken) {
+ this.parsePrivateClassElementName(node)
+ } else {
+ this.parsePropertyName(node)
+ }
+ if ((node.key.type === "Identifier" && node.key.name === "constructor") ||
+ (node.key.type === "Literal" && node.key.value === "constructor")) {
+ this.raise(node.key.start, "Classes may not have a field called constructor")
+ }
+ maybeParseFieldValue.call(this, node)
+ this.finishNode(node, "FieldDefinition")
+ this.semicolon()
+ return node
+ }
+ }
+
+ return super.parseClassElement.apply(this, arguments)
+ }
+
+ // Prohibit arguments in class field initializers
+ parseIdent(liberal, isBinding) {
+ const ident = super.parseIdent(liberal, isBinding)
+ if (this._inFieldValue && ident.name == "arguments") this.raise(ident.start, "A class field initializer may not contain arguments")
+ return ident
+ }
+ }
+}
diff --git a/node-acorn-class-fields/package.json b/node-acorn-class-fields/package.json
new file mode 100644
index 0000000..0bd2454
--- /dev/null
+++ b/node-acorn-class-fields/package.json
@@ -0,0 +1,36 @@
+{
+ "name": "acorn-class-fields",
+ "description": "Support for class fields in acorn",
+ "homepage": "https://github.com/acornjs/acorn-class-fields",
+ "contributors": [
+ "Adrian Heine <mail@adrianheine.de>"
+ ],
+ "engines": {
+ "node": ">=4.8.2"
+ },
+ "repository": {
+ "type": "git",
+ "url": "https://github.com/acornjs/acorn-class-fields"
+ },
+ "license": "MIT",
+ "scripts": {
+ "test": "mocha",
+ "test:test262": "node run_test262.js",
+ "lint": "eslint -c .eslintrc.json ."
+ },
+ "peerDependencies": {
+ "acorn": "^6.0.0"
+ },
+ "version": "0.3.1",
+ "devDependencies": {
+ "acorn": "^6.1.0",
+ "eslint": "^5.13.0",
+ "eslint-plugin-node": "^8.0.1",
+ "mocha": "^5.2.0",
+ "test262": "git+https://github.com/tc39/test262.git#33a306d1026b72227eb50a918db19ada16f12b3d",
+ "test262-parser-runner": "^0.5.0"
+ },
+ "dependencies": {
+ "acorn-private-class-elements": "^0.1.1"
+ }
+}
diff --git a/node-acorn-class-fields/run_test262.js b/node-acorn-class-fields/run_test262.js
new file mode 100644
index 0000000..23a8c23
--- /dev/null
+++ b/node-acorn-class-fields/run_test262.js
@@ -0,0 +1,26 @@
+"use strict"
+
+const fs = require("fs")
+const path = require("path")
+const run = require("test262-parser-runner")
+const acorn = require("acorn")
+const Parser = acorn.Parser.extend(require("."))
+
+const unsupportedFeatures = [
+ "BigInt",
+ "class-methods-private",
+ "class-static-fields-public",
+ "class-static-fields-private",
+ "class-static-methods-private"
+]
+
+const implementedFeatures = [ "class-fields-private", "class-fields-public" ]
+
+run(
+ (content, options) => Parser.parse(content, {sourceType: options.sourceType, ecmaVersion: 9}),
+ {
+ testsDirectory: path.dirname(require.resolve("test262/package.json")),
+ skip: test => (!test.attrs.features || !implementedFeatures.some(f => test.attrs.features.includes(f)) || unsupportedFeatures.some(f => test.attrs.features.includes(f))),
+ whitelist: fs.readFileSync("./test262.whitelist", "utf8").split("\n").filter(v => v && v[0] !== "#")
+ }
+)
diff --git a/node-acorn-class-fields/test/.eslintrc.json b/node-acorn-class-fields/test/.eslintrc.json
new file mode 100644
index 0000000..4668ae7
--- /dev/null
+++ b/node-acorn-class-fields/test/.eslintrc.json
@@ -0,0 +1,5 @@
+{
+ "env": {
+ "mocha": true
+ }
+}
diff --git a/node-acorn-class-fields/test/test.js b/node-acorn-class-fields/test/test.js
new file mode 100644
index 0000000..0c0e2f4
--- /dev/null
+++ b/node-acorn-class-fields/test/test.js
@@ -0,0 +1,342 @@
+"use strict"
+
+const assert = require("assert")
+const acorn = require("acorn"), classFields = require("..")
+const Parser = acorn.Parser.extend(classFields)
+
+function test(text, expectedResult, additionalOptions) {
+ it(text, function () {
+ const result = Parser.parse(text, Object.assign({ ecmaVersion: 9 }, additionalOptions))
+ if (expectedResult) {
+ assert.deepStrictEqual(result.body[0], expectedResult)
+ }
+ })
+}
+function testFail(text, expectedResult, additionalOptions) {
+ it(text, function () {
+ let msg = null
+ try {
+ Parser.parse(text, Object.assign({ ecmaVersion: 9 }, additionalOptions))
+ } catch (e) {
+ msg = e.message
+ }
+ assert.strictEqual(msg, expectedResult)
+ })
+}
+const newNode = (start, props) => Object.assign(new acorn.Node({options: {}}, start), props)
+
+describe("acorn-class-fields", function () {
+ test(`class Counter extends HTMLElement {
+ x = 0;
+
+ clicked() {
+ this.x++;
+ }
+
+ render() {
+ return this.x.toString();
+ }
+ }`)
+
+ test(`class Counter extends HTMLElement {
+ #x = 0;
+
+ clicked() {
+ this.#x++;
+ }
+
+ render() {
+ return this.#x.toString();
+ }
+ }`)
+ test("class A { a = this.#a; #a = 4 }")
+
+ testFail("class A { #a; f() { delete this.#a } }", "Private elements may not be deleted (1:20)")
+ testFail("class A { #a; #a }", "Duplicate private element (1:14)")
+ testFail("class A { a = this.#a }", "Usage of undeclared private name (1:19)")
+ testFail("class A { a = this.#a; b = this.#b }", "Usage of undeclared private name (1:19)")
+ testFail("class A { constructor = 4 }", "Classes may not have a field called constructor (1:10)")
+ testFail("class A { #constructor = 4 }", "Classes may not have a private element named constructor (1:10)")
+ testFail("class A { a = () => arguments }", "A class field initializer may not contain arguments (1:20)")
+ testFail("class A { a = () => super() }", "'super' keyword outside a method (1:20)")
+ testFail("class A { # a }", "Unexpected token (1:10)")
+ testFail("class A { #a; a() { this.# a } }", "Unexpected token (1:27)")
+
+ const classes = [
+ { text: "class A { %s }", ast: getBody => {
+ const body = getBody(10)
+ return newNode(0, {
+ type: "ClassDeclaration",
+ end: body.end + 2,
+ id: newNode(6, {
+ type: "Identifier",
+ end: 7,
+ name: "A"
+ }),
+ superClass: null,
+ body: newNode(8, {
+ type: "ClassBody",
+ end: body.end + 2,
+ body: [body]
+ })
+ })
+ } },
+ { text: "class A { %s; }", ast: getBody => {
+ const body = getBody(10)
+ return newNode(0, {
+ type: "ClassDeclaration",
+ end: body.end + 3,
+ id: newNode(6, {
+ type: "Identifier",
+ end: 7,
+ name: "A"
+ }),
+ superClass: null,
+ body: newNode(8, {
+ type: "ClassBody",
+ end: body.end + 3,
+ body: [body]
+ })
+ })
+ } },
+ { text: "class A { %s; #y }", ast: getBody => {
+ const body = getBody(10)
+ return newNode(0, {
+ type: "ClassDeclaration",
+ end: body.end + 6,
+ id: newNode(6, {
+ type: "Identifier",
+ end: 7,
+ name: "A"
+ }),
+ superClass: null,
+ body: newNode(8, {
+ type: "ClassBody",
+ end: body.end + 6,
+ body: [body, newNode(body.end + 2, {
+ type: "FieldDefinition",
+ end: body.end + 4,
+ key: newNode(body.end + 2, {
+ type: "PrivateName",
+ end: body.end + 4,
+ name: "y"
+ }),
+ value: null,
+ computed: false
+ }) ]
+ })
+ })
+ } },
+ { text: "class A { %s;a() {} }", ast: getBody => {
+ const body = getBody(10)
+ return newNode(0, {
+ type: "ClassDeclaration",
+ end: body.end + 9,
+ id: newNode(6, {
+ type: "Identifier",
+ end: 7,
+ name: "A"
+ }),
+ superClass: null,
+ body: newNode(8, {
+ type: "ClassBody",
+ end: body.end + 9,
+ body: [ body, newNode(body.end + 1, {
+ type: "MethodDefinition",
+ end: body.end + 7,
+ kind: "method",
+ static: false,
+ computed: false,
+ key: newNode(body.end + 1, {
+ type: "Identifier",
+ end: body.end + 2,
+ name: "a"
+ }),
+ value: newNode(body.end + 2, {
+ type: "FunctionExpression",
+ end: body.end + 7,
+ id: null,
+ generator: false,
+ expression: false,
+ async: false,
+ params: [],
+ body: newNode(body.end + 5, {
+ type: "BlockStatement",
+ end: body.end + 7,
+ body: []
+ })
+ })
+ }) ]
+ })
+ })
+ } },
+ { text: "class A { %s\na() {} }", ast: getBody => {
+ const body = getBody(10)
+ return newNode(0, {
+ type: "ClassDeclaration",
+ end: body.end + 9,
+ id: newNode(6, {
+ type: "Identifier",
+ end: 7,
+ name: "A"
+ }),
+ superClass: null,
+ body: newNode(8, {
+ type: "ClassBody",
+ end: body.end + 9,
+ body: [
+ body,
+ newNode(body.end + 1, {
+ type: "MethodDefinition",
+ end: body.end + 7,
+ kind: "method",
+ static: false,
+ computed: false,
+ key: newNode(body.end + 1, {
+ type: "Identifier",
+ end: body.end + 2,
+ name: "a"
+ }),
+ value: newNode(body.end + 2, {
+ type: "FunctionExpression",
+ end: body.end + 7,
+ id: null,
+ generator: false,
+ expression: false,
+ async: false,
+ params: [],
+ body: newNode(body.end + 5, {
+ type: "BlockStatement",
+ end: body.end + 7,
+ body: []
+ })
+ })
+ })
+ ]
+ })
+ })
+ } },
+ ];
+
+ [
+ { body: "x", passes: true, ast: start => newNode(start, {
+ type: "FieldDefinition",
+ end: start + 1,
+ key: newNode(start, {
+ type: "Identifier",
+ end: start + 1,
+ name: "x"
+ }),
+ value: null,
+ computed: false
+ }) },
+ { body: "x = 0", passes: true, ast: start => newNode(start, {
+ type: "FieldDefinition",
+ end: start + 5,
+ key: newNode(start, {
+ type: "Identifier",
+ end: start + 1,
+ name: "x"
+ }),
+ value: newNode(start + 4, {
+ type: "Literal",
+ end: start + 5,
+ value: 0,
+ raw: "0"
+ }),
+ computed: false
+ }) },
+ { body: "[x]", passes: true, ast: start => newNode(start, {
+ type: "FieldDefinition",
+ end: start + 3,
+ computed: true,
+ key: newNode(start + 1, {
+ type: "Identifier",
+ end: start + 2,
+ name: "x"
+ }),
+ value: null
+ }) },
+ { body: "[x] = 0", passes: true, ast: start => newNode(start, {
+ type: "FieldDefinition",
+ end: start + 7,
+ computed: true,
+ key: newNode(start + 1, {
+ type: "Identifier",
+ end: start + 2,
+ name: "x"
+ }),
+ value: newNode(start + 6, {
+ type: "Literal",
+ end: start + 7,
+ value: 0,
+ raw: "0"
+ })
+ }) },
+ { body: "#x", passes: true, ast: start => newNode(start, {
+ type: "FieldDefinition",
+ end: start + 2,
+ computed: false,
+ key: newNode(start, {
+ type: "PrivateName",
+ end: start + 2,
+ name: "x"
+ }),
+ value: null,
+ }) },
+ { body: "#x = 0", passes: true, ast: start => newNode(start, {
+ type: "FieldDefinition",
+ end: start + 6,
+ computed: false,
+ key: newNode(start, {
+ type: "PrivateName",
+ end: start + 2,
+ name: "x"
+ }),
+ value: newNode(start + 5, {
+ type: "Literal",
+ end: start + 6,
+ value: 0,
+ raw: "0"
+ })
+ }) },
+
+ { body: "async", passes: true, ast: start => newNode(start, {
+ type: "FieldDefinition",
+ end: start + 5,
+ key: newNode(start, {
+ type: "Identifier",
+ end: start + 5,
+ name: "async"
+ }),
+ value: null,
+ computed: false
+ }) },
+
+ { body: "async = 5", passes: true, ast: start => newNode(start, {
+ type: "FieldDefinition",
+ end: start + 9,
+ key: newNode(start, {
+ type: "Identifier",
+ end: start + 5,
+ name: "async"
+ }),
+ value: newNode(start + 8, {
+ type: "Literal",
+ end: start + 9,
+ raw: "5",
+ value: 5
+ }),
+ computed: false
+ }) },
+ ].forEach(bodyInput => {
+ const body = bodyInput.body, passes = bodyInput.passes, bodyAst = bodyInput.ast
+ classes.forEach(input => {
+ const text = input.text, options = input.options || {}, ast = input.ast;
+ (passes ? test : testFail)(text.replace("%s", body), ast(bodyAst), options)
+ })
+ })
+
+ testFail("class C { \\u0061sync m(){} };", "Unexpected token (1:21)")
+ test("class A extends B { constructor() { super() } }")
+})
diff --git a/node-acorn-class-fields/test262.whitelist b/node-acorn-class-fields/test262.whitelist
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/node-acorn-class-fields/test262.whitelist
diff --git a/node-acorn-export-ns-from/.eslintrc.json b/node-acorn-export-ns-from/.eslintrc.json
new file mode 100644
index 0000000..b88c24c
--- /dev/null
+++ b/node-acorn-export-ns-from/.eslintrc.json
@@ -0,0 +1,295 @@
+{
+ "env": {
+ "es6": true,
+ "node": true
+ },
+ "extends": ["eslint:recommended", "plugin:node/recommended"],
+ "plugins": ["node"],
+ "rules": {
+ "accessor-pairs": "error",
+ "array-bracket-newline": "off",
+ "array-bracket-spacing": "off",
+ "array-callback-return": "error",
+ "array-element-newline": "off",
+ "arrow-body-style": "error",
+ "arrow-parens": [
+ "error",
+ "as-needed"
+ ],
+ "arrow-spacing": [
+ "error",
+ {
+ "after": true,
+ "before": true
+ }
+ ],
+ "block-scoped-var": "error",
+ "block-spacing": "off",
+ "brace-style": [
+ "error",
+ "1tbs",
+ {
+ "allowSingleLine": true
+ }
+ ],
+ "callback-return": "error",
+ "camelcase": "error",
+ "capitalized-comments": "off",
+ "class-methods-use-this": "error",
+ "comma-dangle": "off",
+ "comma-spacing": [
+ "error",
+ {
+ "after": true,
+ "before": false
+ }
+ ],
+ "comma-style": [
+ "error",
+ "last"
+ ],
+ "complexity": "off",
+ "computed-property-spacing": [
+ "error",
+ "never"
+ ],
+ "consistent-return": "error",
+ "consistent-this": "error",
+ "curly": [ "error", "multi-line" ],
+ "default-case": "error",
+ "dot-location": "error",
+ "dot-notation": [
+ "error",
+ {
+ "allowKeywords": true
+ }
+ ],
+ "eol-last": "error",
+ "eqeqeq": "off",
+ "for-direction": "error",
+ "func-call-spacing": "error",
+ "func-name-matching": "error",
+ "func-names": [
+ "error",
+ "never"
+ ],
+ "func-style": [
+ "error",
+ "declaration",
+ { "allowArrowFunctions": true }
+ ],
+ "function-paren-newline": "off",
+ "generator-star-spacing": "error",
+ "getter-return": "error",
+ "global-require": "off",
+ "guard-for-in": "error",
+ "handle-callback-err": "error",
+ "id-blacklist": "error",
+ "id-length": "off",
+ "id-match": "error",
+ "implicit-arrow-linebreak": [
+ "error",
+ "beside"
+ ],
+ "indent": ["error", 2],
+ "indent-legacy": "off",
+ "init-declarations": "off",
+ "jsx-quotes": "error",
+ "key-spacing": "error",
+ "keyword-spacing": [
+ "error",
+ {
+ "after": true,
+ "before": true
+ }
+ ],
+ "line-comment-position": "off",
+ "linebreak-style": [
+ "error",
+ "unix"
+ ],
+ "lines-around-comment": "error",
+ "lines-around-directive": "error",
+ "lines-between-class-members": "error",
+ "max-depth": "error",
+ "max-len": "off",
+ "max-lines": "off",
+ "max-nested-callbacks": "error",
+ "max-params": "off",
+ "max-statements": "off",
+ "max-statements-per-line": "off",
+ "multiline-comment-style": [
+ "error",
+ "separate-lines"
+ ],
+ "new-cap": ["error", {"capIsNewExceptions": ["BigInt"]}],
+ "new-parens": "error",
+ "newline-after-var": "off",
+ "newline-before-return": "off",
+ "newline-per-chained-call": "off",
+ "no-alert": "error",
+ "no-array-constructor": "error",
+ "no-await-in-loop": "error",
+ "no-bitwise": "error",
+ "no-buffer-constructor": "error",
+ "no-caller": "error",
+ "no-catch-shadow": "error",
+ "no-confusing-arrow": "off",
+ "no-continue": "off",
+ "no-div-regex": "error",
+ "no-duplicate-imports": "error",
+ "no-else-return": "error",
+ "no-empty-function": "error",
+ "no-eq-null": "error",
+ "no-eval": "error",
+ "no-extend-native": "error",
+ "no-extra-bind": "error",
+ "no-extra-label": "error",
+ "no-extra-parens": "off",
+ "no-floating-decimal": "error",
+ "no-global-assign": "error",
+ "no-implicit-coercion": "error",
+ "no-implicit-globals": "error",
+ "no-implied-eval": "error",
+ "no-inline-comments": "off",
+ "no-invalid-this": "off",
+ "no-iterator": "error",
+ "no-label-var": "error",
+ "no-labels": "error",
+ "no-lone-blocks": "error",
+ "no-lonely-if": "off",
+ "no-loop-func": "error",
+ "no-magic-numbers": "off",
+ "no-mixed-operators": "off",
+ "no-mixed-requires": "error",
+ "no-multi-assign": "error",
+ "no-multi-spaces": "error",
+ "no-multi-str": "error",
+ "no-multiple-empty-lines": ["error", { "max": 1, "maxEOF": 0, "maxBOF": 0 }],
+ "no-native-reassign": "error",
+ "no-negated-condition": "off",
+ "no-negated-in-lhs": "error",
+ "no-nested-ternary": "error",
+ "no-new": "error",
+ "no-new-func": "error",
+ "no-new-object": "error",
+ "no-new-require": "error",
+ "no-new-wrappers": "error",
+ "no-octal-escape": "error",
+ "no-param-reassign": "off",
+ "no-path-concat": "error",
+ "no-plusplus": "off",
+ "no-process-env": "error",
+ "no-process-exit": "error",
+ "no-proto": "error",
+ "no-prototype-builtins": "error",
+ "no-restricted-globals": "error",
+ "no-restricted-imports": "error",
+ "no-restricted-modules": "error",
+ "no-restricted-properties": "error",
+ "no-restricted-syntax": "error",
+ "no-return-assign": "error",
+ "no-return-await": "error",
+ "no-script-url": "error",
+ "no-self-compare": "error",
+ "no-sequences": "error",
+ "no-shadow": "error",
+ "no-shadow-restricted-names": "error",
+ "no-spaced-func": "error",
+ "no-sync": [
+ "error",
+ {
+ "allowAtRootLevel": true
+ }
+ ],
+ "no-tabs": "error",
+ "no-template-curly-in-string": "error",
+ "no-ternary": "off",
+ "no-throw-literal": "error",
+ "no-trailing-spaces": "error",
+ "no-undef-init": "error",
+ "no-undefined": "off",
+ "no-underscore-dangle": "off",
+ "no-unmodified-loop-condition": "error",
+ "no-unneeded-ternary": "error",
+ "no-unused-expressions": "error",
+ "no-unused-vars": ["error", {"argsIgnorePattern": "^_"}],
+ "no-use-before-define": "error",
+ "no-useless-call": "error",
+ "no-useless-computed-key": "error",
+ "no-useless-concat": "error",
+ "no-useless-constructor": "error",
+ "no-useless-rename": "error",
+ "no-useless-return": "error",
+ "no-var": "error",
+ "no-void": "error",
+ "no-warning-comments": "error",
+ "no-whitespace-before-property": "error",
+ "no-with": "error",
+ "nonblock-statement-body-position": [
+ "error",
+ "any"
+ ],
+ "object-curly-newline": "off",
+ "object-curly-spacing": "off",
+ "object-property-newline": "off",
+ "object-shorthand": "off",
+ "one-var": "off",
+ "one-var-declaration-per-line": "off",
+ "operator-assignment": "error",
+ "operator-linebreak": "error",
+ "padded-blocks": "off",
+ "padding-line-between-statements": "error",
+ "prefer-arrow-callback": "off",
+ "prefer-const": "off",
+ "prefer-destructuring": "off",
+ "prefer-numeric-literals": "error",
+ "prefer-promise-reject-errors": "error",
+ "prefer-reflect": "off",
+ "prefer-rest-params": "error",
+ "prefer-spread": "error",
+ "prefer-template": "error",
+ "quote-props": ["error", "as-needed"],
+ "quotes": ["error", "double"],
+ "radix": "error",
+ "require-await": "error",
+ "require-jsdoc": "off",
+ "rest-spread-spacing": "error",
+ "semi": ["error", "never"],
+ "semi-spacing": "error",
+ "semi-style": [
+ "error",
+ "last"
+ ],
+ "sort-imports": "error",
+ "sort-keys": "off",
+ "sort-vars": "off",
+ "space-before-blocks": "error",
+ "space-before-function-paren": "off",
+ "space-in-parens": [
+ "error",
+ "never"
+ ],
+ "space-infix-ops": "error",
+ "space-unary-ops": "error",
+ "spaced-comment": "off",
+ "strict": "error",
+ "switch-colon-spacing": "error",
+ "symbol-description": "error",
+ "template-curly-spacing": "error",
+ "template-tag-spacing": "error",
+ "unicode-bom": [
+ "error",
+ "never"
+ ],
+ "valid-jsdoc": "error",
+ "vars-on-top": "off",
+ "wrap-regex": "error",
+ "yield-star-spacing": "error",
+ "yoda": [
+ "error",
+ "never"
+ ],
+ "node/no-unpublished-require": "off"
+ }
+}
diff --git a/node-acorn-export-ns-from/.gitignore b/node-acorn-export-ns-from/.gitignore
new file mode 100644
index 0000000..504afef
--- /dev/null
+++ b/node-acorn-export-ns-from/.gitignore
@@ -0,0 +1,2 @@
+node_modules/
+package-lock.json
diff --git a/node-acorn-export-ns-from/CHANGELOG.md b/node-acorn-export-ns-from/CHANGELOG.md
new file mode 100644
index 0000000..23b7d92
--- /dev/null
+++ b/node-acorn-export-ns-from/CHANGELOG.md
@@ -0,0 +1,3 @@
+## 0.1.0 (2018-10-24)
+
+Initial release
diff --git a/node-acorn-export-ns-from/LICENSE b/node-acorn-export-ns-from/LICENSE
new file mode 100644
index 0000000..7c2b27a
--- /dev/null
+++ b/node-acorn-export-ns-from/LICENSE
@@ -0,0 +1,19 @@
+Copyright (C) 2017-2018 by Adrian Heine
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+THE SOFTWARE.
diff --git a/node-acorn-export-ns-from/README.md b/node-acorn-export-ns-from/README.md
new file mode 100644
index 0000000..b32aa5a
--- /dev/null
+++ b/node-acorn-export-ns-from/README.md
@@ -0,0 +1,21 @@
+# export namespace from support for Acorn
+
+[![NPM version](https://img.shields.io/npm/v/acorn-export-ns-from.svg)](https://www.npmjs.org/package/acorn-export-ns-from)
+
+This is a plugin for [Acorn](http://marijnhaverbeke.nl/acorn/) - a tiny, fast JavaScript parser, written completely in JavaScript.
+
+It implements support for export namespace from as defined in the proposal [Add \`export * as ns from "mod"\` to Export production and Module Semantic](https://github.com/tc39/ecma262/pull/1174). The emitted AST follows [ESTree](https://github.com/leebyron/ecmascript-more-export-from/blob/master/ESTree.md).
+
+## Usage
+
+This module provides a plugin that can be used to extend the Acorn `Parser` class:
+
+```javascript
+const {Parser} = require('acorn');
+const acornExportNsFrom = require('acorn-export-ns-from');
+Parser.extend(acornExportNsFrom).parse('export * as ns from "source"');
+```
+
+## License
+
+This plugin is released under an [MIT License](./LICENSE).
diff --git a/node-acorn-export-ns-from/index.js b/node-acorn-export-ns-from/index.js
new file mode 100644
index 0000000..8942d91
--- /dev/null
+++ b/node-acorn-export-ns-from/index.js
@@ -0,0 +1,31 @@
+"use strict"
+
+const skipWhiteSpace = /(?:\s|\/\/.*|\/\*[^]*?\*\/)*/g
+
+const tt = require("acorn").tokTypes
+
+module.exports = function(Parser) {
+ return class extends Parser {
+ parseExport(node, exports) {
+ skipWhiteSpace.lastIndex = this.pos
+ const skip = skipWhiteSpace.exec(this.input)
+ const next = this.input.charAt(this.pos + skip[0].length)
+ if (next !== "*") return super.parseExport(node, exports)
+
+ this.next()
+ const specifier = this.startNode()
+ this.expect(tt.star)
+ if (this.eatContextual("as")) {
+ node.declaration = null
+ specifier.exported = this.parseIdent(true)
+ this.checkExport(exports, specifier.exported.name, this.lastTokStart)
+ node.specifiers = [this.finishNode(specifier, "ExportNamespaceSpecifier")]
+ }
+ this.expectContextual("from")
+ if (this.type !== tt.string) this.unexpected()
+ node.source = this.parseExprAtom()
+ this.semicolon()
+ return this.finishNode(node, node.specifiers ? "ExportNamedDeclaration" : "ExportAllDeclaration")
+ }
+ }
+}
diff --git a/node-acorn-export-ns-from/package.json b/node-acorn-export-ns-from/package.json
new file mode 100644
index 0000000..e76edc6
--- /dev/null
+++ b/node-acorn-export-ns-from/package.json
@@ -0,0 +1,33 @@
+{
+ "name": "acorn-export-ns-from",
+ "description": "Support for export-ns-from in acorn",
+ "homepage": "https://github.com/acornjs/acorn-export-ns-from",
+ "contributors": [
+ "Adrian Heine <mail@adrianheine.de>"
+ ],
+ "engines": {
+ "node": ">=4.8.2"
+ },
+ "repository": {
+ "type": "git",
+ "url": "https://github.com/acornjs/acorn-export-ns-from"
+ },
+ "license": "MIT",
+ "scripts": {
+ "test": "mocha",
+ "test:test262": "node run_test262.js",
+ "lint": "eslint -c .eslintrc.json ."
+ },
+ "peerDependencies": {
+ "acorn": "^6.0.1"
+ },
+ "version": "0.1.0",
+ "devDependencies": {
+ "acorn": "^6.0.2",
+ "eslint": "^5.7.0",
+ "eslint-plugin-node": "^7.0.1",
+ "mocha": "^5.2.0",
+ "test262": "git+https://github.com/tc39/test262.git#c3e384c8c5fcee43395bebc958e48e23dc2c8d5b",
+ "test262-parser-runner": "^0.5.0"
+ }
+}
diff --git a/node-acorn-export-ns-from/run_test262.js b/node-acorn-export-ns-from/run_test262.js
new file mode 100644
index 0000000..70a4421
--- /dev/null
+++ b/node-acorn-export-ns-from/run_test262.js
@@ -0,0 +1,17 @@
+"use strict"
+
+const fs = require("fs")
+const path = require("path")
+const run = require("test262-parser-runner")
+const acorn = require("acorn")
+const acornExportNsFrom = require(".")
+const Parser = acorn.Parser.extend(acornExportNsFrom)
+
+run(
+ (content, options) => Parser.parse(content, {sourceType: options.sourceType, ecmaVersion: 10}),
+ {
+ testsDirectory: path.dirname(require.resolve("test262/package.json")),
+ skip: test => !(test.attrs.features && test.attrs.features.includes("export-star-as-namespace-from-module") && !test.attrs.features.includes("dynamic-import")),
+ whitelist: fs.readFileSync("./test262.whitelist", "utf8").split("\n").filter(v => v && v[0] !== "#")
+ }
+)
diff --git a/node-acorn-export-ns-from/test/.eslintrc.json b/node-acorn-export-ns-from/test/.eslintrc.json
new file mode 100644
index 0000000..4668ae7
--- /dev/null
+++ b/node-acorn-export-ns-from/test/.eslintrc.json
@@ -0,0 +1,5 @@
+{
+ "env": {
+ "mocha": true
+ }
+}
diff --git a/node-acorn-export-ns-from/test/test.js b/node-acorn-export-ns-from/test/test.js
new file mode 100644
index 0000000..3f304c2
--- /dev/null
+++ b/node-acorn-export-ns-from/test/test.js
@@ -0,0 +1,69 @@
+"use strict"
+
+const assert = require("assert")
+
+const acorn = require("acorn")
+const exportNsFrom = require("..")
+
+const Parser = acorn.Parser.extend(exportNsFrom)
+
+const parse = testCode => Parser.parse(testCode, { ecmaVersion: 10, sourceType: "module" })
+
+function test(testCode, ast) {
+ it(testCode, () => {
+ const result = parse(testCode)
+ assert.deepStrictEqual(result, ast)
+ })
+}
+
+function testFail(text, expectedError) {
+ it(text, function () {
+ let failed = false
+ try {
+ parse(text)
+ } catch (e) {
+ assert.strictEqual(e.message, expectedError)
+ failed = true
+ }
+ assert(failed)
+ })
+}
+
+const newNode = props => Object.assign(new acorn.Node({options: {}}, props.start), props)
+
+describe("acorn-export-ns-from", () => {
+ test("export * as ns from 'source';", newNode({
+ type: "Program",
+ start: 0,
+ end: 29,
+ body: [
+ newNode({
+ type: "ExportNamedDeclaration",
+ start: 0,
+ end: 29,
+ declaration: null,
+ specifiers: [newNode({
+ type: "ExportNamespaceSpecifier",
+ start: 7,
+ end: 14,
+ exported: newNode({
+ type: "Identifier",
+ start: 12,
+ end: 14,
+ name: "ns"
+ })
+ })],
+ source: newNode({
+ type: "Literal",
+ start: 20,
+ end: 28,
+ value: "source",
+ raw: "'source'"
+ })
+ })
+ ],
+ sourceType: "module"
+ }))
+ testFail("export * as ns from 'source';\nexport const ns = null;", "Duplicate export 'ns' (2:13)")
+ testFail("export const ns = null;\nexport * as ns from 'source';", "Duplicate export 'ns' (2:12)")
+})
diff --git a/node-acorn-export-ns-from/test262.whitelist b/node-acorn-export-ns-from/test262.whitelist
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/node-acorn-export-ns-from/test262.whitelist
diff --git a/node-acorn-node/CHANGELOG.md b/node-acorn-node/CHANGELOG.md
index b467c9d..654dcd1 100644
--- a/node-acorn-node/CHANGELOG.md
+++ b/node-acorn-node/CHANGELOG.md
@@ -4,6 +4,26 @@ All notable changes to this project will be documented in this file.
This project adheres to [Semantic Versioning](http://semver.org/).
+## 1.7.0
+ * Add class instance fields support:
+ ```js
+ class X {
+ public = 1;
+ #private = 2;
+ }
+ ```
+ * Add class static fields support:
+ ```js
+ class X {
+ static public = 1;
+ static #private = 2;
+ }
+ ```
+ * Add `export * as ns` support when `sourceType` is 'module':
+ ```js
+ export * as ns from './ns.mjs';
+ ```
+
## 1.6.2
* Allow dynamic `import()` in scripts.
diff --git a/node-acorn-node/README.md b/node-acorn-node/README.md
index d689046..adb2adc 100644
--- a/node-acorn-node/README.md
+++ b/node-acorn-node/README.md
@@ -10,7 +10,7 @@ It also includes versions of the plugins compiled with [Bublé](https://github.c
[npm-image]: https://img.shields.io/npm/v/acorn-node.svg?style=flat-square
[npm-url]: https://www.npmjs.com/package/acorn-node
-[travis-image]: https://img.shields.io/travis/browserify/acorn-node.svg?style=flat-square
+[travis-image]: https://img.shields.io/travis/browserify/acorn-node/master.svg?style=flat-square
[travis-url]: https://travis-ci.org/browserify/acorn-node
[standard-image]: https://img.shields.io/badge/code%20style-standard-brightgreen.svg?style=flat-square
[standard-url]: http://npm.im/standard
@@ -29,9 +29,12 @@ var acorn = require('acorn-node')
The API is the same as [acorn](https://github.com/acornjs/acorn), but the following syntax features are enabled by default:
- - Bigint syntax (via [acorn-bigint](https://github.com/acornjs/acorn-bigint]))
+ - Bigint syntax (via [acorn-bigint](https://github.com/acornjs/acorn-bigint]), MIT)
+ - Public and private class instance fields (via [acorn-class-fields](https://github.com/acornjs/acorn-class-fields), MIT)
+ - Public and private class static fields (via [acorn-static-class-features](https://github.com/acornjs/acorn-static-class-features), MIT)
- Dynamic `import()` (via [acorn-dynamic-import](https://github.com/kesne/acorn-dynamic-import))
- - The `import.meta` property (via [acorn-import-meta](https://github.com/acornjs/acorn-import-meta))
+ - The `import.meta` property (via [acorn-import-meta](https://github.com/acornjs/acorn-import-meta), MIT)
+ - `export * as ns from` syntax (via [acorn-export-ns-from](https://github.com/acornjs/acorn-export-ns-from), MIT)
And the following options have different defaults from acorn, to match Node modules:
diff --git a/node-acorn-node/build.js b/node-acorn-node/build.js
index 8075566..014d773 100644
--- a/node-acorn-node/build.js
+++ b/node-acorn-node/build.js
@@ -5,10 +5,11 @@ var buble = require('buble')
var HEADER = '/* Generated by `npm run build`, do not edit! */\n\n'
-function compile (name, output) { // eslint-disable-line no-unused-vars
+function compile (name, output, fix) {
console.log(name, '→', output)
mkdirp.sync(path.dirname(path.join(__dirname, output)))
var source = fs.readFileSync(require.resolve(name), 'utf8')
+ if (fix) source = fix(source)
var result = buble.transform(source, {
transforms: {
dangerousForOf: true
@@ -17,5 +18,15 @@ function compile (name, output) { // eslint-disable-line no-unused-vars
fs.writeFileSync(path.join(__dirname, output), HEADER + result.code, 'utf8')
}
+function privateClassElements (str) {
+ return str.replace('acorn-private-class-elements', '../private-class-elements')
+}
+
compile('acorn-bigint', './lib/bigint/index.js')
compile('acorn-import-meta', './lib/import-meta/index.js')
+compile('acorn-export-ns-from', './lib/export-ns-from/index.js')
+compile('acorn-class-fields', './lib/class-fields/index.js', privateClassElements)
+compile('acorn-static-class-features', './lib/static-class-features/index.js', privateClassElements)
+compile('acorn-private-class-elements', './lib/private-class-elements/index.js', function (str) {
+ return str.replace('class extends Parser', 'class Parser_ extends Parser')
+})
diff --git a/node-acorn-node/index.js b/node-acorn-node/index.js
index 0c979c9..87e2836 100644
--- a/node-acorn-node/index.js
+++ b/node-acorn-node/index.js
@@ -3,8 +3,11 @@ var xtend = require('xtend')
var CJSParser = acorn.Parser
.extend(require('./lib/bigint'))
+ .extend(require('./lib/class-fields'))
+ .extend(require('./lib/static-class-features'))
.extend(require('acorn-dynamic-import').default)
var ESModulesParser = CJSParser
+ .extend(require('./lib/export-ns-from'))
.extend(require('./lib/import-meta'))
function mapOptions (opts) {
diff --git a/node-acorn-node/package.json b/node-acorn-node/package.json
index 361ef07..9f9696d 100644
--- a/node-acorn-node/package.json
+++ b/node-acorn-node/package.json
@@ -1,21 +1,25 @@
{
"name": "acorn-node",
"description": "the acorn javascript parser, preloaded with plugins for syntax parity with recent node versions",
- "version": "1.6.2",
+ "version": "1.7.0",
"author": "Renée Kooi <renee@kooi.me>",
"bugs": {
"url": "https://github.com/browserify/acorn-node/issues"
},
"dependencies": {
- "acorn": "^6.0.2",
+ "acorn": "^6.1.1",
"acorn-dynamic-import": "^4.0.0",
- "acorn-walk": "^6.1.0",
+ "acorn-walk": "^6.1.1",
"xtend": "^4.0.1"
},
"devDependencies": {
"acorn-bigint": "^0.3.1",
+ "acorn-class-fields": "^0.3.1",
+ "acorn-export-ns-from": "^0.1.0",
"acorn-import-meta": "^0.3.0",
- "buble": "^0.19.6",
+ "acorn-private-class-elements": "^0.1.1",
+ "acorn-static-class-features": "^0.2.0",
+ "buble": "^0.19.7",
"mkdirp": "^0.5.1",
"standard": "^11.0.1",
"tape": "^4.9.1"
diff --git a/node-acorn-node/test/index.js b/node-acorn-node/test/index.js
index 891129a..4668ec8 100644
--- a/node-acorn-node/test/index.js
+++ b/node-acorn-node/test/index.js
@@ -94,6 +94,41 @@ test('supports dynamic import() with sourceType: script', function (t) {
t.end()
})
+test('supports class instance properties', function (t) {
+ t.doesNotThrow(function () {
+ acorn.parse('class X { x = y }', { sourceType: 'script' })
+ })
+ t.end()
+})
+
+test('supports private class instance properties', function (t) {
+ t.doesNotThrow(function () {
+ acorn.parse('class X { #x = y }', { sourceType: 'script' })
+ })
+ t.end()
+})
+
+test('supports class static properties', function (t) {
+ t.doesNotThrow(function () {
+ acorn.parse('class X { static x = y }', { sourceType: 'script' })
+ })
+ t.end()
+})
+
+test('supports private class static properties', function (t) {
+ t.doesNotThrow(function () {
+ acorn.parse('class X { static #x = y }', { sourceType: 'script' })
+ })
+ t.end()
+})
+
+test('supports namespace export syntax with sourceType: module', function (t) {
+ t.doesNotThrow(function () {
+ acorn.parse('export * as x from "./x.mjs";', { sourceType: 'module' })
+ })
+ t.end()
+})
+
test('walk supports plugin syntax', function (t) {
var ast = acorn.parse(
'async function* a() { try { await import(xyz); } catch { for await (x of null) {} } yield import.meta.url }',
diff --git a/node-acorn-numeric-separator/.eslintrc.json b/node-acorn-numeric-separator/.eslintrc.json
new file mode 100644
index 0000000..43d89a4
--- /dev/null
+++ b/node-acorn-numeric-separator/.eslintrc.json
@@ -0,0 +1,294 @@
+{
+ "env": {
+ "es6": true,
+ "node": true
+ },
+ "extends": ["eslint:recommended", "plugin:node/recommended"],
+ "plugins": ["node"],
+ "rules": {
+ "accessor-pairs": "error",
+ "array-bracket-newline": "off",
+ "array-bracket-spacing": "off",
+ "array-callback-return": "error",
+ "array-element-newline": "off",
+ "arrow-body-style": "error",
+ "arrow-parens": [
+ "error",
+ "as-needed"
+ ],
+ "arrow-spacing": [
+ "error",
+ {
+ "after": true,
+ "before": true
+ }
+ ],
+ "block-scoped-var": "error",
+ "block-spacing": "off",
+ "brace-style": [
+ "error",
+ "1tbs",
+ {
+ "allowSingleLine": true
+ }
+ ],
+ "callback-return": "error",
+ "camelcase": "error",
+ "capitalized-comments": "off",
+ "class-methods-use-this": "error",
+ "comma-dangle": "off",
+ "comma-spacing": [
+ "error",
+ {
+ "after": true,
+ "before": false
+ }
+ ],
+ "comma-style": [
+ "error",
+ "last"
+ ],
+ "complexity": "off",
+ "computed-property-spacing": [
+ "error",
+ "never"
+ ],
+ "consistent-return": "error",
+ "consistent-this": "error",
+ "curly": [ "error", "multi-line" ],
+ "default-case": "error",
+ "dot-location": "error",
+ "dot-notation": [
+ "error",
+ {
+ "allowKeywords": true
+ }
+ ],
+ "eol-last": "error",
+ "eqeqeq": "off",
+ "for-direction": "error",
+ "func-call-spacing": "error",
+ "func-name-matching": "error",
+ "func-names": [
+ "error",
+ "never"
+ ],
+ "func-style": [
+ "error",
+ "declaration",
+ { "allowArrowFunctions": true }
+ ],
+ "function-paren-newline": "off",
+ "generator-star-spacing": "error",
+ "getter-return": "error",
+ "global-require": "error",
+ "guard-for-in": "error",
+ "handle-callback-err": "error",
+ "id-blacklist": "error",
+ "id-length": "off",
+ "id-match": "error",
+ "implicit-arrow-linebreak": [
+ "error",
+ "beside"
+ ],
+ "indent": ["error", 2],
+ "indent-legacy": "off",
+ "init-declarations": "off",
+ "jsx-quotes": "error",
+ "key-spacing": "error",
+ "keyword-spacing": [
+ "error",
+ {
+ "after": true,
+ "before": true
+ }
+ ],
+ "line-comment-position": "off",
+ "linebreak-style": [
+ "error",
+ "unix"
+ ],
+ "lines-around-comment": "error",
+ "lines-around-directive": "error",
+ "lines-between-class-members": "error",
+ "max-depth": "error",
+ "max-len": "off",
+ "max-lines": "off",
+ "max-nested-callbacks": "error",
+ "max-params": "off",
+ "max-statements": "off",
+ "max-statements-per-line": "off",
+ "multiline-comment-style": [
+ "error",
+ "separate-lines"
+ ],
+ "new-cap": "error",
+ "new-parens": "error",
+ "newline-after-var": "off",
+ "newline-before-return": "off",
+ "newline-per-chained-call": "off",
+ "no-alert": "error",
+ "no-array-constructor": "error",
+ "no-await-in-loop": "error",
+ "no-bitwise": "error",
+ "no-buffer-constructor": "error",
+ "no-caller": "error",
+ "no-catch-shadow": "error",
+ "no-confusing-arrow": "error",
+ "no-continue": "off",
+ "no-div-regex": "error",
+ "no-duplicate-imports": "error",
+ "no-else-return": "error",
+ "no-empty-function": "error",
+ "no-eq-null": "warn",
+ "no-eval": "error",
+ "no-extend-native": "error",
+ "no-extra-bind": "error",
+ "no-extra-label": "error",
+ "no-extra-parens": "off",
+ "no-floating-decimal": "error",
+ "no-implicit-coercion": "error",
+ "no-implicit-globals": "error",
+ "no-implied-eval": "error",
+ "no-inline-comments": "off",
+ "no-invalid-this": "off",
+ "no-iterator": "error",
+ "no-label-var": "error",
+ "no-labels": "error",
+ "no-lone-blocks": "error",
+ "no-lonely-if": "off",
+ "no-loop-func": "error",
+ "no-magic-numbers": "off",
+ "no-mixed-operators": "off",
+ "no-mixed-requires": "error",
+ "no-multi-assign": "error",
+ "no-multi-spaces": "error",
+ "no-multi-str": "error",
+ "no-multiple-empty-lines": ["error", { "max": 1, "maxEOF": 0, "maxBOF": 0 }],
+ "no-native-reassign": "error",
+ "no-negated-condition": "off",
+ "no-negated-in-lhs": "error",
+ "no-nested-ternary": "error",
+ "no-new": "error",
+ "no-new-func": "error",
+ "no-new-object": "error",
+ "no-new-require": "error",
+ "no-new-wrappers": "error",
+ "no-octal-escape": "error",
+ "no-param-reassign": "off",
+ "no-path-concat": "error",
+ "no-plusplus": "off",
+ "no-process-env": "error",
+ "no-process-exit": "error",
+ "no-proto": "error",
+ "no-prototype-builtins": "error",
+ "no-restricted-globals": "error",
+ "no-restricted-imports": "error",
+ "no-restricted-modules": "error",
+ "no-restricted-properties": "error",
+ "no-restricted-syntax": "error",
+ "no-return-assign": "error",
+ "no-return-await": "error",
+ "no-script-url": "error",
+ "no-self-compare": "error",
+ "no-sequences": "error",
+ "no-shadow": "error",
+ "no-shadow-restricted-names": "error",
+ "no-spaced-func": "error",
+ "no-sync": [
+ "error",
+ {
+ "allowAtRootLevel": true
+ }
+ ],
+ "no-tabs": "error",
+ "no-template-curly-in-string": "error",
+ "no-ternary": "off",
+ "no-throw-literal": "error",
+ "no-trailing-spaces": "error",
+ "no-undef-init": "error",
+ "no-undefined": "error",
+ "no-underscore-dangle": "off",
+ "no-unmodified-loop-condition": "error",
+ "no-unneeded-ternary": "error",
+ "no-unused-expressions": "error",
+ "no-unused-vars": ["error", {"argsIgnorePattern": "^_"}],
+ "no-use-before-define": "error",
+ "no-useless-call": "error",
+ "no-useless-computed-key": "error",
+ "no-useless-concat": "error",
+ "no-useless-constructor": "error",
+ "no-useless-rename": "error",
+ "no-useless-return": "error",
+ "no-var": "error",
+ "no-void": "error",
+ "no-warning-comments": "error",
+ "no-whitespace-before-property": "error",
+ "no-with": "error",
+ "nonblock-statement-body-position": [
+ "error",
+ "any"
+ ],
+ "object-curly-newline": "off",
+ "object-curly-spacing": "off",
+ "object-property-newline": "off",
+ "object-shorthand": "off",
+ "one-var": "off",
+ "one-var-declaration-per-line": "off",
+ "operator-assignment": "error",
+ "operator-linebreak": "error",
+ "padded-blocks": "off",
+ "padding-line-between-statements": "error",
+ "prefer-arrow-callback": "off",
+ "prefer-const": "off",
+ "prefer-destructuring": "off",
+ "prefer-numeric-literals": "error",
+ "prefer-promise-reject-errors": "error",
+ "prefer-reflect": "off",
+ "prefer-rest-params": "error",
+ "prefer-spread": "error",
+ "prefer-template": "error",
+ "quote-props": ["error", "as-needed"],
+ "quotes": ["error", "double"],
+ "radix": "error",
+ "require-await": "error",
+ "require-jsdoc": "off",
+ "rest-spread-spacing": "error",
+ "semi": ["error", "never"],
+ "semi-spacing": "error",
+ "semi-style": [
+ "error",
+ "last"
+ ],
+ "sort-imports": "error",
+ "sort-keys": "off",
+ "sort-vars": "off",
+ "space-before-blocks": "error",
+ "space-before-function-paren": "off",
+ "space-in-parens": [
+ "error",
+ "never"
+ ],
+ "space-infix-ops": "error",
+ "space-unary-ops": "error",
+ "spaced-comment": "off",
+ "strict": "error",
+ "switch-colon-spacing": "error",
+ "symbol-description": "error",
+ "template-curly-spacing": "error",
+ "template-tag-spacing": "error",
+ "unicode-bom": [
+ "error",
+ "never"
+ ],
+ "valid-jsdoc": "error",
+ "vars-on-top": "off",
+ "wrap-regex": "error",
+ "yield-star-spacing": "error",
+ "yoda": [
+ "error",
+ "never"
+ ],
+ "node/no-unpublished-require": "off"
+ }
+}
diff --git a/node-acorn-numeric-separator/.gitignore b/node-acorn-numeric-separator/.gitignore
new file mode 100644
index 0000000..c2658d7
--- /dev/null
+++ b/node-acorn-numeric-separator/.gitignore
@@ -0,0 +1 @@
+node_modules/
diff --git a/node-acorn-numeric-separator/CHANGELOG.md b/node-acorn-numeric-separator/CHANGELOG.md
new file mode 100644
index 0000000..dfe8e3e
--- /dev/null
+++ b/node-acorn-numeric-separator/CHANGELOG.md
@@ -0,0 +1,16 @@
+## 0.3.0 (2019-04-04)
+
+* Make compatible with acorn-bigint
+
+## 0.2.0 (2018-09-14)
+
+* Update to new acorn 6 interface
+* Change license to MIT
+
+## 0.1.1 (2018-01-16)
+
+* Don't bail on empty integers as in `1.`
+
+## 0.1.0 (2017-12-19)
+
+Initial release
diff --git a/node-acorn-numeric-separator/LICENSE b/node-acorn-numeric-separator/LICENSE
new file mode 100644
index 0000000..7c2b27a
--- /dev/null
+++ b/node-acorn-numeric-separator/LICENSE
@@ -0,0 +1,19 @@
+Copyright (C) 2017-2018 by Adrian Heine
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+THE SOFTWARE.
diff --git a/node-acorn-numeric-separator/README.md b/node-acorn-numeric-separator/README.md
new file mode 100644
index 0000000..2718857
--- /dev/null
+++ b/node-acorn-numeric-separator/README.md
@@ -0,0 +1,21 @@
+# Numeric separator support for Acorn
+
+[![NPM version](https://img.shields.io/npm/v/acorn-numeric-separator.svg)](https://www.npmjs.org/package/acorn-numeric-separator)
+
+This is a plugin for [Acorn](http://marijnhaverbeke.nl/acorn/) - a tiny, fast JavaScript parser, written completely in JavaScript.
+
+It implements support for numeric separators as defined in the stage 3 proposal [Numeric Separators](https://github.com/tc39/proposal-numeric-separator).
+
+## Usage
+
+This module provides a plugin that can be used to extend the Acorn `Parser` class to parse numeric separators:
+
+```javascript
+var acorn = require('acorn');
+var numericSeparator = require('acorn-numeric-separator');
+acorn.Parser.extend(numericSeparator).parse('100_000');
+```
+
+## License
+
+This plugin is released under an [MIT License](./LICENSE).
diff --git a/node-acorn-numeric-separator/index.js b/node-acorn-numeric-separator/index.js
new file mode 100644
index 0000000..52f207c
--- /dev/null
+++ b/node-acorn-numeric-separator/index.js
@@ -0,0 +1,49 @@
+"use strict"
+
+module.exports = function(Parser) {
+ return class extends Parser {
+ readInt(radix, len) {
+ // Hack: len is only != null for unicode escape sequences,
+ // where numeric separators are not allowed
+ if (len != null) return super.readInt(radix, len)
+
+ let start = this.pos, total = 0, acceptUnderscore = false
+ for (;;) {
+ let code = this.input.charCodeAt(this.pos), val
+ if (code >= 97) val = code - 97 + 10 // a
+ else if (code == 95) {
+ if (!acceptUnderscore) this.raise(this.pos, "Invalid numeric separator")
+ ++this.pos
+ acceptUnderscore = false
+ continue
+ } else if (code >= 65) val = code - 65 + 10 // A
+ else if (code >= 48 && code <= 57) val = code - 48 // 0-9
+ else val = Infinity
+ if (val >= radix) break
+ ++this.pos
+ total = total * radix + val
+ acceptUnderscore = true
+ }
+ if (this.pos === start) return null
+ if (!acceptUnderscore) this.raise(this.pos - 1, "Invalid numeric separator")
+
+ return total
+ }
+
+ readNumber(startsWithDot) {
+ const token = super.readNumber(startsWithDot)
+ let octal = this.end - this.start >= 2 && this.input.charCodeAt(this.start) === 48
+ const stripped = this.getNumberInput(this.start, this.end)
+ if (stripped.length < this.end - this.start) {
+ if (octal) this.raise(this.start, "Invalid number")
+ this.value = parseFloat(stripped)
+ }
+ return token
+ }
+
+ // This is used by acorn-bigint
+ getNumberInput(start, end) {
+ return this.input.slice(start, end).replace(/_/g, "")
+ }
+ }
+}
diff --git a/node-acorn-numeric-separator/package.json b/node-acorn-numeric-separator/package.json
new file mode 100644
index 0000000..bc09f65
--- /dev/null
+++ b/node-acorn-numeric-separator/package.json
@@ -0,0 +1,33 @@
+{
+ "name": "acorn-numeric-separator",
+ "description": "Support for numeric separators in acorn",
+ "homepage": "https://github.com/acornjs/acorn-numeric-separator",
+ "contributors": [
+ "Adrian Heine <mail@adrianheine.de>"
+ ],
+ "engines": {
+ "node": ">=4.8.2"
+ },
+ "repository": {
+ "type": "git",
+ "url": "https://github.com/acornjs/acorn-numeric-separator"
+ },
+ "license": "MIT",
+ "scripts": {
+ "test": "mocha",
+ "test:test262": "node run_test262.js",
+ "lint": "eslint -c .eslintrc.json ."
+ },
+ "peerDependencies": {
+ "acorn": "^6.0.0"
+ },
+ "version": "0.3.0",
+ "devDependencies": {
+ "acorn": "^6.0.0",
+ "eslint": "^5.5.0",
+ "eslint-plugin-node": "^8.0.1",
+ "mocha": "^6.0.2",
+ "test262": "git+https://github.com/tc39/test262.git#de567d3aa5de4eaa11e00131d26b9fe77997dfb0",
+ "test262-parser-runner": "^0.5.0"
+ }
+}
diff --git a/node-acorn-numeric-separator/run_test262.js b/node-acorn-numeric-separator/run_test262.js
new file mode 100644
index 0000000..ece90cf
--- /dev/null
+++ b/node-acorn-numeric-separator/run_test262.js
@@ -0,0 +1,27 @@
+"use strict"
+
+const path = require("path")
+const run = require("test262-parser-runner")
+const acorn = require("acorn")
+const Parser = acorn.Parser.extend(require("."))
+
+const unsupportedFeatures = [
+ "BigInt",
+ "class-fields-private",
+ "class-fields-public",
+ "class-methods-private",
+ "class-static-fields-private",
+ "class-static-fields-public",
+ "class-static-methods-private",
+ "dynamic-import",
+ "export-star-as-namespace-from-module",
+ "import.meta"
+]
+
+run(
+ (content, options) => Parser.parse(content, {sourceType: options.sourceType, ecmaVersion: 9}),
+ {
+ testsDirectory: path.dirname(require.resolve("test262/package.json")),
+ skip: test => (!test.attrs.features || !test.attrs.features.includes("numeric-separator-literal") || unsupportedFeatures.some(f => test.attrs.features.includes(f))),
+ }
+)
diff --git a/node-acorn-numeric-separator/test/.eslintrc.json b/node-acorn-numeric-separator/test/.eslintrc.json
new file mode 100644
index 0000000..4668ae7
--- /dev/null
+++ b/node-acorn-numeric-separator/test/.eslintrc.json
@@ -0,0 +1,5 @@
+{
+ "env": {
+ "mocha": true
+ }
+}
diff --git a/node-acorn-numeric-separator/test/test.js b/node-acorn-numeric-separator/test/test.js
new file mode 100644
index 0000000..85b2ebc
--- /dev/null
+++ b/node-acorn-numeric-separator/test/test.js
@@ -0,0 +1,270 @@
+"use strict"
+
+const assert = require("assert")
+const acorn = require("acorn")
+const numericSeparator = require("..")
+const Parser = acorn.Parser.extend(numericSeparator)
+
+function test(text, expectedResult, additionalOptions) {
+ it(text, function () {
+ const result = Parser.parse(text, Object.assign({ ecmaVersion: 9, plugins: { numericSeparator: true } }, additionalOptions))
+ assert.deepStrictEqual(result.body[0], expectedResult)
+ })
+}
+function testFail(text, expectedError, additionalOptions) {
+ it(text, function () {
+ let failed = false
+ try {
+ Parser.parse(text, Object.assign({ ecmaVersion: 9, plugins: { numericSeparator: true } }, additionalOptions))
+ } catch (e) {
+ assert.strictEqual(e.message, expectedError)
+ failed = true
+ }
+ assert(failed)
+ })
+}
+
+const newNode = (start, props) => Object.assign(new acorn.Node({options: {}}, start), props)
+
+describe("acorn-numeric-separator", function () {
+ testFail("'\\u{12_34}'", "Bad character escape sequence (1:4)")
+ testFail("'\\u12_34'", "Bad character escape sequence (1:3)")
+ testFail("let a\\u{12_34} = 5", "Bad character escape sequence (1:8)")
+
+ const digits = [
+ {d: "1_0", ast: start => newNode(start, {
+ type: "Literal",
+ end: start + 3,
+ value: 10,
+ raw: "1_0",
+ })},
+ {d: "12e3_4", ast: start => newNode(start, {
+ type: "Literal",
+ end: start + 6,
+ value: 12e34,
+ raw: "12e3_4",
+ })},
+ {d: "1_2e34", ast: start => newNode(start, {
+ type: "Literal",
+ end: start + 6,
+ value: 12e34,
+ raw: "1_2e34",
+ })},
+ {d: "0b1010_1001", ast: start => newNode(start, {
+ type: "Literal",
+ end: start + 11,
+ value: 169,
+ raw: "0b1010_1001",
+ })},
+ {d: "0xA0_B0_C0", ast: start => newNode(start, {
+ type: "Literal",
+ end: start + 10,
+ value: 0xa0b0c0,
+ raw: "0xA0_B0_C0",
+ })},
+ {d: "0o70_60_50", ast: start => newNode(start, {
+ type: "Literal",
+ end: start + 10,
+ value: 0o706050,
+ raw: "0o70_60_50",
+ })},
+
+ {d: "_2", ast: start => newNode(start, {
+ type: "Identifier",
+ end: start + 2,
+ name: "_2",
+ })},
+ {d: "0b_1", error: start => `Invalid numeric separator (1:${start + 2})`},
+ {d: "0o_1", error: start => `Invalid numeric separator (1:${start + 2})`},
+ {d: "0x_1", error: start => `Invalid numeric separator (1:${start + 2})`},
+ {d: "2_", error: start => `Invalid numeric separator (1:${start + 1})`},
+ {d: "2__4", error: start => `Invalid numeric separator (1:${start + 2})`},
+ {d: "._4", error: start => `Unexpected token (1:${start})`},
+ {d: "_.4", error: start => `Unexpected token (1:${start + 1})`},
+ {d: "1._4", error: start => `Invalid numeric separator (1:${start + 2})`},
+ {d: "1_.4", error: start => `Invalid numeric separator (1:${start + 1})`},
+ {d: "_1.4", error: start => `Unexpected token (1:${start + 2})`},
+ {d: "1.4_", error: start => `Invalid numeric separator (1:${start + 3})`},
+ {d: "1.4_e2", error: start => `Invalid numeric separator (1:${start + 3})`},
+ {d: "1.4e_2", error: start => `Invalid numeric separator (1:${start + 4})`},
+ {d: "04_3_2", error: start => `Invalid number (1:${start})`},
+ {d: "0_4_3_2", error: start => `Invalid number (1:${start})`},
+ ]
+ const statements = [
+ {s: "let i = %s", ast: content => newNode(0, {
+ type: "VariableDeclaration",
+ end: content.end,
+ kind: "let",
+ declarations: [newNode(4, {
+ type: "VariableDeclarator",
+ end: content.end,
+ id: newNode(4, {
+ type: "Identifier",
+ end: 5,
+ name: "i"
+ }),
+ init: content
+ })]
+ })},
+
+ {s: "i = %s", ast: content => newNode(0, {
+ type: "ExpressionStatement",
+ end: content.end,
+ expression: newNode(0, {
+ type: "AssignmentExpression",
+ end: content.end,
+ operator: "=",
+ left: newNode(0, {
+ type: "Identifier",
+ end: 1,
+ name: "i"
+ }),
+ right: content
+ })
+ })},
+
+ {s: "((i = %s) => {})", ast: content => newNode(0, {
+ type: "ExpressionStatement",
+ end: content.end + 8,
+ expression: newNode(1, {
+ type: "ArrowFunctionExpression",
+ end: content.end + 7,
+ id: null,
+ generator: false,
+ expression: false,
+ async: false,
+ params: [
+ newNode(2, {
+ type: "AssignmentPattern",
+ end: content.end,
+ left: newNode(2, {
+ type: "Identifier",
+ end: 3,
+ name: "i"
+ }),
+ right: content
+ })
+ ],
+ body: newNode(content.end + 5, {
+ type: "BlockStatement",
+ end: content.end + 7,
+ body: []
+ })
+ })
+ })},
+
+ {s: "for (let i = 10; i < %s;++i) {}", ast: content => newNode(0, {
+ type: "ForStatement",
+ end: content.end + 8,
+ init: newNode(5, {
+ type: "VariableDeclaration",
+ end: 15,
+ declarations: [
+ newNode(9, {
+ type: "VariableDeclarator",
+ end: 15,
+ id: newNode(9, {
+ type: "Identifier",
+ end: 10,
+ name: "i"
+ }),
+ init: newNode(13, {
+ type: "Literal",
+ end: 15,
+ value: 10,
+ raw: "10"
+ })
+ })
+ ],
+ kind: "let"
+ }),
+ test: newNode(17, {
+ type: "BinaryExpression",
+ end: content.end,
+ left: newNode(17, {
+ type: "Identifier",
+ end: 18,
+ name: "i"
+ }),
+ operator: "<",
+ right: content
+ }),
+ update: newNode(content.end + 1, {
+ type: "UpdateExpression",
+ end: content.end + 4,
+ operator: "++",
+ prefix: true,
+ argument: newNode(content.end + 3, {
+ type: "Identifier",
+ end: content.end + 4,
+ name: "i"
+ })
+ }),
+ body: newNode(content.end + 6, {
+ type: "BlockStatement",
+ end: content.end + 8,
+ body: []
+ })
+ })},
+
+ {s: "i + %s", ast: content => newNode(0, {
+ type: "ExpressionStatement",
+ end: content.end,
+ expression: newNode(0, {
+ type: "BinaryExpression",
+ end: content.end,
+ left: newNode(0, {
+ type: "Identifier",
+ end: 1,
+ name: "i"
+ }),
+ operator: "+",
+ right: content
+ })
+ })}
+ ]
+ statements.forEach(statement => {
+ const start = statement.s.indexOf("%s")
+ digits.forEach(d => {
+ (d.error ? testFail : test)(
+ statement.s.replace("%s", d.d),
+ d.error ? d.error(start) : statement.ast(d.ast(start))
+ )
+ })
+ })
+
+ // Make sure we didn't break anything
+ test("123..toString(10)", newNode(0, {
+ type: "ExpressionStatement",
+ end: 17,
+ expression: newNode(0, {
+ type: "CallExpression",
+ end: 17,
+ callee: newNode(0, {
+ type: "MemberExpression",
+ end: 13,
+ object: newNode(0, {
+ type: "Literal",
+ end: 4,
+ raw: "123.",
+ value: 123
+ }),
+ property: newNode(5, {
+ type: "Identifier",
+ end: 13,
+ name: "toString"
+ }),
+ computed: false,
+ }),
+ arguments: [
+ newNode(14, {
+ type: "Literal",
+ start: 14,
+ end: 16,
+ raw: "10",
+ value: 10
+ })
+ ],
+ })
+ }))
+})
diff --git a/node-acorn-private-class-elements/.eslintrc.json b/node-acorn-private-class-elements/.eslintrc.json
new file mode 100644
index 0000000..c0442f8
--- /dev/null
+++ b/node-acorn-private-class-elements/.eslintrc.json
@@ -0,0 +1,296 @@
+{
+ "env": {
+ "es6": true,
+ "node": true
+ },
+ "extends": ["eslint:recommended", "plugin:node/recommended"],
+ "plugins": ["node"],
+ "rules": {
+ "accessor-pairs": "error",
+ "array-bracket-newline": "off",
+ "array-bracket-spacing": "off",
+ "array-callback-return": "error",
+ "array-element-newline": "off",
+ "arrow-body-style": "error",
+ "arrow-parens": [
+ "error",
+ "as-needed"
+ ],
+ "arrow-spacing": [
+ "error",
+ {
+ "after": true,
+ "before": true
+ }
+ ],
+ "block-scoped-var": "error",
+ "block-spacing": "off",
+ "brace-style": [
+ "error",
+ "1tbs",
+ {
+ "allowSingleLine": true
+ }
+ ],
+ "callback-return": "error",
+ "camelcase": "error",
+ "capitalized-comments": "off",
+ "class-methods-use-this": "error",
+ "comma-dangle": "off",
+ "comma-spacing": [
+ "error",
+ {
+ "after": true,
+ "before": false
+ }
+ ],
+ "comma-style": [
+ "error",
+ "last"
+ ],
+ "complexity": "off",
+ "computed-property-spacing": [
+ "error",
+ "never"
+ ],
+ "consistent-return": "error",
+ "consistent-this": "error",
+ "curly": [ "error", "multi-line" ],
+ "default-case": "error",
+ "dot-location": "error",
+ "dot-notation": [
+ "error",
+ {
+ "allowKeywords": true
+ }
+ ],
+ "eol-last": "error",
+ "eqeqeq": "off",
+ "for-direction": "error",
+ "func-call-spacing": "error",
+ "func-name-matching": "error",
+ "func-names": [
+ "error",
+ "never"
+ ],
+ "func-style": [
+ "error",
+ "declaration",
+ { "allowArrowFunctions": true }
+ ],
+ "function-paren-newline": "off",
+ "generator-star-spacing": "error",
+ "getter-return": "error",
+ "global-require": "error",
+ "guard-for-in": "error",
+ "handle-callback-err": "error",
+ "id-blacklist": "error",
+ "id-length": "off",
+ "id-match": "error",
+ "implicit-arrow-linebreak": [
+ "error",
+ "beside"
+ ],
+ "indent": ["error", 2],
+ "indent-legacy": "off",
+ "init-declarations": "off",
+ "jsx-quotes": "error",
+ "key-spacing": "error",
+ "keyword-spacing": [
+ "error",
+ {
+ "after": true,
+ "before": true
+ }
+ ],
+ "line-comment-position": "off",
+ "linebreak-style": [
+ "error",
+ "unix"
+ ],
+ "lines-around-comment": "error",
+ "lines-around-directive": "error",
+ "lines-between-class-members": "error",
+ "max-depth": "error",
+ "max-len": "off",
+ "max-lines": "off",
+ "max-nested-callbacks": "error",
+ "max-params": "off",
+ "max-statements": "off",
+ "max-statements-per-line": "off",
+ "multiline-comment-style": [
+ "error",
+ "separate-lines"
+ ],
+ "new-cap": "error",
+ "new-parens": "error",
+ "newline-after-var": "off",
+ "newline-before-return": "off",
+ "newline-per-chained-call": "off",
+ "no-alert": "error",
+ "no-array-constructor": "error",
+ "no-await-in-loop": "error",
+ "no-bitwise": "error",
+ "no-buffer-constructor": "error",
+ "no-caller": "error",
+ "no-catch-shadow": "error",
+ "no-confusing-arrow": "error",
+ "no-continue": "off",
+ "no-div-regex": "error",
+ "no-duplicate-imports": "error",
+ "no-else-return": "error",
+ "no-empty-function": "error",
+ "no-eq-null": "error",
+ "no-eval": "error",
+ "no-extend-native": "error",
+ "no-extra-bind": "error",
+ "no-extra-label": "error",
+ "no-extra-parens": "off",
+ "no-floating-decimal": "error",
+ "no-implicit-coercion": "error",
+ "no-implicit-globals": "error",
+ "no-implied-eval": "error",
+ "no-inline-comments": "off",
+ "no-invalid-this": "off",
+ "no-iterator": "error",
+ "no-label-var": "error",
+ "no-labels": "error",
+ "no-lone-blocks": "error",
+ "no-lonely-if": "off",
+ "no-loop-func": "error",
+ "no-magic-numbers": "off",
+ "no-mixed-operators": "off",
+ "no-mixed-requires": "error",
+ "no-multi-assign": "error",
+ "no-multi-spaces": "error",
+ "no-multi-str": "error",
+ "no-multiple-empty-lines": ["error", { "max": 1, "maxEOF": 0, "maxBOF": 0 }],
+ "no-native-reassign": "error",
+ "no-negated-condition": "off",
+ "no-negated-in-lhs": "error",
+ "no-nested-ternary": "error",
+ "no-new": "error",
+ "no-new-func": "error",
+ "no-new-object": "error",
+ "no-new-require": "error",
+ "no-new-wrappers": "error",
+ "no-octal-escape": "error",
+ "no-param-reassign": "off",
+ "no-path-concat": "error",
+ "no-plusplus": "off",
+ "no-process-env": "error",
+ "no-process-exit": "error",
+ "no-proto": "error",
+ "no-prototype-builtins": "error",
+ "no-restricted-globals": "error",
+ "no-restricted-imports": "error",
+ "no-restricted-modules": "error",
+ "no-restricted-properties": "error",
+ "no-restricted-syntax": "error",
+ "no-return-assign": "error",
+ "no-return-await": "error",
+ "no-script-url": "error",
+ "no-self-compare": "error",
+ "no-sequences": "error",
+ "no-shadow": "error",
+ "no-shadow-restricted-names": "error",
+ "no-spaced-func": "error",
+ "no-sync": [
+ "error",
+ {
+ "allowAtRootLevel": true
+ }
+ ],
+ "no-tabs": "error",
+ "no-template-curly-in-string": "error",
+ "no-ternary": "off",
+ "no-throw-literal": "error",
+ "no-trailing-spaces": "error",
+ "no-undef-init": "error",
+ "no-undefined": "error",
+ "no-underscore-dangle": "off",
+ "no-unmodified-loop-condition": "error",
+ "no-unneeded-ternary": "error",
+ "no-unused-expressions": "error",
+ "no-unused-vars": ["error", {"argsIgnorePattern": "^_"}],
+ "no-use-before-define": "error",
+ "no-useless-call": "error",
+ "no-useless-computed-key": "error",
+ "no-useless-concat": "error",
+ "no-useless-constructor": "error",
+ "no-useless-rename": "error",
+ "no-useless-return": "error",
+ "no-var": "error",
+ "no-void": "error",
+ "no-warning-comments": "warn",
+ "no-whitespace-before-property": "error",
+ "no-with": "error",
+ "nonblock-statement-body-position": [
+ "error",
+ "any"
+ ],
+ "object-curly-newline": "off",
+ "object-curly-spacing": "off",
+ "object-property-newline": "off",
+ "object-shorthand": "off",
+ "one-var": "off",
+ "one-var-declaration-per-line": "off",
+ "operator-assignment": "error",
+ "operator-linebreak": "error",
+ "padded-blocks": "off",
+ "padding-line-between-statements": "error",
+ "prefer-arrow-callback": "off",
+ "prefer-const": "off",
+ "prefer-destructuring": "off",
+ "prefer-numeric-literals": "error",
+ "prefer-promise-reject-errors": "error",
+ "prefer-reflect": "off",
+ "prefer-rest-params": "off",
+ "prefer-spread": "error",
+ "prefer-template": "error",
+ "quote-props": ["error", "as-needed"],
+ "quotes": ["error", "double"],
+ "radix": "error",
+ "require-await": "error",
+ "require-jsdoc": "off",
+ "rest-spread-spacing": "error",
+ "semi": ["error", "never"],
+ "semi-spacing": "error",
+ "semi-style": [
+ "error",
+ "last"
+ ],
+ "sort-imports": "error",
+ "sort-keys": "off",
+ "sort-vars": "off",
+ "space-before-blocks": "error",
+ "space-before-function-paren": "off",
+ "space-in-parens": [
+ "error",
+ "never"
+ ],
+ "space-infix-ops": "error",
+ "space-unary-ops": "error",
+ "spaced-comment": "off",
+ "strict": "error",
+ "switch-colon-spacing": "error",
+ "symbol-description": "error",
+ "template-curly-spacing": "error",
+ "template-tag-spacing": "error",
+ "unicode-bom": [
+ "error",
+ "never"
+ ],
+ "valid-jsdoc": "error",
+ "vars-on-top": "off",
+ "wrap-regex": "error",
+ "yield-star-spacing": "error",
+ "yoda": [
+ "error",
+ "never"
+ ],
+ "node/no-unpublished-require": "off",
+ "no-proto": "warn",
+ "no-empty-function": "off"
+ }
+}
diff --git a/node-acorn-private-class-elements/.gitignore b/node-acorn-private-class-elements/.gitignore
new file mode 100644
index 0000000..c2658d7
--- /dev/null
+++ b/node-acorn-private-class-elements/.gitignore
@@ -0,0 +1 @@
+node_modules/
diff --git a/node-acorn-private-class-elements/CHANGELOG.md b/node-acorn-private-class-elements/CHANGELOG.md
new file mode 100644
index 0000000..5b49344
--- /dev/null
+++ b/node-acorn-private-class-elements/CHANGELOG.md
@@ -0,0 +1,7 @@
+## 0.1.1 (2019-02-09)
+
+* Add \_branch() method
+
+## 0.1.0 (2019-02-09)
+
+Initial release
diff --git a/node-acorn-private-class-elements/LICENSE b/node-acorn-private-class-elements/LICENSE
new file mode 100644
index 0000000..7c2b27a
--- /dev/null
+++ b/node-acorn-private-class-elements/LICENSE
@@ -0,0 +1,19 @@
+Copyright (C) 2017-2018 by Adrian Heine
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+THE SOFTWARE.
diff --git a/node-acorn-private-class-elements/README.md b/node-acorn-private-class-elements/README.md
new file mode 100644
index 0000000..0d22882
--- /dev/null
+++ b/node-acorn-private-class-elements/README.md
@@ -0,0 +1,11 @@
+# Helpers for supporting private class methods and fields for Acorn
+
+[![NPM version](https://img.shields.io/npm/v/acorn-private-class-elements.svg)](https://www.npmjs.org/package/acorn-private-class-elements)
+
+This is a plugin for [Acorn](http://marijnhaverbeke.nl/acorn/) - a tiny, fast JavaScript parser, written completely in JavaScript.
+
+It provides helpers for implementing support for private class elements. The emitted AST follows [an ESTree proposal](https://github.com/estree/estree/pull/180).
+
+## License
+
+This plugin is released under an [MIT License](./LICENSE).
diff --git a/node-acorn-private-class-elements/index.js b/node-acorn-private-class-elements/index.js
new file mode 100644
index 0000000..d0d15e0
--- /dev/null
+++ b/node-acorn-private-class-elements/index.js
@@ -0,0 +1,123 @@
+"use strict"
+
+const acorn = require("acorn")
+if (acorn.version.indexOf("6.") != 0 || acorn.version.indexOf("6.0.") == 0) {
+ throw new Error(`acorn-private-class-elements requires acorn@^6.1.0, not ${acorn.version}`)
+}
+const tt = acorn.tokTypes
+const TokenType = acorn.TokenType
+
+module.exports = function(Parser) {
+ // Only load this plugin once.
+ if (Parser.prototype.parsePrivateName) {
+ return Parser
+ }
+
+ // Make sure `Parser` comes from the same acorn as our `tt`,
+ // otherwise the comparisons fail.
+ let cur = Parser
+ while (cur && cur !== acorn.Parser) {
+ cur = cur.__proto__
+ }
+ if (cur !== acorn.Parser) {
+ throw new Error("acorn-private-class-elements does not support mixing different acorn copies")
+ }
+
+ Parser = class extends Parser {
+ _branch() {
+ this.__branch = this.__branch || new Parser({ecmaVersion: this.options.ecmaVersion}, this.input)
+ this.__branch.end = this.end
+ this.__branch.pos = this.pos
+ this.__branch.type = this.type
+ this.__branch.value = this.value
+ this.__branch.containsEsc = this.containsEsc
+ return this.__branch
+ }
+
+ parsePrivateClassElementName(element) {
+ element.computed = false
+ element.key = this.parsePrivateName()
+ if (element.key.name == "constructor") this.raise(element.key.start, "Classes may not have a private element named constructor")
+ const accept = {get: "set", set: "get"}[element.kind]
+ const privateBoundNames = this._privateBoundNamesStack[this._privateBoundNamesStack.length - 1]
+ if (Object.prototype.hasOwnProperty.call(privateBoundNames, element.key.name) && privateBoundNames[element.key.name] !== accept) {
+ this.raise(element.start, "Duplicate private element")
+ }
+ privateBoundNames[element.key.name] = element.kind || true
+ delete this._unresolvedPrivateNamesStack[this._unresolvedPrivateNamesStack.length - 1][element.key.name]
+ return element.key
+ }
+
+ parsePrivateName() {
+ const node = this.startNode()
+ node.name = this.value
+ this.next()
+ this.finishNode(node, "PrivateName")
+ if (this.options.allowReserved == "never") this.checkUnreserved(node)
+ return node
+ }
+
+ // Parse # token
+ getTokenFromCode(code) {
+ if (code === 35) {
+ ++this.pos
+ const word = this.readWord1()
+ return this.finishToken(this.privateNameToken, word)
+ }
+ return super.getTokenFromCode(code)
+ }
+
+ // Manage stacks and check for undeclared private names
+ parseClass(node, isStatement) {
+ this._privateBoundNamesStack = this._privateBoundNamesStack || []
+ const privateBoundNames = Object.create(this._privateBoundNamesStack[this._privateBoundNamesStack.length - 1] || null)
+ this._privateBoundNamesStack.push(privateBoundNames)
+ this._unresolvedPrivateNamesStack = this._unresolvedPrivateNamesStack || []
+ const unresolvedPrivateNames = Object.create(null)
+ this._unresolvedPrivateNamesStack.push(unresolvedPrivateNames)
+ const _return = super.parseClass(node, isStatement)
+ this._privateBoundNamesStack.pop()
+ this._unresolvedPrivateNamesStack.pop()
+ if (!this._unresolvedPrivateNamesStack.length) {
+ const names = Object.keys(unresolvedPrivateNames)
+ if (names.length) {
+ names.sort((n1, n2) => unresolvedPrivateNames[n1] - unresolvedPrivateNames[n2])
+ this.raise(unresolvedPrivateNames[names[0]], "Usage of undeclared private name")
+ }
+ } else Object.assign(this._unresolvedPrivateNamesStack[this._unresolvedPrivateNamesStack.length - 1], unresolvedPrivateNames)
+ return _return
+ }
+
+ // Parse private element access
+ parseSubscript(base, startPos, startLoc, noCalls, maybeAsyncArrow) {
+ if (!this.eat(tt.dot)) {
+ return super.parseSubscript(base, startPos, startLoc, noCalls, maybeAsyncArrow)
+ }
+ let node = this.startNodeAt(startPos, startLoc)
+ node.object = base
+ node.computed = false
+ if (this.type == this.privateNameToken) {
+ node.property = this.parsePrivateName()
+ if (!this._privateBoundNamesStack.length || !this._privateBoundNamesStack[this._privateBoundNamesStack.length - 1][node.property.name]) {
+ this._unresolvedPrivateNamesStack[this._unresolvedPrivateNamesStack.length - 1][node.property.name] = node.property.start
+ }
+ } else {
+ node.property = this.parseIdent(true)
+ }
+ return this.finishNode(node, "MemberExpression")
+ }
+
+ // Prohibit delete of private class elements
+ parseMaybeUnary(refDestructuringErrors, sawUnary) {
+ const _return = super.parseMaybeUnary(refDestructuringErrors, sawUnary)
+ if (_return.operator == "delete") {
+ if (_return.argument.type == "MemberExpression" && _return.argument.property.type == "PrivateName") {
+ this.raise(_return.start, "Private elements may not be deleted")
+ }
+ }
+ return _return
+ }
+ }
+ Parser.prototype.privateNameToken = new TokenType("privateName")
+ return Parser
+}
diff --git a/node-acorn-private-class-elements/package.json b/node-acorn-private-class-elements/package.json
new file mode 100644
index 0000000..b5e5fd4
--- /dev/null
+++ b/node-acorn-private-class-elements/package.json
@@ -0,0 +1,32 @@
+{
+ "name": "acorn-private-class-elements",
+ "description": "Helpers for supporting private class methods and fields in acorn",
+ "homepage": "https://github.com/acornjs/acorn-private-class-elements",
+ "contributors": [
+ "Adrian Heine <mail@adrianheine.de>"
+ ],
+ "engines": {
+ "node": ">=4.8.2"
+ },
+ "repository": {
+ "type": "git",
+ "url": "https://github.com/acornjs/acorn-private-class-elements"
+ },
+ "license": "MIT",
+ "scripts": {
+ "test": "mocha",
+ "lint": "eslint -c .eslintrc.json ."
+ },
+ "peerDependencies": {
+ "acorn": "^6.1.0"
+ },
+ "version": "0.1.1",
+ "devDependencies": {
+ "acorn": "^6.1.0",
+ "eslint": "^5.13.0",
+ "eslint-plugin-node": "^8.0.1"
+ },
+ "dependencies": {
+ "mocha": "^5.2.0"
+ }
+}
diff --git a/node-acorn-private-class-elements/test/.eslintrc.json b/node-acorn-private-class-elements/test/.eslintrc.json
new file mode 100644
index 0000000..4668ae7
--- /dev/null
+++ b/node-acorn-private-class-elements/test/.eslintrc.json
@@ -0,0 +1,5 @@
+{
+ "env": {
+ "mocha": true
+ }
+}
diff --git a/node-acorn-private-class-elements/test/test.js b/node-acorn-private-class-elements/test/test.js
new file mode 100644
index 0000000..0ea78be
--- /dev/null
+++ b/node-acorn-private-class-elements/test/test.js
@@ -0,0 +1,15 @@
+"use strict"
+
+const assert = require("assert")
+const acorn = require("acorn")
+const privateClassElements = require("..")
+
+describe("acorn-private-class-elements", () => {
+ it("does not inject itself twice", () => {
+ const first = privateClassElements(acorn.Parser)
+ assert.strictEqual(first, privateClassElements(first))
+ })
+ it("checks that the same acorn copy is used", () => {
+ assert.throws(() => privateClassElements(function () {}))
+ })
+})
diff --git a/node-acorn-private-methods/.eslintrc.json b/node-acorn-private-methods/.eslintrc.json
new file mode 100644
index 0000000..3981ed4
--- /dev/null
+++ b/node-acorn-private-methods/.eslintrc.json
@@ -0,0 +1,294 @@
+{
+ "env": {
+ "es6": true,
+ "node": true
+ },
+ "extends": ["eslint:recommended", "plugin:node/recommended"],
+ "plugins": ["node"],
+ "rules": {
+ "accessor-pairs": "error",
+ "array-bracket-newline": "off",
+ "array-bracket-spacing": "off",
+ "array-callback-return": "error",
+ "array-element-newline": "off",
+ "arrow-body-style": "error",
+ "arrow-parens": [
+ "error",
+ "as-needed"
+ ],
+ "arrow-spacing": [
+ "error",
+ {
+ "after": true,
+ "before": true
+ }
+ ],
+ "block-scoped-var": "error",
+ "block-spacing": "off",
+ "brace-style": [
+ "error",
+ "1tbs",
+ {
+ "allowSingleLine": true
+ }
+ ],
+ "callback-return": "error",
+ "camelcase": "error",
+ "capitalized-comments": "off",
+ "class-methods-use-this": "error",
+ "comma-dangle": "off",
+ "comma-spacing": [
+ "error",
+ {
+ "after": true,
+ "before": false
+ }
+ ],
+ "comma-style": [
+ "error",
+ "last"
+ ],
+ "complexity": "off",
+ "computed-property-spacing": [
+ "error",
+ "never"
+ ],
+ "consistent-return": "error",
+ "consistent-this": "error",
+ "curly": [ "error", "multi-line" ],
+ "default-case": "error",
+ "dot-location": "error",
+ "dot-notation": [
+ "error",
+ {
+ "allowKeywords": true
+ }
+ ],
+ "eol-last": "error",
+ "eqeqeq": "off",
+ "for-direction": "error",
+ "func-call-spacing": "error",
+ "func-name-matching": "error",
+ "func-names": [
+ "error",
+ "never"
+ ],
+ "func-style": [
+ "error",
+ "declaration",
+ { "allowArrowFunctions": true }
+ ],
+ "function-paren-newline": "off",
+ "generator-star-spacing": "error",
+ "getter-return": "error",
+ "global-require": "error",
+ "guard-for-in": "error",
+ "handle-callback-err": "error",
+ "id-blacklist": "error",
+ "id-length": "off",
+ "id-match": "error",
+ "implicit-arrow-linebreak": [
+ "error",
+ "beside"
+ ],
+ "indent": ["error", 2],
+ "indent-legacy": "off",
+ "init-declarations": "off",
+ "jsx-quotes": "error",
+ "key-spacing": "error",
+ "keyword-spacing": [
+ "error",
+ {
+ "after": true,
+ "before": true
+ }
+ ],
+ "line-comment-position": "off",
+ "linebreak-style": [
+ "error",
+ "unix"
+ ],
+ "lines-around-comment": "error",
+ "lines-around-directive": "error",
+ "lines-between-class-members": "error",
+ "max-depth": "error",
+ "max-len": "off",
+ "max-lines": "off",
+ "max-nested-callbacks": "error",
+ "max-params": "off",
+ "max-statements": "off",
+ "max-statements-per-line": "off",
+ "multiline-comment-style": [
+ "error",
+ "separate-lines"
+ ],
+ "new-cap": "error",
+ "new-parens": "error",
+ "newline-after-var": "off",
+ "newline-before-return": "off",
+ "newline-per-chained-call": "off",
+ "no-alert": "error",
+ "no-array-constructor": "error",
+ "no-await-in-loop": "error",
+ "no-bitwise": "error",
+ "no-buffer-constructor": "error",
+ "no-caller": "error",
+ "no-catch-shadow": "error",
+ "no-confusing-arrow": "error",
+ "no-continue": "off",
+ "no-div-regex": "error",
+ "no-duplicate-imports": "error",
+ "no-else-return": "error",
+ "no-empty-function": "error",
+ "no-eq-null": "error",
+ "no-eval": "error",
+ "no-extend-native": "error",
+ "no-extra-bind": "error",
+ "no-extra-label": "error",
+ "no-extra-parens": "off",
+ "no-floating-decimal": "error",
+ "no-implicit-coercion": "error",
+ "no-implicit-globals": "error",
+ "no-implied-eval": "error",
+ "no-inline-comments": "off",
+ "no-invalid-this": "off",
+ "no-iterator": "error",
+ "no-label-var": "error",
+ "no-labels": "error",
+ "no-lone-blocks": "error",
+ "no-lonely-if": "off",
+ "no-loop-func": "error",
+ "no-magic-numbers": "off",
+ "no-mixed-operators": "off",
+ "no-mixed-requires": "error",
+ "no-multi-assign": "error",
+ "no-multi-spaces": "error",
+ "no-multi-str": "error",
+ "no-multiple-empty-lines": ["error", { "max": 1, "maxEOF": 0, "maxBOF": 0 }],
+ "no-native-reassign": "error",
+ "no-negated-condition": "off",
+ "no-negated-in-lhs": "error",
+ "no-nested-ternary": "error",
+ "no-new": "error",
+ "no-new-func": "error",
+ "no-new-object": "error",
+ "no-new-require": "error",
+ "no-new-wrappers": "error",
+ "no-octal-escape": "error",
+ "no-param-reassign": "off",
+ "no-path-concat": "error",
+ "no-plusplus": "off",
+ "no-process-env": "error",
+ "no-process-exit": "error",
+ "no-proto": "error",
+ "no-prototype-builtins": "error",
+ "no-restricted-globals": "error",
+ "no-restricted-imports": "error",
+ "no-restricted-modules": "error",
+ "no-restricted-properties": "error",
+ "no-restricted-syntax": "error",
+ "no-return-assign": "error",
+ "no-return-await": "error",
+ "no-script-url": "error",
+ "no-self-compare": "error",
+ "no-sequences": "error",
+ "no-shadow": "error",
+ "no-shadow-restricted-names": "error",
+ "no-spaced-func": "error",
+ "no-sync": [
+ "error",
+ {
+ "allowAtRootLevel": true
+ }
+ ],
+ "no-tabs": "error",
+ "no-template-curly-in-string": "error",
+ "no-ternary": "off",
+ "no-throw-literal": "error",
+ "no-trailing-spaces": "error",
+ "no-undef-init": "error",
+ "no-undefined": "error",
+ "no-underscore-dangle": "off",
+ "no-unmodified-loop-condition": "error",
+ "no-unneeded-ternary": "error",
+ "no-unused-expressions": "error",
+ "no-unused-vars": ["error", {"argsIgnorePattern": "^_"}],
+ "no-use-before-define": "error",
+ "no-useless-call": "error",
+ "no-useless-computed-key": "error",
+ "no-useless-concat": "error",
+ "no-useless-constructor": "error",
+ "no-useless-rename": "error",
+ "no-useless-return": "error",
+ "no-var": "error",
+ "no-void": "error",
+ "no-warning-comments": "warn",
+ "no-whitespace-before-property": "error",
+ "no-with": "error",
+ "nonblock-statement-body-position": [
+ "error",
+ "any"
+ ],
+ "object-curly-newline": "off",
+ "object-curly-spacing": "off",
+ "object-property-newline": "off",
+ "object-shorthand": "off",
+ "one-var": "off",
+ "one-var-declaration-per-line": "off",
+ "operator-assignment": "error",
+ "operator-linebreak": "error",
+ "padded-blocks": "off",
+ "padding-line-between-statements": "error",
+ "prefer-arrow-callback": "off",
+ "prefer-const": "off",
+ "prefer-destructuring": "off",
+ "prefer-numeric-literals": "error",
+ "prefer-promise-reject-errors": "error",
+ "prefer-reflect": "off",
+ "prefer-rest-params": "off",
+ "prefer-spread": "error",
+ "prefer-template": "error",
+ "quote-props": ["error", "as-needed"],
+ "quotes": ["error", "double"],
+ "radix": "error",
+ "require-await": "error",
+ "require-jsdoc": "off",
+ "rest-spread-spacing": "error",
+ "semi": ["error", "never"],
+ "semi-spacing": "error",
+ "semi-style": [
+ "error",
+ "last"
+ ],
+ "sort-imports": "error",
+ "sort-keys": "off",
+ "sort-vars": "off",
+ "space-before-blocks": "error",
+ "space-before-function-paren": "off",
+ "space-in-parens": [
+ "error",
+ "never"
+ ],
+ "space-infix-ops": "error",
+ "space-unary-ops": "error",
+ "spaced-comment": "off",
+ "strict": "error",
+ "switch-colon-spacing": "error",
+ "symbol-description": "error",
+ "template-curly-spacing": "error",
+ "template-tag-spacing": "error",
+ "unicode-bom": [
+ "error",
+ "never"
+ ],
+ "valid-jsdoc": "error",
+ "vars-on-top": "off",
+ "wrap-regex": "error",
+ "yield-star-spacing": "error",
+ "yoda": [
+ "error",
+ "never"
+ ],
+ "node/no-unpublished-require": "off"
+ }
+}
diff --git a/node-acorn-private-methods/.gitignore b/node-acorn-private-methods/.gitignore
new file mode 100644
index 0000000..c2658d7
--- /dev/null
+++ b/node-acorn-private-methods/.gitignore
@@ -0,0 +1 @@
+node_modules/
diff --git a/node-acorn-private-methods/CHANGELOG.md b/node-acorn-private-methods/CHANGELOG.md
new file mode 100644
index 0000000..5de4b97
--- /dev/null
+++ b/node-acorn-private-methods/CHANGELOG.md
@@ -0,0 +1,29 @@
+## 0.3.0 (2019-02-09)
+
+* Require acorn >= 6.1.0
+
+## 0.2.3 (2019-02-09)
+
+* Forbid binding await in async arrow function's parameter list
+
+## 0.2.2 (2019-01-30)
+
+* Fix parsing of chained subscripts
+
+## 0.2.1 (2018-11-06)
+
+* Adapt to changes in acorn 6.0.3
+
+## 0.2.0 (2018-09-14)
+
+* Update to new acorn 6 interface
+* Change license to MIT
+* Don't allow direct super() calls in private methods
+
+## 0.1.1 (2018-02-09)
+
+* Don't accept whitespace between hash and private name
+
+## 0.1.0 (2018-01-13)
+
+Initial release
diff --git a/node-acorn-private-methods/LICENSE b/node-acorn-private-methods/LICENSE
new file mode 100644
index 0000000..7c2b27a
--- /dev/null
+++ b/node-acorn-private-methods/LICENSE
@@ -0,0 +1,19 @@
+Copyright (C) 2017-2018 by Adrian Heine
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+THE SOFTWARE.
diff --git a/node-acorn-private-methods/README.md b/node-acorn-private-methods/README.md
new file mode 100644
index 0000000..6929e84
--- /dev/null
+++ b/node-acorn-private-methods/README.md
@@ -0,0 +1,21 @@
+# Private methods and getter/setters support for Acorn
+
+[![NPM version](https://img.shields.io/npm/v/acorn-private-methods.svg)](https://www.npmjs.org/package/acorn-private-methods)
+
+This is a plugin for [Acorn](http://marijnhaverbeke.nl/acorn/) - a tiny, fast JavaScript parser, written completely in JavaScript.
+
+It implements support for private methods, getters and setters as defined in the stage 3 proposal [Private methods and getter/setters for JavaScript classes](https://github.com/tc39/proposal-private-methods). The emitted AST follows [an ESTree proposal](https://github.com/estree/estree/pull/180).
+
+## Usage
+
+This module provides a plugin that can be used to extend the Acorn `Parser` class:
+
+```javascript
+const {Parser} = require('acorn');
+const privateMethods = require('acorn-private-methods');
+Parser.extend(privateMethods).parse('class X { #a() {} }');
+```
+
+## License
+
+This plugin is released under an [MIT License](./LICENSE).
diff --git a/node-acorn-private-methods/index.js b/node-acorn-private-methods/index.js
new file mode 100644
index 0000000..7f3860e
--- /dev/null
+++ b/node-acorn-private-methods/index.js
@@ -0,0 +1,25 @@
+"use strict"
+
+const privateClassElements = require("acorn-private-class-elements")
+
+module.exports = function(Parser) {
+ const ExtendedParser = privateClassElements(Parser)
+
+ return class extends ExtendedParser {
+ // Parse private methods
+ parseClassElement(_constructorAllowsSuper) {
+ const oldInClassMemberName = this._inClassMemberName
+ this._inClassMemberName = true
+ const result = super.parseClassElement.apply(this, arguments)
+ this._inClassMemberName = oldInClassMemberName
+ return result
+ }
+
+ parsePropertyName(prop) {
+ const isPrivate = this.options.ecmaVersion >= 8 && this._inClassMemberName && this.type == this.privateNameToken
+ this._inClassMemberName = false
+ if (!isPrivate) return super.parsePropertyName(prop)
+ return this.parsePrivateClassElementName(prop)
+ }
+ }
+}
diff --git a/node-acorn-private-methods/package.json b/node-acorn-private-methods/package.json
new file mode 100644
index 0000000..8f485cf
--- /dev/null
+++ b/node-acorn-private-methods/package.json
@@ -0,0 +1,36 @@
+{
+ "name": "acorn-private-methods",
+ "description": "Support for private methods in acorn",
+ "homepage": "https://github.com/acornjs/acorn-private-methods",
+ "contributors": [
+ "Adrian Heine <mail@adrianheine.de>"
+ ],
+ "engines": {
+ "node": ">=4.8.2"
+ },
+ "repository": {
+ "type": "git",
+ "url": "https://github.com/acornjs/acorn-private-methods"
+ },
+ "license": "MIT",
+ "scripts": {
+ "test": "mocha",
+ "test:test262": "node run_test262.js",
+ "lint": "eslint -c .eslintrc.json ."
+ },
+ "peerDependencies": {
+ "acorn": "^6.1.0"
+ },
+ "dependencies": {
+ "acorn-private-class-elements": "^0.1.0"
+ },
+ "version": "0.3.0",
+ "devDependencies": {
+ "acorn": "^6.1.0",
+ "eslint": "^5.13.0",
+ "eslint-plugin-node": "^8.0.1",
+ "mocha": "^5.2.0",
+ "test262": "git+https://github.com/tc39/test262.git#33a306d1026b72227eb50a918db19ada16f12b3d",
+ "test262-parser-runner": "^0.5.0"
+ }
+}
diff --git a/node-acorn-private-methods/run_test262.js b/node-acorn-private-methods/run_test262.js
new file mode 100644
index 0000000..9cb4bc7
--- /dev/null
+++ b/node-acorn-private-methods/run_test262.js
@@ -0,0 +1,30 @@
+"use strict"
+
+const fs = require("fs")
+const path = require("path")
+const run = require("test262-parser-runner")
+const acorn = require("acorn")
+const privateMethods = require(".")
+const Parser = acorn.Parser.extend(privateMethods)
+
+const unsupportedFeatures = [
+ "BigInt",
+ "class-fields-private",
+ "class-fields-public",
+ "class-static-fields-public",
+ "class-static-fields-private",
+ "class-static-methods-private"
+]
+
+const implementedFeatures = [
+ "class-methods-private"
+]
+
+run(
+ (content, options) => Parser.parse(content, {sourceType: options.sourceType, ecmaVersion: 9}),
+ {
+ testsDirectory: path.dirname(require.resolve("test262/package.json")),
+ skip: test => (!test.attrs.features || !implementedFeatures.some(f => test.attrs.features.includes(f)) || unsupportedFeatures.some(f => test.attrs.features.includes(f))),
+ whitelist: fs.readFileSync("./test262.whitelist", "utf8").split("\n").filter(v => v && v[0] !== "#")
+ }
+)
diff --git a/node-acorn-private-methods/test/.eslintrc.json b/node-acorn-private-methods/test/.eslintrc.json
new file mode 100644
index 0000000..4668ae7
--- /dev/null
+++ b/node-acorn-private-methods/test/.eslintrc.json
@@ -0,0 +1,5 @@
+{
+ "env": {
+ "mocha": true
+ }
+}
diff --git a/node-acorn-private-methods/test/test.js b/node-acorn-private-methods/test/test.js
new file mode 100644
index 0000000..e9fc8f0
--- /dev/null
+++ b/node-acorn-private-methods/test/test.js
@@ -0,0 +1,285 @@
+"use strict"
+
+const assert = require("assert")
+const acorn = require("acorn")
+const privateMethods = require("..")
+const Parser = acorn.Parser.extend(privateMethods)
+
+function test(text, expectedResult, additionalOptions) {
+ it(text, function () {
+ const result = Parser.parse(text, Object.assign({ ecmaVersion: 9 }, additionalOptions))
+ if (expectedResult) assert.deepStrictEqual(result.body[0], expectedResult)
+ })
+}
+function testFail(text, expectedError, additionalOptions) {
+ it(text, function () {
+ let failed = false
+ try {
+ Parser.parse(text, Object.assign({ ecmaVersion: 9, plugins: { privateMethods: true } }, additionalOptions))
+ } catch (e) {
+ assert.strictEqual(e.message, expectedError)
+ failed = true
+ }
+ assert(failed)
+ })
+}
+
+const newNode = (start, props) => Object.assign(new acorn.Node({options: {}}, start), props)
+describe("acorn-private-methods", function () {
+ test("class A { a() { this.#a }; #a() {} }")
+ test(`var C = class {
+ #m() { return 42; }
+ constructor() {
+ (() => this)().#m
+ }
+}`)
+
+ testFail("class A { #a() {}; f() { delete this.#a } }", "Private elements may not be deleted (1:25)")
+ testFail("class A { #a() {}; #a() {} }", "Duplicate private element (1:19)")
+ test("class A { get #a() {}; set #a(newA) {} }")
+ testFail("class A { a() { this.#a } }", "Usage of undeclared private name (1:21)")
+ testFail("class A { a() { this.#a } b() { this.#b } }", "Usage of undeclared private name (1:21)")
+ testFail("class A { #constructor() {} }", "Classes may not have a private element named constructor (1:10)")
+ testFail("class A { #[ab]() {} }", "Unexpected token (1:11)")
+ testFail("a = { #ab() {} }", "Unexpected token (1:6)")
+ testFail("class A { [{#ab() {}}]() {} }", "Unexpected token (1:12)")
+ testFail("class A{ # a() {}}", "Unexpected token (1:11)")
+ testFail("class C{ #method() { super(); } };", "super() call outside constructor of a subclass (1:21)")
+ test("class C{ #method() { super.y(); } };")
+
+ const classes = [
+ { text: "class A { %s }", ast: getBody => {
+ const body = getBody(10)
+ return newNode(0, {
+ type: "ClassDeclaration",
+ end: body.end + 2,
+ id: newNode(6, {
+ type: "Identifier",
+ end: 7,
+ name: "A"
+ }),
+ superClass: null,
+ body: newNode(8, {
+ type: "ClassBody",
+ end: body.end + 2,
+ body: [body]
+ })
+ })
+ } },
+ { text: "class A { %s; }", ast: getBody => {
+ const body = getBody(10)
+ return newNode(0, {
+ type: "ClassDeclaration",
+ end: body.end + 3,
+ id: newNode(6, {
+ type: "Identifier",
+ end: 7,
+ name: "A"
+ }),
+ superClass: null,
+ body: newNode(8, {
+ type: "ClassBody",
+ end: body.end + 3,
+ body: [body]
+ })
+ })
+ } },
+ { text: "class A { %s; #y() {} }", ast: getBody => {
+ const body = getBody(10)
+ return newNode(0, {
+ type: "ClassDeclaration",
+ end: body.end + 11,
+ id: newNode(6, {
+ type: "Identifier",
+ end: 7,
+ name: "A"
+ }),
+ superClass: null,
+ body: newNode(8, {
+ type: "ClassBody",
+ end: body.end + 11,
+ body: [body, newNode(body.end + 2, {
+ type: "MethodDefinition",
+ end: body.end + 9,
+ kind: "method",
+ static: false,
+ computed: false,
+ key: newNode(body.end + 2, {
+ type: "PrivateName",
+ end: body.end + 4,
+ name: "y"
+ }),
+ value: newNode(body.end + 4, {
+ type: "FunctionExpression",
+ end: body.end + 9,
+ id: null,
+ generator: false,
+ expression: false,
+ async: false,
+ params: [],
+ body: newNode(body.end + 7, {
+ type: "BlockStatement",
+ end: body.end + 9,
+ body: []
+ })
+ })
+ }) ]
+ })
+ })
+ } },
+ { text: "class A { %s;a() {} }", ast: getBody => {
+ const body = getBody(10)
+ return newNode(0, {
+ type: "ClassDeclaration",
+ end: body.end + 9,
+ id: newNode(6, {
+ type: "Identifier",
+ end: 7,
+ name: "A"
+ }),
+ superClass: null,
+ body: newNode(8, {
+ type: "ClassBody",
+ end: body.end + 9,
+ body: [ body, newNode(body.end + 1, {
+ type: "MethodDefinition",
+ end: body.end + 7,
+ kind: "method",
+ static: false,
+ computed: false,
+ key: newNode(body.end + 1, {
+ type: "Identifier",
+ end: body.end + 2,
+ name: "a"
+ }),
+ value: newNode(body.end + 2, {
+ type: "FunctionExpression",
+ end: body.end + 7,
+ id: null,
+ generator: false,
+ expression: false,
+ async: false,
+ params: [],
+ body: newNode(body.end + 5, {
+ type: "BlockStatement",
+ end: body.end + 7,
+ body: []
+ })
+ })
+ }) ]
+ })
+ })
+ } },
+ { text: "class A { %s\na() {} }", ast: getBody => {
+ const body = getBody(10)
+ return newNode(0, {
+ type: "ClassDeclaration",
+ end: body.end + 9,
+ id: newNode(6, {
+ type: "Identifier",
+ end: 7,
+ name: "A"
+ }),
+ superClass: null,
+ body: newNode(8, {
+ type: "ClassBody",
+ end: body.end + 9,
+ body: [
+ body,
+ newNode(body.end + 1, {
+ type: "MethodDefinition",
+ end: body.end + 7,
+ kind: "method",
+ static: false,
+ computed: false,
+ key: newNode(body.end + 1, {
+ type: "Identifier",
+ end: body.end + 2,
+ name: "a"
+ }),
+ value: newNode(body.end + 2, {
+ type: "FunctionExpression",
+ end: body.end + 7,
+ id: null,
+ generator: false,
+ expression: false,
+ async: false,
+ params: [],
+ body: newNode(body.end + 5, {
+ type: "BlockStatement",
+ end: body.end + 7,
+ body: []
+ })
+ })
+ })
+ ]
+ })
+ })
+ } },
+ ];
+
+ [
+ { body: "#x() {}", passes: true, ast: start => newNode(start, {
+ type: "MethodDefinition",
+ end: start + 7,
+ computed: false,
+ key: newNode(start, {
+ type: "PrivateName",
+ end: start + 2,
+ name: "x"
+ }),
+ kind: "method",
+ static: false,
+ value: newNode(start + 2, {
+ type: "FunctionExpression",
+ end: start + 7,
+ async: false,
+ body: newNode(start + 5, {
+ type: "BlockStatement",
+ body: [],
+ end: start + 7,
+ }),
+ expression: false,
+ generator: false,
+ id: null,
+ params: [],
+ })
+ }) },
+ { body: "get #x() {}", passes: true, ast: start => newNode(start, {
+ type: "MethodDefinition",
+ end: start + 11,
+ computed: false,
+ key: newNode(start + 4, {
+ type: "PrivateName",
+ end: start + 6,
+ name: "x"
+ }),
+ kind: "get",
+ static: false,
+ value: newNode(start + 6, {
+ type: "FunctionExpression",
+ end: start + 11,
+ async: false,
+ body: newNode(start + 9, {
+ body: [],
+ end: start + 11,
+ type: "BlockStatement"
+ }),
+ expression: false,
+ generator: false,
+ id: null,
+ params: [],
+ })
+ }) },
+
+ ].forEach(bodyInput => {
+ const body = bodyInput.body, passes = bodyInput.passes, bodyAst = bodyInput.ast
+ classes.forEach(input => {
+ const text = input.text, options = input.options || {}, ast = input.ast;
+ (passes ? test : testFail)(text.replace("%s", body), ast(bodyAst), options)
+ })
+ })
+
+ testFail("class C { \\u0061sync m(){} };", "Unexpected token (1:21)")
+ test("class A extends B { constructor() { super() } }")
+})
diff --git a/node-acorn-private-methods/test262.whitelist b/node-acorn-private-methods/test262.whitelist
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/node-acorn-private-methods/test262.whitelist
diff --git a/node-acorn-static-class-features/.eslintrc.json b/node-acorn-static-class-features/.eslintrc.json
new file mode 100644
index 0000000..92d6d82
--- /dev/null
+++ b/node-acorn-static-class-features/.eslintrc.json
@@ -0,0 +1,294 @@
+{
+ "env": {
+ "es6": true,
+ "node": true
+ },
+ "extends": ["eslint:recommended", "plugin:node/recommended"],
+ "plugins": ["node"],
+ "rules": {
+ "accessor-pairs": "error",
+ "array-bracket-newline": "off",
+ "array-bracket-spacing": "off",
+ "array-callback-return": "error",
+ "array-element-newline": "off",
+ "arrow-body-style": "error",
+ "arrow-parens": [
+ "error",
+ "as-needed"
+ ],
+ "arrow-spacing": [
+ "error",
+ {
+ "after": true,
+ "before": true
+ }
+ ],
+ "block-scoped-var": "error",
+ "block-spacing": "off",
+ "brace-style": [
+ "error",
+ "1tbs",
+ {
+ "allowSingleLine": true
+ }
+ ],
+ "callback-return": "error",
+ "camelcase": "error",
+ "capitalized-comments": "off",
+ "class-methods-use-this": "error",
+ "comma-dangle": "off",
+ "comma-spacing": [
+ "error",
+ {
+ "after": true,
+ "before": false
+ }
+ ],
+ "comma-style": [
+ "error",
+ "last"
+ ],
+ "complexity": "off",
+ "computed-property-spacing": [
+ "error",
+ "never"
+ ],
+ "consistent-return": "error",
+ "consistent-this": "error",
+ "curly": [ "error", "multi-line" ],
+ "default-case": "error",
+ "dot-location": "error",
+ "dot-notation": [
+ "error",
+ {
+ "allowKeywords": true
+ }
+ ],
+ "eol-last": "error",
+ "eqeqeq": "off",
+ "for-direction": "error",
+ "func-call-spacing": "error",
+ "func-name-matching": "error",
+ "func-names": [
+ "error",
+ "never"
+ ],
+ "func-style": [
+ "error",
+ "declaration",
+ { "allowArrowFunctions": true }
+ ],
+ "function-paren-newline": "off",
+ "generator-star-spacing": "error",
+ "getter-return": "error",
+ "global-require": "error",
+ "guard-for-in": "error",
+ "handle-callback-err": "error",
+ "id-blacklist": "error",
+ "id-length": "off",
+ "id-match": "error",
+ "implicit-arrow-linebreak": [
+ "error",
+ "beside"
+ ],
+ "indent": ["error", 2],
+ "indent-legacy": "off",
+ "init-declarations": "off",
+ "jsx-quotes": "error",
+ "key-spacing": "error",
+ "keyword-spacing": [
+ "error",
+ {
+ "after": true,
+ "before": true
+ }
+ ],
+ "line-comment-position": "off",
+ "linebreak-style": [
+ "error",
+ "unix"
+ ],
+ "lines-around-comment": "error",
+ "lines-around-directive": "error",
+ "lines-between-class-members": "error",
+ "max-depth": "error",
+ "max-len": "off",
+ "max-lines": "off",
+ "max-nested-callbacks": "error",
+ "max-params": "off",
+ "max-statements": "off",
+ "max-statements-per-line": "off",
+ "multiline-comment-style": [
+ "error",
+ "separate-lines"
+ ],
+ "new-cap": "error",
+ "new-parens": "error",
+ "newline-after-var": "off",
+ "newline-before-return": "off",
+ "newline-per-chained-call": "off",
+ "no-alert": "error",
+ "no-array-constructor": "error",
+ "no-await-in-loop": "error",
+ "no-bitwise": "error",
+ "no-buffer-constructor": "error",
+ "no-caller": "error",
+ "no-catch-shadow": "error",
+ "no-confusing-arrow": "error",
+ "no-continue": "off",
+ "no-div-regex": "error",
+ "no-duplicate-imports": "error",
+ "no-else-return": "error",
+ "no-empty-function": "error",
+ "no-eq-null": "error",
+ "no-eval": "error",
+ "no-extend-native": "error",
+ "no-extra-bind": "error",
+ "no-extra-label": "error",
+ "no-extra-parens": "off",
+ "no-floating-decimal": "error",
+ "no-implicit-coercion": "error",
+ "no-implicit-globals": "error",
+ "no-implied-eval": "error",
+ "no-inline-comments": "off",
+ "no-invalid-this": "off",
+ "no-iterator": "error",
+ "no-label-var": "error",
+ "no-labels": "error",
+ "no-lone-blocks": "error",
+ "no-lonely-if": "off",
+ "no-loop-func": "error",
+ "no-magic-numbers": "off",
+ "no-mixed-operators": "off",
+ "no-mixed-requires": "error",
+ "no-multi-assign": "error",
+ "no-multi-spaces": "error",
+ "no-multi-str": "error",
+ "no-multiple-empty-lines": ["error", { "max": 1, "maxEOF": 0, "maxBOF": 0 }],
+ "no-native-reassign": "error",
+ "no-negated-condition": "off",
+ "no-negated-in-lhs": "error",
+ "no-nested-ternary": "error",
+ "no-new": "error",
+ "no-new-func": "error",
+ "no-new-object": "error",
+ "no-new-require": "error",
+ "no-new-wrappers": "error",
+ "no-octal-escape": "error",
+ "no-param-reassign": "off",
+ "no-path-concat": "error",
+ "no-plusplus": "off",
+ "no-process-env": "error",
+ "no-process-exit": "error",
+ "no-proto": "error",
+ "no-prototype-builtins": "error",
+ "no-restricted-globals": "error",
+ "no-restricted-imports": "error",
+ "no-restricted-modules": "error",
+ "no-restricted-properties": "error",
+ "no-restricted-syntax": "error",
+ "no-return-assign": "error",
+ "no-return-await": "error",
+ "no-script-url": "error",
+ "no-self-compare": "error",
+ "no-sequences": "error",
+ "no-shadow": "error",
+ "no-shadow-restricted-names": "error",
+ "no-spaced-func": "error",
+ "no-sync": [
+ "error",
+ {
+ "allowAtRootLevel": true
+ }
+ ],
+ "no-tabs": "error",
+ "no-template-curly-in-string": "error",
+ "no-ternary": "off",
+ "no-throw-literal": "error",
+ "no-trailing-spaces": "error",
+ "no-undef-init": "error",
+ "no-undefined": "error",
+ "no-underscore-dangle": "off",
+ "no-unmodified-loop-condition": "error",
+ "no-unneeded-ternary": "error",
+ "no-unused-expressions": "error",
+ "no-unused-vars": ["error", {"argsIgnorePattern": "^_"}],
+ "no-use-before-define": "error",
+ "no-useless-call": "error",
+ "no-useless-computed-key": "error",
+ "no-useless-concat": "error",
+ "no-useless-constructor": "error",
+ "no-useless-rename": "error",
+ "no-useless-return": "error",
+ "no-var": "error",
+ "no-void": "error",
+ "no-warning-comments": "warn",
+ "no-whitespace-before-property": "error",
+ "no-with": "error",
+ "nonblock-statement-body-position": [
+ "error",
+ "any"
+ ],
+ "object-curly-newline": "off",
+ "object-curly-spacing": "off",
+ "object-property-newline": "off",
+ "object-shorthand": "off",
+ "one-var": "off",
+ "one-var-declaration-per-line": "off",
+ "operator-assignment": "error",
+ "operator-linebreak": "error",
+ "padded-blocks": "off",
+ "padding-line-between-statements": "error",
+ "prefer-arrow-callback": "off",
+ "prefer-const": "off",
+ "prefer-destructuring": "off",
+ "prefer-numeric-literals": "error",
+ "prefer-promise-reject-errors": "error",
+ "prefer-reflect": "off",
+ "prefer-rest-params": "off",
+ "prefer-spread": "error",
+ "prefer-template": "error",
+ "quote-props": ["error", "as-needed"],
+ "quotes": ["error", "double"],
+ "radix": "error",
+ "require-await": "error",
+ "require-jsdoc": "off",
+ "rest-spread-spacing": "error",
+ "semi": ["error", "never"],
+ "semi-spacing": "error",
+ "semi-style": [
+ "error",
+ "first"
+ ],
+ "sort-imports": "error",
+ "sort-keys": "off",
+ "sort-vars": "off",
+ "space-before-blocks": "error",
+ "space-before-function-paren": "off",
+ "space-in-parens": [
+ "error",
+ "never"
+ ],
+ "space-infix-ops": "error",
+ "space-unary-ops": "error",
+ "spaced-comment": "off",
+ "strict": "error",
+ "switch-colon-spacing": "error",
+ "symbol-description": "error",
+ "template-curly-spacing": "error",
+ "template-tag-spacing": "error",
+ "unicode-bom": [
+ "error",
+ "never"
+ ],
+ "valid-jsdoc": "error",
+ "vars-on-top": "off",
+ "wrap-regex": "error",
+ "yield-star-spacing": "error",
+ "yoda": [
+ "error",
+ "never"
+ ],
+ "node/no-unpublished-require": "off"
+ }
+}
diff --git a/node-acorn-static-class-features/.gitignore b/node-acorn-static-class-features/.gitignore
new file mode 100644
index 0000000..c2658d7
--- /dev/null
+++ b/node-acorn-static-class-features/.gitignore
@@ -0,0 +1 @@
+node_modules/
diff --git a/node-acorn-static-class-features/CHANGELOG.md b/node-acorn-static-class-features/CHANGELOG.md
new file mode 100644
index 0000000..b9896a4
--- /dev/null
+++ b/node-acorn-static-class-features/CHANGELOG.md
@@ -0,0 +1,11 @@
+## 0.2.0 (2019-02-09)
+
+* Require acorn >= 6.1.0
+
+## 0.1.1 (2018-11-06)
+
+* Adapt to changes in acorn 6.0.3
+
+## 0.1.0 (2018-09-14)
+
+Initial release
diff --git a/node-acorn-static-class-features/LICENSE b/node-acorn-static-class-features/LICENSE
new file mode 100644
index 0000000..7c2b27a
--- /dev/null
+++ b/node-acorn-static-class-features/LICENSE
@@ -0,0 +1,19 @@
+Copyright (C) 2017-2018 by Adrian Heine
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+THE SOFTWARE.
diff --git a/node-acorn-static-class-features/README.md b/node-acorn-static-class-features/README.md
new file mode 100644
index 0000000..bb214fc
--- /dev/null
+++ b/node-acorn-static-class-features/README.md
@@ -0,0 +1,21 @@
+# Static class features support for Acorn
+
+[![NPM version](https://img.shields.io/npm/v/acorn-class-fields.svg)](https://www.npmjs.org/package/acorn-static-class-features)
+
+This is a plugin for [Acorn](http://marijnhaverbeke.nl/acorn/) - a tiny, fast JavaScript parser, written completely in JavaScript.
+
+It implements support for static class features as defined in the stage 3 proposal [Static class features](https://github.com/tc39/proposal-static-class-features). The emitted AST follows [an ESTree proposal](https://github.com/estree/estree/pull/180).
+
+## Usage
+
+This module provides a plugin that can be used to extend the Acorn `Parser` class:
+
+```javascript
+const {Parser} = require('acorn');
+const staticClassFeatures = require('acorn-static-class-features');
+Parser.extend(staticClassFeatures).parse('class X { static x = 0 }');
+```
+
+## License
+
+This plugin is released under an [MIT License](./LICENSE).
diff --git a/node-acorn-static-class-features/index.js b/node-acorn-static-class-features/index.js
new file mode 100644
index 0000000..8ba0521
--- /dev/null
+++ b/node-acorn-static-class-features/index.js
@@ -0,0 +1,126 @@
+"use strict"
+
+const skipWhiteSpace = /(?:\s|\/\/.*|\/\*[^]*?\*\/)*/g
+
+const acorn = require("acorn")
+const tt = acorn.tokTypes
+
+function maybeParseFieldValue(field) {
+ if (this.eat(tt.eq)) {
+ const oldInFieldValue = this._inStaticFieldValue
+ this._inStaticFieldValue = true
+ field.value = this.parseExpression()
+ this._inStaticFieldValue = oldInFieldValue
+ } else field.value = null
+}
+
+const privateClassElements = require("acorn-private-class-elements")
+
+module.exports = function(Parser) {
+ const ExtendedParser = privateClassElements(Parser)
+
+ return class extends ExtendedParser {
+ // Parse private fields
+ parseClassElement(_constructorAllowsSuper) {
+ if (this.eat(tt.semi)) return null
+
+ const node = this.startNode()
+
+ const tryContextual = (k, noLineBreak) => {
+ if (typeof noLineBreak == "undefined") noLineBreak = false
+ const start = this.start, startLoc = this.startLoc
+ if (!this.eatContextual(k)) return false
+ if (this.type !== tt.parenL && (!noLineBreak || !this.canInsertSemicolon())) return true
+ if (node.key) this.unexpected()
+ node.computed = false
+ node.key = this.startNodeAt(start, startLoc)
+ node.key.name = k
+ this.finishNode(node.key, "Identifier")
+ return false
+ }
+
+ node.static = tryContextual("static")
+ if (!node.static) return super.parseClassElement.apply(this, arguments)
+
+ let isGenerator = this.eat(tt.star)
+ let isAsync = false
+ if (!isGenerator) {
+ // Special-case for `async`, since `parseClassMember` currently looks
+ // for `(` to determine whether `async` is a method name
+ if (this.options.ecmaVersion >= 8 && this.isContextual("async")) {
+ skipWhiteSpace.lastIndex = this.pos
+ let skip = skipWhiteSpace.exec(this.input)
+ let next = this.input.charAt(this.pos + skip[0].length)
+ if (next === ";" || next === "=") {
+ node.key = this.parseIdent(true)
+ node.computed = false
+ maybeParseFieldValue.call(this, node)
+ this.finishNode(node, "FieldDefinition")
+ this.semicolon()
+ return node
+ } else if (this.options.ecmaVersion >= 8 && tryContextual("async", true)) {
+ isAsync = true
+ isGenerator = this.options.ecmaVersion >= 9 && this.eat(tt.star)
+ }
+ } else if (tryContextual("get")) {
+ node.kind = "get"
+ } else if (tryContextual("set")) {
+ node.kind = "set"
+ }
+ }
+ if (this.type === this.privateNameToken) {
+ this.parsePrivateClassElementName(node)
+ if (this.type !== tt.parenL) {
+ if (node.key.name === "prototype") {
+ this.raise(node.key.start, "Classes may not have a private static property named prototype")
+ }
+ maybeParseFieldValue.call(this, node)
+ this.finishNode(node, "FieldDefinition")
+ this.semicolon()
+ return node
+ }
+ } else if (!node.key) {
+ this.parsePropertyName(node)
+ if ((node.key.name || node.key.value) === "prototype" && !node.computed) {
+ this.raise(node.key.start, "Classes may not have a static property named prototype")
+ }
+ }
+ if (!node.kind) node.kind = "method"
+ this.parseClassMethod(node, isGenerator, isAsync)
+ if (!node.kind && (node.key.name || node.key.value) === "constructor" && !node.computed) {
+ this.raise(node.key.start, "Classes may not have a static field named constructor")
+ }
+ if (node.kind === "get" && node.value.params.length !== 0) {
+ this.raiseRecoverable(node.value.start, "getter should have no params")
+ }
+ if (node.kind === "set" && node.value.params.length !== 1) {
+ this.raiseRecoverable(node.value.start, "setter should have exactly one param")
+ }
+ if (node.kind === "set" && node.value.params[0].type === "RestElement") {
+ this.raiseRecoverable(node.value.params[0].start, "Setter cannot use rest params")
+ }
+
+ return node
+
+ }
+
+ // Parse public static fields
+ parseClassMethod(method, isGenerator, isAsync, _allowsDirectSuper) {
+ if (isGenerator || isAsync || method.kind != "method" || !method.static || this.options.ecmaVersion < 8 || this.type == tt.parenL) {
+ return super.parseClassMethod.apply(this, arguments)
+ }
+ maybeParseFieldValue.call(this, method)
+ delete method.kind
+ method = this.finishNode(method, "FieldDefinition")
+ this.semicolon()
+ return method
+ }
+
+ // Prohibit arguments in class field initializers
+ parseIdent(liberal, isBinding) {
+ const ident = super.parseIdent(liberal, isBinding)
+ if (this._inStaticFieldValue && ident.name == "arguments") this.raise(ident.start, "A static class field initializer may not contain arguments")
+ return ident
+ }
+ }
+}
diff --git a/node-acorn-static-class-features/package.json b/node-acorn-static-class-features/package.json
new file mode 100644
index 0000000..e8477e4
--- /dev/null
+++ b/node-acorn-static-class-features/package.json
@@ -0,0 +1,36 @@
+{
+ "name": "acorn-static-class-features",
+ "description": "Support for static class features in acorn",
+ "homepage": "https://github.com/acornjs/acorn-static-class-features",
+ "contributors": [
+ "Adrian Heine <mail@adrianheine.de>"
+ ],
+ "engines": {
+ "node": ">=4.8.2"
+ },
+ "repository": {
+ "type": "git",
+ "url": "https://github.com/acornjs/acorn-static-class-features"
+ },
+ "license": "MIT",
+ "scripts": {
+ "test": "mocha",
+ "test:test262": "node run_test262.js",
+ "lint": "eslint -c .eslintrc.json ."
+ },
+ "peerDependencies": {
+ "acorn": "^6.1.0"
+ },
+ "version": "0.2.0",
+ "devDependencies": {
+ "acorn": "^6.1.0",
+ "eslint": "^5.13.0",
+ "eslint-plugin-node": "^8.0.1",
+ "mocha": "^5.2.0",
+ "test262": "git+https://github.com/tc39/test262.git#33a306d1026b72227eb50a918db19ada16f12b3d",
+ "test262-parser-runner": "^0.5.0"
+ },
+ "dependencies": {
+ "acorn-private-class-elements": "^0.1.0"
+ }
+}
diff --git a/node-acorn-static-class-features/run_test262.js b/node-acorn-static-class-features/run_test262.js
new file mode 100644
index 0000000..01a8bc4
--- /dev/null
+++ b/node-acorn-static-class-features/run_test262.js
@@ -0,0 +1,28 @@
+"use strict"
+
+const fs = require("fs")
+const path = require("path")
+const run = require("test262-parser-runner")
+const acorn = require("acorn")
+const Parser = acorn.Parser.extend(require("."))
+
+const unsupportedFeatures = [
+ "BigInt",
+ "class-fields-public",
+ "class-methods-private"
+]
+
+const implementedFeatures = [
+ "class-static-fields-public",
+ "class-static-fields-private",
+ "class-static-methods-private"
+]
+
+run(
+ (content, options) => Parser.parse(content, {sourceType: options.sourceType, ecmaVersion: 10}),
+ {
+ testsDirectory: path.dirname(require.resolve("test262/package.json")),
+ skip: test => (!test.attrs.features || !implementedFeatures.some(f => test.attrs.features.includes(f)) || unsupportedFeatures.some(f => test.attrs.features.includes(f))),
+ whitelist: fs.readFileSync("./test262.whitelist", "utf8").split("\n").filter(v => v && v[0] !== "#")
+ }
+)
diff --git a/node-acorn-static-class-features/test/.eslintrc.json b/node-acorn-static-class-features/test/.eslintrc.json
new file mode 100644
index 0000000..4668ae7
--- /dev/null
+++ b/node-acorn-static-class-features/test/.eslintrc.json
@@ -0,0 +1,5 @@
+{
+ "env": {
+ "mocha": true
+ }
+}
diff --git a/node-acorn-static-class-features/test/test.js b/node-acorn-static-class-features/test/test.js
new file mode 100644
index 0000000..5bf2656
--- /dev/null
+++ b/node-acorn-static-class-features/test/test.js
@@ -0,0 +1,409 @@
+"use strict"
+
+const assert = require("assert")
+const acorn = require("acorn")
+const Parser = acorn.Parser.extend(require(".."))
+
+function test(text, expectedResult, additionalOptions) {
+ it(text, function () {
+ const result = Parser.parse(text, Object.assign({ ecmaVersion: 10 }, additionalOptions))
+ if (expectedResult) {
+ assert.deepStrictEqual(result.body[0], expectedResult)
+ }
+ })
+}
+function testFail(text, expectedResult, additionalOptions) {
+ it(text, function () {
+ let failed = false
+ try {
+ Parser.parse(text, Object.assign({ ecmaVersion: 10 }, additionalOptions))
+ } catch (e) {
+ assert.strictEqual(e.message, expectedResult)
+ failed = true
+ }
+ assert(failed)
+ })
+}
+const newNode = (start, props) => Object.assign(new acorn.Node({options: {}}, start), props)
+
+describe("acorn-static-class-features", function () {
+ test(`class CustomDate {
+ // ...
+ static epoch = new CustomDate(0);
+ }`)
+
+ testFail("class A { static #a; f() { delete A.#a } }", "Private elements may not be deleted (1:27)")
+ testFail("class A { static #a; static #a }", "Duplicate private element (1:21)")
+ testFail("class A { static a = A.#a }", "Usage of undeclared private name (1:23)")
+ testFail("class A { static a = () => arguments }", "A static class field initializer may not contain arguments (1:27)")
+ testFail("class A { static a = () => super() }", "'super' keyword outside a method (1:27)")
+ testFail("class A { static # a }", "Unexpected token (1:19)")
+ testFail("class A { static #a; a() { A.# a } }", "Unexpected token (1:31)")
+ test(`class C {
+ static async * #method() {
+ }
+ }`)
+
+ const classes = [
+ { text: "class A { %s }", ast: getBody => {
+ const body = getBody(10)
+ return newNode(0, {
+ type: "ClassDeclaration",
+ end: body.end + 2,
+ id: newNode(6, {
+ type: "Identifier",
+ end: 7,
+ name: "A"
+ }),
+ superClass: null,
+ body: newNode(8, {
+ type: "ClassBody",
+ end: body.end + 2,
+ body: [body]
+ })
+ })
+ } },
+ { text: "class A { %s; }", ast: getBody => {
+ const body = getBody(10)
+ return newNode(0, {
+ type: "ClassDeclaration",
+ end: body.end + 3,
+ id: newNode(6, {
+ type: "Identifier",
+ end: 7,
+ name: "A"
+ }),
+ superClass: null,
+ body: newNode(8, {
+ type: "ClassBody",
+ end: body.end + 3,
+ body: [body]
+ })
+ })
+ } },
+ { text: "class A { %s; static #y }", ast: getBody => {
+ const body = getBody(10)
+ return newNode(0, {
+ type: "ClassDeclaration",
+ end: body.end + 13,
+ id: newNode(6, {
+ type: "Identifier",
+ end: 7,
+ name: "A"
+ }),
+ superClass: null,
+ body: newNode(8, {
+ type: "ClassBody",
+ end: body.end + 13,
+ body: [body, newNode(body.end + 2, {
+ type: "FieldDefinition",
+ end: body.end + 11,
+ key: newNode(body.end + 9, {
+ type: "PrivateName",
+ end: body.end + 11,
+ name: "y"
+ }),
+ value: null,
+ computed: false,
+ static: true
+ }) ]
+ })
+ })
+ } },
+ { text: "class A { %s;a() {} }", ast: getBody => {
+ const body = getBody(10)
+ return newNode(0, {
+ type: "ClassDeclaration",
+ end: body.end + 9,
+ id: newNode(6, {
+ type: "Identifier",
+ end: 7,
+ name: "A"
+ }),
+ superClass: null,
+ body: newNode(8, {
+ type: "ClassBody",
+ end: body.end + 9,
+ body: [ body, newNode(body.end + 1, {
+ type: "MethodDefinition",
+ end: body.end + 7,
+ kind: "method",
+ static: false,
+ computed: false,
+ key: newNode(body.end + 1, {
+ type: "Identifier",
+ end: body.end + 2,
+ name: "a"
+ }),
+ value: newNode(body.end + 2, {
+ type: "FunctionExpression",
+ end: body.end + 7,
+ id: null,
+ generator: false,
+ expression: false,
+ async: false,
+ params: [],
+ body: newNode(body.end + 5, {
+ type: "BlockStatement",
+ end: body.end + 7,
+ body: []
+ })
+ })
+ }) ]
+ })
+ })
+ } },
+ { text: "class A { %s\na() {} }", ast: getBody => {
+ const body = getBody(10)
+ return newNode(0, {
+ type: "ClassDeclaration",
+ end: body.end + 9,
+ id: newNode(6, {
+ type: "Identifier",
+ end: 7,
+ name: "A"
+ }),
+ superClass: null,
+ body: newNode(8, {
+ type: "ClassBody",
+ end: body.end + 9,
+ body: [
+ body,
+ newNode(body.end + 1, {
+ type: "MethodDefinition",
+ end: body.end + 7,
+ kind: "method",
+ static: false,
+ computed: false,
+ key: newNode(body.end + 1, {
+ type: "Identifier",
+ end: body.end + 2,
+ name: "a"
+ }),
+ value: newNode(body.end + 2, {
+ type: "FunctionExpression",
+ end: body.end + 7,
+ id: null,
+ generator: false,
+ expression: false,
+ async: false,
+ params: [],
+ body: newNode(body.end + 5, {
+ type: "BlockStatement",
+ end: body.end + 7,
+ body: []
+ })
+ })
+ })
+ ]
+ })
+ })
+ } },
+ ]
+
+ ;[
+ { body: "static x", passes: true, ast: start => newNode(start, {
+ type: "FieldDefinition",
+ end: start + 8,
+ key: newNode(start + 7, {
+ type: "Identifier",
+ end: start + 8,
+ name: "x"
+ }),
+ value: null,
+ computed: false,
+ static: true
+ }) },
+ { body: "static x = 0", passes: true, ast: start => newNode(start, {
+ type: "FieldDefinition",
+ end: start + 12,
+ key: newNode(start + 7, {
+ type: "Identifier",
+ end: start + 8,
+ name: "x"
+ }),
+ value: newNode(start + 11, {
+ type: "Literal",
+ end: start + 12,
+ value: 0,
+ raw: "0"
+ }),
+ computed: false,
+ static: true
+ }) },
+ { body: "static [x]", passes: true, ast: start => newNode(start, {
+ type: "FieldDefinition",
+ end: start + 10,
+ computed: true,
+ key: newNode(start + 8, {
+ type: "Identifier",
+ end: start + 9,
+ name: "x"
+ }),
+ value: null,
+ static: true
+ }) },
+ { body: "static [x] = 0", passes: true, ast: start => newNode(start, {
+ type: "FieldDefinition",
+ end: start + 14,
+ computed: true,
+ key: newNode(start + 8, {
+ type: "Identifier",
+ end: start + 9,
+ name: "x"
+ }),
+ value: newNode(start + 13, {
+ type: "Literal",
+ end: start + 14,
+ value: 0,
+ raw: "0"
+ }),
+ static: true
+ }) },
+ { body: "static #x", passes: true, ast: start => newNode(start, {
+ type: "FieldDefinition",
+ end: start + 9,
+ computed: false,
+ key: newNode(start + 7, {
+ type: "PrivateName",
+ end: start + 9,
+ name: "x"
+ }),
+ value: null,
+ static: true
+ }) },
+ { body: "static #x = 0", passes: true, ast: start => newNode(start, {
+ type: "FieldDefinition",
+ end: start + 13,
+ computed: false,
+ key: newNode(start + 7, {
+ type: "PrivateName",
+ end: start + 9,
+ name: "x"
+ }),
+ value: newNode(start + 12, {
+ type: "Literal",
+ end: start + 13,
+ value: 0,
+ raw: "0"
+ }),
+ static: true
+ }) },
+
+ { body: "static async", passes: true, ast: start => newNode(start, {
+ type: "FieldDefinition",
+ end: start + 12,
+ key: newNode(start + 7, {
+ type: "Identifier",
+ end: start + 12,
+ name: "async"
+ }),
+ value: null,
+ computed: false,
+ static: true
+ }) },
+
+ { body: "static async = 5", passes: true, ast: start => newNode(start, {
+ type: "FieldDefinition",
+ end: start + 16,
+ key: newNode(start + 7, {
+ type: "Identifier",
+ end: start + 12,
+ name: "async"
+ }),
+ value: newNode(start + 15, {
+ type: "Literal",
+ end: start + 16,
+ raw: "5",
+ value: 5
+ }),
+ computed: false,
+ static: true
+ }) },
+ ].forEach(bodyInput => {
+ const body = bodyInput.body, passes = bodyInput.passes, bodyAst = bodyInput.ast
+ classes.forEach(input => {
+ const text = input.text, options = input.options || {}, ast = input.ast
+ ;(passes ? test : testFail)(text.replace("%s", body), ast(bodyAst), options)
+ })
+ })
+
+ // Private static methods
+ test("class A { a() { A.#a }; static #a() {} }")
+
+ testFail("class A { static #a() {}; f() { delete A.#a } }", "Private elements may not be deleted (1:32)")
+ testFail("class A { static #a() {}; static #a() {} }", "Duplicate private element (1:26)")
+ test("class A { static get #a() {}; static set #a(newA) {} }")
+ testFail("class A { a() { A.#a } }", "Usage of undeclared private name (1:18)")
+ testFail("class A { a() { A.#a } b() { A.#b } }", "Usage of undeclared private name (1:18)")
+ testFail("class A { static #constructor() {} }", "Classes may not have a private element named constructor (1:17)")
+ testFail("class A { static #[ab]() {} }", "Unexpected token (1:18)")
+ testFail("a = { static #ab() {} }", "Unexpected token (1:13)")
+ testFail("class A { static [{#ab() {}}]() {} }", "Unexpected token (1:19)")
+ testFail("class A{ static # a() {}}", "Unexpected token (1:18)")
+ testFail("class C{ static #method() { super(); } };", "super() call outside constructor of a subclass (1:28)")
+ test("class C{ static #method() { super.y(); } };")
+
+ ;[
+ { body: "static #x() {}", passes: true, ast: start => newNode(start, {
+ type: "MethodDefinition",
+ end: start + 14,
+ computed: false,
+ key: newNode(start + 7, {
+ type: "PrivateName",
+ end: start + 9,
+ name: "x"
+ }),
+ kind: "method",
+ static: true,
+ value: newNode(start + 9, {
+ type: "FunctionExpression",
+ end: start + 14,
+ async: false,
+ body: newNode(start + 12, {
+ type: "BlockStatement",
+ body: [],
+ end: start + 14,
+ }),
+ expression: false,
+ generator: false,
+ id: null,
+ params: [],
+ })
+ }) },
+ { body: "static get #x() {}", passes: true, ast: start => newNode(start, {
+ type: "MethodDefinition",
+ end: start + 18,
+ computed: false,
+ key: newNode(start + 11, {
+ type: "PrivateName",
+ end: start + 13,
+ name: "x"
+ }),
+ kind: "get",
+ static: true,
+ value: newNode(start + 13, {
+ type: "FunctionExpression",
+ end: start + 18,
+ async: false,
+ body: newNode(start + 16, {
+ body: [],
+ end: start + 18,
+ type: "BlockStatement"
+ }),
+ expression: false,
+ generator: false,
+ id: null,
+ params: [],
+ })
+ }) },
+
+ ].forEach(bodyInput => {
+ const body = bodyInput.body, passes = bodyInput.passes, bodyAst = bodyInput.ast
+ classes.forEach(input => {
+ const text = input.text, options = input.options || {}, ast = input.ast
+ ;(passes ? test : testFail)(text.replace("%s", body), ast(bodyAst), options)
+ })
+ })
+ test("class A extends B { constructor() { super() } }")
+})
diff --git a/node-acorn-static-class-features/test262.whitelist b/node-acorn-static-class-features/test262.whitelist
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/node-acorn-static-class-features/test262.whitelist
diff --git a/package.json b/package.json
index b208c92..eb0dd1c 100644
--- a/package.json
+++ b/package.json
@@ -12,7 +12,7 @@
},
{
"name": "Adrian Heine",
- "email": "http://adrianheine.de"
+ "web": "http://adrianheine.de"
}
],
"repository": {
@@ -39,10 +39,11 @@
"eslint-plugin-node": "^5.2.1",
"eslint-plugin-promise": "^3.5.0",
"eslint-plugin-standard": "^3.0.1",
- "rollup": "^0.45.0",
- "rollup-plugin-buble": "^0.16.0",
- "test262": "git+https://github.com/tc39/test262.git#e39604fa41b1ad0effdcf586e4d554ff2d8c3eb7",
+ "rollup": "^1.7.0",
+ "rollup-plugin-buble": "^0.19.0",
+ "test262": "git+https://github.com/tc39/test262.git#de567d3aa5de4eaa11e00131d26b9fe77997dfb0",
"test262-parser-runner": "^0.5.0",
- "unicode-11.0.0": "^0.7.7"
+ "test262-stream": "^1.2.1",
+ "unicode-12.0.0": "^0.7.9"
}
}
diff --git a/test/driver.js b/test/driver.js
index dc8fc6f..b05cbb1 100644
--- a/test/driver.js
+++ b/test/driver.js
@@ -61,7 +61,7 @@ exports.runTests = function(config, callback) {
}
};
-function ppJSON(v) { return v instanceof RegExp ? v.toString() : JSON.stringify(v, null, 2); }
+function ppJSON(v) { return v instanceof RegExp ? v.toString() : (typeof v == "bigint" ? v.toString() : JSON.stringify(v, null, 2)); }
function addPath(str, pt) {
if (str.charAt(str.length-1) == ")")
return str.slice(0, str.length-1) + "/" + pt + ")";
diff --git a/test/run.js b/test/run.js
index 7fed589..4ea981b 100644
--- a/test/run.js
+++ b/test/run.js
@@ -14,6 +14,8 @@
require("./tests-regexp-2018.js");
require("./tests-json-superset.js");
require("./tests-optional-catch-binding.js");
+ require("./tests-bigint.js");
+ require("./tests-dynamic-import.js");
var acorn = require("../acorn")
var acorn_loose = require("../acorn-loose")
diff --git a/test/tests-bigint.js b/test/tests-bigint.js
new file mode 100644
index 0000000..bb2d9d5
--- /dev/null
+++ b/test/tests-bigint.js
@@ -0,0 +1,197 @@
+if (typeof exports != "undefined") {
+ var test = require("./driver.js").test;
+ var testFail = require("./driver.js").testFail;
+}
+
+const newBigIntLiteral = (start, stringValue) => ({
+ start: start,
+ type: "Literal",
+ end: start + stringValue.length + 1,
+ value: typeof BigInt !== "undefined" ? BigInt(stringValue) : null,
+ raw: `${stringValue}n`,
+ bigint: stringValue
+})
+
+const digits = [
+ {d: "0", ast: start => newBigIntLiteral(start, "0")},
+ {d: "2", ast: start => newBigIntLiteral(start, "2")},
+ {d: "0x2", ast: start => newBigIntLiteral(start, "0x2")},
+ {d: "0o2", ast: start => newBigIntLiteral(start, "0o2")},
+ {d: "0b10", ast: start => newBigIntLiteral(start, "0b10")},
+ {d: "-0xbf2ed51ff75d380fd3be813ec6185780", ast: start => ({
+ start: start,
+ type: "UnaryExpression",
+ end: start + 36,
+ operator: "-",
+ prefix: true,
+ argument: newBigIntLiteral(start + 1, "0xbf2ed51ff75d380fd3be813ec6185780")
+ })},
+ {d: "02", error: start => `Identifier directly after number (1:${start + 2})`},
+ {d: "2e2", error: start => `Identifier directly after number (1:${start + 3})`},
+ {d: "2.4", error: start => `Identifier directly after number (1:${start + 3})`},
+ {d: ".4", error: start => `Identifier directly after number (1:${start + 2})`},
+]
+const statements = [
+ {s: "let i = %s", ast: content => ({
+ start: 0,
+ type: "VariableDeclaration",
+ end: content.end,
+ kind: "let",
+ declarations: [{
+ start: 4,
+ type: "VariableDeclarator",
+ end: content.end,
+ id: {
+ start: 4,
+ type: "Identifier",
+ end: 5,
+ name: "i"
+ },
+ init: content
+ }]
+ })},
+
+ {s: "i = %s", ast: content => ({
+ start: 0,
+ type: "ExpressionStatement",
+ end: content.end,
+ expression: {
+ start: 0,
+ type: "AssignmentExpression",
+ end: content.end,
+ operator: "=",
+ left: {
+ start: 0,
+ type: "Identifier",
+ end: 1,
+ name: "i"
+ },
+ right: content
+ }
+ })},
+
+ {s: "((i = %s) => {})", ast: content => ({
+ start: 0,
+ type: "ExpressionStatement",
+ end: content.end + 8,
+ expression: {
+ start: 1,
+ type: "ArrowFunctionExpression",
+ end: content.end + 7,
+ id: null,
+ generator: false,
+ expression: false,
+ async: false,
+ params: [
+ {
+ start: 2,
+ type: "AssignmentPattern",
+ end: content.end,
+ left: {
+ start: 2,
+ type: "Identifier",
+ end: 3,
+ name: "i"
+ },
+ right: content
+ }
+ ],
+ body: {
+ start: content.end + 5,
+ type: "BlockStatement",
+ end: content.end + 7,
+ body: []
+ }
+ }
+ })},
+
+ {s: "for (let i = 0n; i < %s;++i) {}", ast: content => ({
+ start: 0,
+ type: "ForStatement",
+ end: content.end + 8,
+ init: {
+ start: 5,
+ type: "VariableDeclaration",
+ end: 15,
+ declarations: [
+ {
+ start: 9,
+ type: "VariableDeclarator",
+ end: 15,
+ id: {
+ start: 9,
+ type: "Identifier",
+ end: 10,
+ name: "i"
+ },
+ init: newBigIntLiteral(13, "0")
+ }
+ ],
+ kind: "let"
+ },
+ test: {
+ start: 17,
+ type: "BinaryExpression",
+ end: content.end,
+ left: {
+ start: 17,
+ type: "Identifier",
+ start: 17,
+ end: 18,
+ name: "i"
+ },
+ operator: "<",
+ right: content
+ },
+ update: {
+ start: content.end + 1,
+ type: "UpdateExpression",
+ end: content.end + 4,
+ operator: "++",
+ prefix: true,
+ argument: {
+ start: content.end + 3,
+ type: "Identifier",
+ end: content.end + 4,
+ name: "i"
+ }
+ },
+ body: {
+ start: content.end + 6,
+ type: "BlockStatement",
+ end: content.end + 8,
+ body: []
+ }
+ })},
+
+ {s: "i + %s", ast: content => ({
+ start: 0,
+ type: "ExpressionStatement",
+ end: content.end,
+ expression: {
+ start: 0,
+ type: "BinaryExpression",
+ end: content.end,
+ left: {
+ start: 0,
+ type: "Identifier",
+ start: 0,
+ end: 1,
+ name: "i"
+ },
+ operator: "+",
+ right: content
+ }
+ })}
+]
+statements.forEach(statement => {
+ const start = statement.s.indexOf("%s")
+ digits.forEach(d => {
+ (d.error ? testFail : test)(
+ statement.s.replace("%s", `${d.d}n`),
+ d.error ? d.error(start) : { type: "Program", body: [
+ statement.ast(d.ast(start))
+ ]}, { ecmaVersion: 11 }
+ )
+ })
+})
diff --git a/test/tests-dynamic-import.js b/test/tests-dynamic-import.js
new file mode 100644
index 0000000..18c23d3
--- /dev/null
+++ b/test/tests-dynamic-import.js
@@ -0,0 +1,128 @@
+// Tests for ECMAScript 2020 dynamic import
+
+if (typeof exports != 'undefined') {
+ var test = require('./driver.js').test;
+ var testFail = require('./driver.js').testFail;
+}
+
+test(
+ "import('dynamicImport.js')",
+ {
+ type: 'Program',
+ start: 0,
+ end: 26,
+ body: [
+ {
+ type: 'ExpressionStatement',
+ start: 0,
+ end: 26,
+ expression: {
+ type: 'CallExpression',
+ start: 0,
+ end: 26,
+ callee: { type: 'Import', start: 0, end: 6 },
+ arguments: [
+ {
+ type: 'Literal',
+ start: 7,
+ end: 25,
+ value: 'dynamicImport.js',
+ raw: "'dynamicImport.js'"
+ }
+ ]
+ }
+ }
+ ],
+ sourceType: 'script'
+ },
+ { ecmaVersion: 11 }
+);
+
+test(
+ "function* a() { yield import('http'); }",
+ {
+ type: 'Program',
+ start: 0,
+ end: 39,
+ body: [
+ {
+ type: 'FunctionDeclaration',
+ start: 0,
+ end: 39,
+ id: { type: 'Identifier', start: 10, end: 11, name: 'a' },
+ expression: false,
+ generator: true,
+ async: false,
+ params: [],
+ body: {
+ type: 'BlockStatement',
+ start: 14,
+ end: 39,
+ body: [
+ {
+ type: 'ExpressionStatement',
+ start: 16,
+ end: 37,
+ expression: {
+ type: 'YieldExpression',
+ start: 16,
+ end: 36,
+ delegate: false,
+ argument: {
+ type: 'CallExpression',
+ start: 22,
+ end: 36,
+ callee: { type: 'Import', start: 22, end: 28 },
+ arguments: [{ type: 'Literal', start: 29, end: 35, value: 'http', raw: "'http'" }]
+ }
+ }
+ }
+ ]
+ }
+ }
+ ],
+ sourceType: 'script'
+ },
+ { ecmaVersion: 11 }
+);
+
+testFail('function failsParse() { return import.then(); }', 'Unexpected token (1:37)', {
+ ecmaVersion: 11,
+ loose: false
+});
+
+testFail("var dynImport = import; dynImport('http');", 'Unexpected token (1:22)', {
+ ecmaVersion: 11,
+ loose: false
+});
+
+testFail("import('test.js')", 'Unexpected token (1:6)', {
+ ecmaVersion: 10,
+ loose: false,
+ sourceType: 'module'
+});
+
+testFail("import()", 'import() requires exactly one argument (1:0)', {
+ ecmaVersion: 11,
+ loose: false
+});
+
+testFail("import(a, b)", 'import() requires exactly one argument (1:0)', {
+ ecmaVersion: 11,
+ loose: false
+});
+
+testFail("import(...[a])", '... is not allowed in import() (1:7)', {
+ ecmaVersion: 11,
+ loose: false
+});
+
+testFail("import(source,)", 'Unexpected token (1:14)', {
+ ecmaVersion: 11,
+ loose: false
+});
+
+testFail("new import(source)", 'Cannot use new with import(...) (1:4)', {
+ ecmaVersion: 11,
+ loose: false
+});
diff --git a/test/tests-harmony.js b/test/tests-harmony.js
index e370474..ade46a2 100644
--- a/test/tests-harmony.js
+++ b/test/tests-harmony.js
@@ -6028,95 +6028,6 @@ test("for (var x of list) process(x);", {
locations: true
});
-test("for (var x = 42 of list) process(x);", {
- type: "Program",
- body: [{
- type: "ForOfStatement",
- left: {
- type: "VariableDeclaration",
- declarations: [{
- type: "VariableDeclarator",
- id: {
- type: "Identifier",
- name: "x",
- loc: {
- start: {line: 1, column: 9},
- end: {line: 1, column: 10}
- }
- },
- init: {
- type: "Literal",
- value: 42,
- raw: "42",
- loc: {
- start: {line: 1, column: 13},
- end: {line: 1, column: 15}
- }
- },
- loc: {
- start: {line: 1, column: 9},
- end: {line: 1, column: 15}
- }
- }],
- kind: "var",
- loc: {
- start: {line: 1, column: 5},
- end: {line: 1, column: 15}
- }
- },
- right: {
- type: "Identifier",
- name: "list",
- loc: {
- start: {line: 1, column: 19},
- end: {line: 1, column: 23}
- }
- },
- body: {
- type: "ExpressionStatement",
- expression: {
- type: "CallExpression",
- callee: {
- type: "Identifier",
- name: "process",
- loc: {
- start: {line: 1, column: 25},
- end: {line: 1, column: 32}
- }
- },
- arguments: [{
- type: "Identifier",
- name: "x",
- loc: {
- start: {line: 1, column: 33},
- end: {line: 1, column: 34}
- }
- }],
- loc: {
- start: {line: 1, column: 25},
- end: {line: 1, column: 35}
- }
- },
- loc: {
- start: {line: 1, column: 25},
- end: {line: 1, column: 36}
- }
- },
- loc: {
- start: {line: 1, column: 0},
- end: {line: 1, column: 36}
- }
- }],
- loc: {
- start: {line: 1, column: 0},
- end: {line: 1, column: 36}
- }
-}, {
- ecmaVersion: 6,
- ranges: true,
- locations: true
-});
-
test("for (let x of list) process(x);", {
type: "Program",
body: [{
@@ -13204,9 +13115,16 @@ testFail("\"use strict\"; ({ v: eval } = obj)", "Assigning to eval in strict mod
testFail("\"use strict\"; ({ v: arguments } = obj)", "Assigning to arguments in strict mode (1:20)", {ecmaVersion: 6});
-testFail("for (let x = 42 in list) process(x);", "Unexpected token (1:16)", {ecmaVersion: 6});
+testFail("for (let x = 42 in list) process(x);", "for-in loop variable declaration may not have an initializer (1:5)", {ecmaVersion: 6});
+testFail("for (const x = 42 in list) process(x);", "for-in loop variable declaration may not have an initializer (1:5)", {ecmaVersion: 6});
-testFail("for (let x = 42 of list) process(x);", "Unexpected token (1:16)", {ecmaVersion: 6});
+testFail("for (let x = 42 of list) process(x);", "for-of loop variable declaration may not have an initializer (1:5)", {ecmaVersion: 6});
+testFail("for (const x = 42 of list) process(x);", "for-of loop variable declaration may not have an initializer (1:5)", {ecmaVersion: 6});
+testFail("for (var x = 42 of list) process(x);", "for-of loop variable declaration may not have an initializer (1:5)", {ecmaVersion: 6});
+testFail("for (var x = 42 of list) process(x);", "for-of loop variable declaration may not have an initializer (1:5)", {ecmaVersion: 8});
+testFail("for (var {x} = 42 of list) process(x);", "for-of loop variable declaration may not have an initializer (1:5)", {ecmaVersion: 6});
+testFail("for (var [x] = 42 of list) process(x);", "for-of loop variable declaration may not have an initializer (1:5)", {ecmaVersion: 6});
+testFail("var x; for (x = 42 of list) process(x);", "Invalid left-hand side in for-loop (1:12)", {ecmaVersion: 6});
testFail("import foo", "Unexpected token (1:10)", {ecmaVersion: 6, sourceType: "module"});
@@ -13485,15 +13403,32 @@ test("var let = 1", {
]
}, {ecmaVersion: 6})
-testFail("'use strict'; let + 1", "The keyword 'let' is reserved (1:14)", {ecmaVersion: 6})
testFail("let let", "let is disallowed as a lexically bound name (1:4)", {ecmaVersion: 6})
testFail("const let", "let is disallowed as a lexically bound name (1:6)", {ecmaVersion: 6})
-testFail("'use strict'; let let", "let is disallowed as a lexically bound name (1:18)", {ecmaVersion: 6})
+testFail("let { let } = {};", "let is disallowed as a lexically bound name (1:6)", {ecmaVersion: 6})
+
+testFail("const { let } = {};", "let is disallowed as a lexically bound name (1:8)", {ecmaVersion: 6})
+
+testFail("let [let] = [];", "let is disallowed as a lexically bound name (1:5)", {ecmaVersion: 6})
+
+testFail("const [let] = [];", "let is disallowed as a lexically bound name (1:7)", {ecmaVersion: 6})
+
+testFail("'use strict'; let + 1", "The keyword 'let' is reserved (1:14)", {ecmaVersion: 6})
+
+testFail("'use strict'; let let", "The keyword 'let' is reserved (1:18)", {ecmaVersion: 6})
+
+testFail("'use strict'; const let", "The keyword 'let' is reserved (1:20)", {ecmaVersion: 6})
+
+testFail("'use strict'; let { let } = {};", "The keyword 'let' is reserved (1:20)", {ecmaVersion: 6})
+
+testFail("'use strict'; const { let } = {};", "The keyword 'let' is reserved (1:22)", {ecmaVersion: 6})
+
+testFail("'use strict'; let [let] = [];", "The keyword 'let' is reserved (1:19)", {ecmaVersion: 6})
-testFail("'use strict'; const let", "let is disallowed as a lexically bound name (1:20)", {ecmaVersion: 6})
+testFail("'use strict'; const [let] = [];", "The keyword 'let' is reserved (1:21)", {ecmaVersion: 6})
test("if (1) let\n{}", {}, {ecmaVersion: 6})