deps: update acorn to 6.2.0

Includes support for bigint syntax so we can remove the acorn-bigint
plugin.

PR-URL: https://github.com/nodejs/node/pull/28649
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Reviewed-By: Richard Lau <riclau@uk.ibm.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Yongsheng Zhang <zyszys98@gmail.com>
This commit is contained in:
Michaël Zasso 2019-07-12 08:53:01 +02:00 committed by Anna Henningsen
parent 00464b5282
commit 60a207f5f2
No known key found for this signature in database
GPG Key ID: 9C63F3A6CD2AD8F9
18 changed files with 5132 additions and 5351 deletions

View File

@ -1,21 +0,0 @@
## 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!)
## 0.3.0 (2018-09-14)
* Update to new acorn 6 interface
* Actually support creating BigInt values in AST in Chrome
* Change license to MIT
## 0.2.0 (2017-12-20)
* Emit BigInt values in AST if supported by runtime engine
## 0.1.0 (2017-12-19)
Initial release

View File

@ -1,19 +0,0 @@
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.

View File

@ -1,21 +0,0 @@
# BigInt support for Acorn
[![NPM version](https://img.shields.io/npm/v/acorn-bigint.svg)](https://www.npmjs.org/package/acorn-bigint)
This is a plugin for [Acorn](http://marijnhaverbeke.nl/acorn/) - a tiny, fast JavaScript parser, written completely in JavaScript.
It implements support for arbitrary precision integers as defined in the stage 3 proposal [BigInt: Arbitrary precision integers in JavaScript](https://github.com/tc39/proposal-bigint). The emitted AST follows [an ESTree proposal](https://github.com/estree/estree/blob/132be9b9ec376adbc082dd5f6ba78aefd7a1a864/experimental/bigint.md).
## Usage
This module provides a plugin that can be used to extend the Acorn `Parser` class:
```javascript
const {Parser} = require('acorn');
const bigInt = require('acorn-bigint');
Parser.extend(bigInt).parse('100n');
```
## License
This plugin is released under an [MIT License](./LICENSE).

View File

@ -1,59 +0,0 @@
"use strict"
const acorn = require('internal/deps/acorn/acorn/dist/acorn')
const tt = acorn.tokTypes
const isIdentifierStart = acorn.isIdentifierStart
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 = this.getNumberInput(node.start, node.end)
return node
}
readRadixNumber(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 (this.input.charCodeAt(this.pos) == 110) {
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")
return this.finishToken(tt.num, val)
}
readNumber(startsWithDot) {
let start = this.pos
// Not an int
if (startsWithDot) return super.readNumber(startsWithDot)
// Legacy octal
if (this.input.charCodeAt(start) === 48 && this.input.charCodeAt(start + 1) !== 110) {
return super.readNumber(startsWithDot)
}
if (this.readInt(10) === null) this.raise(start, "Invalid number")
// Not a BigInt, reset and parse again
if (this.input.charCodeAt(this.pos) != 110) {
this.pos = start
return super.readNumber(startsWithDot)
}
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)
}
}
}

View File

@ -1,65 +0,0 @@
{
"_from": "acorn-bigint",
"_id": "acorn-bigint@0.4.0",
"_inBundle": false,
"_integrity": "sha512-W9iaqWzqFo7ZBLmI9dMjHYGrN0Nm/ZgToqhvd3RELJux7RsX6k1/80h+bD9TtTpeKky/kYNbr3+vHWqI3hdyfA==",
"_location": "/acorn-bigint",
"_phantomChildren": {},
"_requested": {
"type": "tag",
"registry": true,
"raw": "acorn-bigint",
"name": "acorn-bigint",
"escapedName": "acorn-bigint",
"rawSpec": "",
"saveSpec": null,
"fetchSpec": "latest"
},
"_requiredBy": [
"#USER",
"/"
],
"_resolved": "https://registry.npmjs.org/acorn-bigint/-/acorn-bigint-0.4.0.tgz",
"_shasum": "af3245ed8a7c3747387fca4680ae1960f617c4cd",
"_spec": "acorn-bigint",
"_where": "/home/ruben/repos/node/node",
"bugs": {
"url": "https://github.com/acornjs/acorn-bigint/issues"
},
"bundleDependencies": false,
"contributors": [
{
"name": "Adrian Heine",
"email": "mail@adrianheine.de"
}
],
"deprecated": false,
"description": "Support for BigInt in acorn",
"devDependencies": {
"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"
},
"engines": {
"node": ">=4.8.2"
},
"homepage": "https://github.com/acornjs/acorn-bigint",
"license": "MIT",
"name": "acorn-bigint",
"peerDependencies": {
"acorn": "^6.0.0"
},
"repository": {
"type": "git",
"url": "git+https://github.com/acornjs/acorn-bigint.git"
},
"scripts": {
"lint": "eslint -c .eslintrc.json .",
"test": "mocha",
"test:test262": "node run_test262.js"
},
"version": "0.4.0"
}

View File

@ -1,3 +1,9 @@
## 6.2.0 (2017-07-04)
### New features
Add support for `Import` nodes.
## 6.1.0 (2018-09-28) ## 6.1.0 (2018-09-28)
### New features ### New features

View File

@ -6,7 +6,7 @@ An abstract syntax tree walker for the
## Community ## Community
Acorn is open source software released under an Acorn is open source software released under an
[MIT license](https://github.com/acornjs/acorn/blob/master/LICENSE). [MIT license](https://github.com/acornjs/acorn/blob/master/acorn-walk/LICENSE).
You are welcome to You are welcome to
[report bugs](https://github.com/acornjs/acorn/issues) or create pull [report bugs](https://github.com/acornjs/acorn/issues) or create pull

View File

@ -1,40 +1,40 @@
(function (global, factory) { (function (global, factory) {
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) : typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) :
typeof define === 'function' && define.amd ? define(['exports'], factory) : typeof define === 'function' && define.amd ? define(['exports'], factory) :
(factory((global.acorn = global.acorn || {}, global.acorn.walk = {}))); (global = global || self, factory((global.acorn = global.acorn || {}, global.acorn.walk = {})));
}(this, (function (exports) { 'use strict'; }(this, function (exports) { 'use strict';
// AST walker module for Mozilla Parser API compatible trees // AST walker module for Mozilla Parser API compatible trees
// A simple walk is one where you simply specify callbacks to be // A simple walk is one where you simply specify callbacks to be
// called on specific nodes. The last two arguments are optional. A // called on specific nodes. The last two arguments are optional. A
// simple use would be // simple use would be
// //
// walk.simple(myTree, { // walk.simple(myTree, {
// Expression: function(node) { ... } // Expression: function(node) { ... }
// }); // });
// //
// to do something with all expressions. All Parser API node types // to do something with all expressions. All Parser API node types
// can be used to identify node types, as well as Expression and // can be used to identify node types, as well as Expression and
// Statement, which denote categories of nodes. // Statement, which denote categories of nodes.
// //
// The base argument can be used to pass a custom (recursive) // The base argument can be used to pass a custom (recursive)
// walker, and state can be used to give this walked an initial // walker, and state can be used to give this walked an initial
// state. // state.
function simple(node, visitors, baseVisitor, state, override) { function simple(node, visitors, baseVisitor, state, override) {
if (!baseVisitor) { baseVisitor = base if (!baseVisitor) { baseVisitor = base
; }(function c(node, st, override) { ; }(function c(node, st, override) {
var type = override || node.type, found = visitors[type]; var type = override || node.type, found = visitors[type];
baseVisitor[type](node, st, c); baseVisitor[type](node, st, c);
if (found) { found(node, st); } if (found) { found(node, st); }
})(node, state, override); })(node, state, override);
} }
// An ancestor walk keeps an array of ancestor nodes (including the // An ancestor walk keeps an array of ancestor nodes (including the
// current node) and passes them to the callback as third parameter // current node) and passes them to the callback as third parameter
// (and also as state parameter when no other state is present). // (and also as state parameter when no other state is present).
function ancestor(node, visitors, baseVisitor, state) { function ancestor(node, visitors, baseVisitor, state) {
var ancestors = []; var ancestors = [];
if (!baseVisitor) { baseVisitor = base if (!baseVisitor) { baseVisitor = base
; }(function c(node, st, override) { ; }(function c(node, st, override) {
@ -45,45 +45,47 @@ function ancestor(node, visitors, baseVisitor, state) {
if (found) { found(node, st || ancestors, ancestors); } if (found) { found(node, st || ancestors, ancestors); }
if (isNew) { ancestors.pop(); } if (isNew) { ancestors.pop(); }
})(node, state); })(node, state);
} }
// A recursive walk is one where your functions override the default // A recursive walk is one where your functions override the default
// walkers. They can modify and replace the state parameter that's // walkers. They can modify and replace the state parameter that's
// threaded through the walk, and can opt how and whether to walk // threaded through the walk, and can opt how and whether to walk
// their child nodes (by calling their third argument on these // their child nodes (by calling their third argument on these
// nodes). // nodes).
function recursive(node, state, funcs, baseVisitor, override) { function recursive(node, state, funcs, baseVisitor, override) {
var visitor = funcs ? make(funcs, baseVisitor || undefined) : baseVisitor;(function c(node, st, override) { var visitor = funcs ? make(funcs, baseVisitor || undefined) : baseVisitor
;(function c(node, st, override) {
visitor[override || node.type](node, st, c); visitor[override || node.type](node, st, c);
})(node, state, override); })(node, state, override);
} }
function makeTest(test) { function makeTest(test) {
if (typeof test === "string") if (typeof test === "string")
{ return function (type) { return type === test; } } { return function (type) { return type === test; } }
else if (!test) else if (!test)
{ return function () { return true; } } { return function () { return true; } }
else else
{ return test } { return test }
} }
var Found = function Found(node, state) { this.node = node; this.state = state; }; var Found = function Found(node, state) { this.node = node; this.state = state; };
// A full walk triggers the callback on each node // A full walk triggers the callback on each node
function full(node, callback, baseVisitor, state, override) { function full(node, callback, baseVisitor, state, override) {
if (!baseVisitor) { baseVisitor = base if (!baseVisitor) { baseVisitor = base
; }(function c(node, st, override) { ; }(function c(node, st, override) {
var type = override || node.type; var type = override || node.type;
baseVisitor[type](node, st, c); baseVisitor[type](node, st, c);
if (!override) { callback(node, st, type); } if (!override) { callback(node, st, type); }
})(node, state, override); })(node, state, override);
} }
// An fullAncestor walk is like an ancestor walk, but triggers // An fullAncestor walk is like an ancestor walk, but triggers
// the callback on each node // the callback on each node
function fullAncestor(node, callback, baseVisitor, state) { function fullAncestor(node, callback, baseVisitor, state) {
if (!baseVisitor) { baseVisitor = base; } if (!baseVisitor) { baseVisitor = base; }
var ancestors = [];(function c(node, st, override) { var ancestors = []
;(function c(node, st, override) {
var type = override || node.type; var type = override || node.type;
var isNew = node !== ancestors[ancestors.length - 1]; var isNew = node !== ancestors[ancestors.length - 1];
if (isNew) { ancestors.push(node); } if (isNew) { ancestors.push(node); }
@ -91,12 +93,12 @@ function fullAncestor(node, callback, baseVisitor, state) {
if (!override) { callback(node, st || ancestors, ancestors, type); } if (!override) { callback(node, st || ancestors, ancestors, type); }
if (isNew) { ancestors.pop(); } if (isNew) { ancestors.pop(); }
})(node, state); })(node, state);
} }
// Find a node with a given start, end, and type (all are optional, // Find a node with a given start, end, and type (all are optional,
// null can be used as wildcard). Returns a {node, state} object, or // null can be used as wildcard). Returns a {node, state} object, or
// undefined when it doesn't find a matching node. // undefined when it doesn't find a matching node.
function findNodeAt(node, start, end, test, baseVisitor, state) { function findNodeAt(node, start, end, test, baseVisitor, state) {
if (!baseVisitor) { baseVisitor = base; } if (!baseVisitor) { baseVisitor = base; }
test = makeTest(test); test = makeTest(test);
try { try {
@ -114,11 +116,11 @@ function findNodeAt(node, start, end, test, baseVisitor, state) {
if (e instanceof Found) { return e } if (e instanceof Found) { return e }
throw e throw e
} }
} }
// Find the innermost node of a given type that contains the given // Find the innermost node of a given type that contains the given
// position. Interface similar to findNodeAt. // position. Interface similar to findNodeAt.
function findNodeAround(node, pos, test, baseVisitor, state) { function findNodeAround(node, pos, test, baseVisitor, state) {
test = makeTest(test); test = makeTest(test);
if (!baseVisitor) { baseVisitor = base; } if (!baseVisitor) { baseVisitor = base; }
try { try {
@ -132,10 +134,10 @@ function findNodeAround(node, pos, test, baseVisitor, state) {
if (e instanceof Found) { return e } if (e instanceof Found) { return e }
throw e throw e
} }
} }
// Find the outermost matching node after a given position. // Find the outermost matching node after a given position.
function findNodeAfter(node, pos, test, baseVisitor, state) { function findNodeAfter(node, pos, test, baseVisitor, state) {
test = makeTest(test); test = makeTest(test);
if (!baseVisitor) { baseVisitor = base; } if (!baseVisitor) { baseVisitor = base; }
try { try {
@ -149,13 +151,14 @@ function findNodeAfter(node, pos, test, baseVisitor, state) {
if (e instanceof Found) { return e } if (e instanceof Found) { return e }
throw e throw e
} }
} }
// Find the outermost matching node before a given position. // Find the outermost matching node before a given position.
function findNodeBefore(node, pos, test, baseVisitor, state) { function findNodeBefore(node, pos, test, baseVisitor, state) {
test = makeTest(test); test = makeTest(test);
if (!baseVisitor) { baseVisitor = base; } if (!baseVisitor) { baseVisitor = base; }
var max;(function c(node, st, override) { var max
;(function c(node, st, override) {
if (node.start > pos) { return } if (node.start > pos) { return }
var type = override || node.type; var type = override || node.type;
if (node.end <= pos && (!max || max.node.end < node.end) && test(type, node)) if (node.end <= pos && (!max || max.node.end < node.end) && test(type, node))
@ -163,68 +166,68 @@ function findNodeBefore(node, pos, test, baseVisitor, state) {
baseVisitor[type](node, st, c); baseVisitor[type](node, st, c);
})(node, state); })(node, state);
return max return max
} }
// Fallback to an Object.create polyfill for older environments. // Fallback to an Object.create polyfill for older environments.
var create = Object.create || function(proto) { var create = Object.create || function(proto) {
function Ctor() {} function Ctor() {}
Ctor.prototype = proto; Ctor.prototype = proto;
return new Ctor return new Ctor
}; };
// Used to create a custom walker. Will fill in all missing node // Used to create a custom walker. Will fill in all missing node
// type properties with the defaults. // type properties with the defaults.
function make(funcs, baseVisitor) { function make(funcs, baseVisitor) {
var visitor = create(baseVisitor || base); var visitor = create(baseVisitor || base);
for (var type in funcs) { visitor[type] = funcs[type]; } for (var type in funcs) { visitor[type] = funcs[type]; }
return visitor return visitor
} }
function skipThrough(node, st, c) { c(node, st); } function skipThrough(node, st, c) { c(node, st); }
function ignore(_node, _st, _c) {} function ignore(_node, _st, _c) {}
// Node walkers. // Node walkers.
var base = {}; var base = {};
base.Program = base.BlockStatement = function (node, st, c) { base.Program = base.BlockStatement = function (node, st, c) {
for (var i = 0, list = node.body; i < list.length; i += 1) for (var i = 0, list = node.body; i < list.length; i += 1)
{ {
var stmt = list[i]; var stmt = list[i];
c(stmt, st, "Statement"); c(stmt, st, "Statement");
} }
}; };
base.Statement = skipThrough; base.Statement = skipThrough;
base.EmptyStatement = ignore; base.EmptyStatement = ignore;
base.ExpressionStatement = base.ParenthesizedExpression = base.ExpressionStatement = base.ParenthesizedExpression =
function (node, st, c) { return c(node.expression, st, "Expression"); }; function (node, st, c) { return c(node.expression, st, "Expression"); };
base.IfStatement = function (node, st, c) { base.IfStatement = function (node, st, c) {
c(node.test, st, "Expression"); c(node.test, st, "Expression");
c(node.consequent, st, "Statement"); c(node.consequent, st, "Statement");
if (node.alternate) { c(node.alternate, st, "Statement"); } if (node.alternate) { c(node.alternate, st, "Statement"); }
}; };
base.LabeledStatement = function (node, st, c) { return c(node.body, st, "Statement"); }; base.LabeledStatement = function (node, st, c) { return c(node.body, st, "Statement"); };
base.BreakStatement = base.ContinueStatement = ignore; base.BreakStatement = base.ContinueStatement = ignore;
base.WithStatement = function (node, st, c) { base.WithStatement = function (node, st, c) {
c(node.object, st, "Expression"); c(node.object, st, "Expression");
c(node.body, st, "Statement"); c(node.body, st, "Statement");
}; };
base.SwitchStatement = function (node, st, c) { base.SwitchStatement = function (node, st, c) {
c(node.discriminant, st, "Expression"); c(node.discriminant, st, "Expression");
for (var i = 0, list = node.cases; i < list.length; i += 1) { for (var i$1 = 0, list$1 = node.cases; i$1 < list$1.length; i$1 += 1) {
var cs = list[i]; var cs = list$1[i$1];
if (cs.test) { c(cs.test, st, "Expression"); } if (cs.test) { c(cs.test, st, "Expression"); }
for (var i$1 = 0, list$1 = cs.consequent; i$1 < list$1.length; i$1 += 1) for (var i = 0, list = cs.consequent; i < list.length; i += 1)
{ {
var cons = list$1[i$1]; var cons = list[i];
c(cons, st, "Statement"); c(cons, st, "Statement");
} }
} }
}; };
base.SwitchCase = function (node, st, c) { base.SwitchCase = function (node, st, c) {
if (node.test) { c(node.test, st, "Expression"); } if (node.test) { c(node.test, st, "Expression"); }
for (var i = 0, list = node.consequent; i < list.length; i += 1) for (var i = 0, list = node.consequent; i < list.length; i += 1)
{ {
@ -232,57 +235,57 @@ base.SwitchCase = function (node, st, c) {
c(cons, st, "Statement"); c(cons, st, "Statement");
} }
}; };
base.ReturnStatement = base.YieldExpression = base.AwaitExpression = function (node, st, c) { base.ReturnStatement = base.YieldExpression = base.AwaitExpression = function (node, st, c) {
if (node.argument) { c(node.argument, st, "Expression"); } if (node.argument) { c(node.argument, st, "Expression"); }
}; };
base.ThrowStatement = base.SpreadElement = base.ThrowStatement = base.SpreadElement =
function (node, st, c) { return c(node.argument, st, "Expression"); }; function (node, st, c) { return c(node.argument, st, "Expression"); };
base.TryStatement = function (node, st, c) { base.TryStatement = function (node, st, c) {
c(node.block, st, "Statement"); c(node.block, st, "Statement");
if (node.handler) { c(node.handler, st); } if (node.handler) { c(node.handler, st); }
if (node.finalizer) { c(node.finalizer, st, "Statement"); } if (node.finalizer) { c(node.finalizer, st, "Statement"); }
}; };
base.CatchClause = function (node, st, c) { base.CatchClause = function (node, st, c) {
if (node.param) { c(node.param, st, "Pattern"); } if (node.param) { c(node.param, st, "Pattern"); }
c(node.body, st, "Statement"); c(node.body, st, "Statement");
}; };
base.WhileStatement = base.DoWhileStatement = function (node, st, c) { base.WhileStatement = base.DoWhileStatement = function (node, st, c) {
c(node.test, st, "Expression"); c(node.test, st, "Expression");
c(node.body, st, "Statement"); c(node.body, st, "Statement");
}; };
base.ForStatement = function (node, st, c) { base.ForStatement = function (node, st, c) {
if (node.init) { c(node.init, st, "ForInit"); } if (node.init) { c(node.init, st, "ForInit"); }
if (node.test) { c(node.test, st, "Expression"); } if (node.test) { c(node.test, st, "Expression"); }
if (node.update) { c(node.update, st, "Expression"); } if (node.update) { c(node.update, st, "Expression"); }
c(node.body, st, "Statement"); c(node.body, st, "Statement");
}; };
base.ForInStatement = base.ForOfStatement = function (node, st, c) { base.ForInStatement = base.ForOfStatement = function (node, st, c) {
c(node.left, st, "ForInit"); c(node.left, st, "ForInit");
c(node.right, st, "Expression"); c(node.right, st, "Expression");
c(node.body, st, "Statement"); c(node.body, st, "Statement");
}; };
base.ForInit = function (node, st, c) { base.ForInit = function (node, st, c) {
if (node.type === "VariableDeclaration") { c(node, st); } if (node.type === "VariableDeclaration") { c(node, st); }
else { c(node, st, "Expression"); } else { c(node, st, "Expression"); }
}; };
base.DebuggerStatement = ignore; base.DebuggerStatement = ignore;
base.FunctionDeclaration = function (node, st, c) { return c(node, st, "Function"); }; base.FunctionDeclaration = function (node, st, c) { return c(node, st, "Function"); };
base.VariableDeclaration = function (node, st, c) { base.VariableDeclaration = function (node, st, c) {
for (var i = 0, list = node.declarations; i < list.length; i += 1) for (var i = 0, list = node.declarations; i < list.length; i += 1)
{ {
var decl = list[i]; var decl = list[i];
c(decl, st); c(decl, st);
} }
}; };
base.VariableDeclarator = function (node, st, c) { base.VariableDeclarator = function (node, st, c) {
c(node.id, st, "Pattern"); c(node.id, st, "Pattern");
if (node.init) { c(node.init, st, "Expression"); } if (node.init) { c(node.init, st, "Expression"); }
}; };
base.Function = function (node, st, c) { base.Function = function (node, st, c) {
if (node.id) { c(node.id, st, "Pattern"); } if (node.id) { c(node.id, st, "Pattern"); }
for (var i = 0, list = node.params; i < list.length; i += 1) for (var i = 0, list = node.params; i < list.length; i += 1)
{ {
@ -291,27 +294,27 @@ base.Function = function (node, st, c) {
c(param, st, "Pattern"); c(param, st, "Pattern");
} }
c(node.body, st, node.expression ? "Expression" : "Statement"); c(node.body, st, node.expression ? "Expression" : "Statement");
}; };
base.Pattern = function (node, st, c) { base.Pattern = function (node, st, c) {
if (node.type === "Identifier") if (node.type === "Identifier")
{ c(node, st, "VariablePattern"); } { c(node, st, "VariablePattern"); }
else if (node.type === "MemberExpression") else if (node.type === "MemberExpression")
{ c(node, st, "MemberPattern"); } { c(node, st, "MemberPattern"); }
else else
{ c(node, st); } { c(node, st); }
}; };
base.VariablePattern = ignore; base.VariablePattern = ignore;
base.MemberPattern = skipThrough; base.MemberPattern = skipThrough;
base.RestElement = function (node, st, c) { return c(node.argument, st, "Pattern"); }; base.RestElement = function (node, st, c) { return c(node.argument, st, "Pattern"); };
base.ArrayPattern = function (node, st, c) { base.ArrayPattern = function (node, st, c) {
for (var i = 0, list = node.elements; i < list.length; i += 1) { for (var i = 0, list = node.elements; i < list.length; i += 1) {
var elt = list[i]; var elt = list[i];
if (elt) { c(elt, st, "Pattern"); } if (elt) { c(elt, st, "Pattern"); }
} }
}; };
base.ObjectPattern = function (node, st, c) { base.ObjectPattern = function (node, st, c) {
for (var i = 0, list = node.properties; i < list.length; i += 1) { for (var i = 0, list = node.properties; i < list.length; i += 1) {
var prop = list[i]; var prop = list[i];
@ -322,35 +325,35 @@ base.ObjectPattern = function (node, st, c) {
c(prop.argument, st, "Pattern"); c(prop.argument, st, "Pattern");
} }
} }
}; };
base.Expression = skipThrough; base.Expression = skipThrough;
base.ThisExpression = base.Super = base.MetaProperty = ignore; base.ThisExpression = base.Super = base.MetaProperty = ignore;
base.ArrayExpression = function (node, st, c) { base.ArrayExpression = function (node, st, c) {
for (var i = 0, list = node.elements; i < list.length; i += 1) { for (var i = 0, list = node.elements; i < list.length; i += 1) {
var elt = list[i]; var elt = list[i];
if (elt) { c(elt, st, "Expression"); } if (elt) { c(elt, st, "Expression"); }
} }
}; };
base.ObjectExpression = function (node, st, c) { base.ObjectExpression = function (node, st, c) {
for (var i = 0, list = node.properties; i < list.length; i += 1) for (var i = 0, list = node.properties; i < list.length; i += 1)
{ {
var prop = list[i]; var prop = list[i];
c(prop, st); c(prop, st);
} }
}; };
base.FunctionExpression = base.ArrowFunctionExpression = base.FunctionDeclaration; base.FunctionExpression = base.ArrowFunctionExpression = base.FunctionDeclaration;
base.SequenceExpression = function (node, st, c) { base.SequenceExpression = function (node, st, c) {
for (var i = 0, list = node.expressions; i < list.length; i += 1) for (var i = 0, list = node.expressions; i < list.length; i += 1)
{ {
var expr = list[i]; var expr = list[i];
c(expr, st, "Expression"); c(expr, st, "Expression");
} }
}; };
base.TemplateLiteral = function (node, st, c) { base.TemplateLiteral = function (node, st, c) {
for (var i = 0, list = node.quasis; i < list.length; i += 1) for (var i = 0, list = node.quasis; i < list.length; i += 1)
{ {
var quasi = list[i]; var quasi = list[i];
@ -364,25 +367,25 @@ base.TemplateLiteral = function (node, st, c) {
c(expr, st, "Expression"); c(expr, st, "Expression");
} }
}; };
base.TemplateElement = ignore; base.TemplateElement = ignore;
base.UnaryExpression = base.UpdateExpression = function (node, st, c) { base.UnaryExpression = base.UpdateExpression = function (node, st, c) {
c(node.argument, st, "Expression"); c(node.argument, st, "Expression");
}; };
base.BinaryExpression = base.LogicalExpression = function (node, st, c) { base.BinaryExpression = base.LogicalExpression = function (node, st, c) {
c(node.left, st, "Expression"); c(node.left, st, "Expression");
c(node.right, st, "Expression"); c(node.right, st, "Expression");
}; };
base.AssignmentExpression = base.AssignmentPattern = function (node, st, c) { base.AssignmentExpression = base.AssignmentPattern = function (node, st, c) {
c(node.left, st, "Pattern"); c(node.left, st, "Pattern");
c(node.right, st, "Expression"); c(node.right, st, "Expression");
}; };
base.ConditionalExpression = function (node, st, c) { base.ConditionalExpression = function (node, st, c) {
c(node.test, st, "Expression"); c(node.test, st, "Expression");
c(node.consequent, st, "Expression"); c(node.consequent, st, "Expression");
c(node.alternate, st, "Expression"); c(node.alternate, st, "Expression");
}; };
base.NewExpression = base.CallExpression = function (node, st, c) { base.NewExpression = base.CallExpression = function (node, st, c) {
c(node.callee, st, "Expression"); c(node.callee, st, "Expression");
if (node.arguments) if (node.arguments)
{ for (var i = 0, list = node.arguments; i < list.length; i += 1) { for (var i = 0, list = node.arguments; i < list.length; i += 1)
@ -391,20 +394,20 @@ base.NewExpression = base.CallExpression = function (node, st, c) {
c(arg, st, "Expression"); c(arg, st, "Expression");
} } } }
}; };
base.MemberExpression = function (node, st, c) { base.MemberExpression = function (node, st, c) {
c(node.object, st, "Expression"); c(node.object, st, "Expression");
if (node.computed) { c(node.property, st, "Expression"); } if (node.computed) { c(node.property, st, "Expression"); }
}; };
base.ExportNamedDeclaration = base.ExportDefaultDeclaration = function (node, st, c) { base.ExportNamedDeclaration = base.ExportDefaultDeclaration = function (node, st, c) {
if (node.declaration) if (node.declaration)
{ c(node.declaration, st, node.type === "ExportNamedDeclaration" || node.declaration.id ? "Statement" : "Expression"); } { c(node.declaration, st, node.type === "ExportNamedDeclaration" || node.declaration.id ? "Statement" : "Expression"); }
if (node.source) { c(node.source, st, "Expression"); } if (node.source) { c(node.source, st, "Expression"); }
}; };
base.ExportAllDeclaration = function (node, st, c) { base.ExportAllDeclaration = function (node, st, c) {
c(node.source, st, "Expression"); c(node.source, st, "Expression");
}; };
base.ImportDeclaration = function (node, st, c) { base.ImportDeclaration = function (node, st, c) {
for (var i = 0, list = node.specifiers; i < list.length; i += 1) for (var i = 0, list = node.specifiers; i < list.length; i += 1)
{ {
var spec = list[i]; var spec = list[i];
@ -412,45 +415,44 @@ base.ImportDeclaration = function (node, st, c) {
c(spec, st); c(spec, st);
} }
c(node.source, st, "Expression"); 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 = function (node, st, c) { base.TaggedTemplateExpression = function (node, st, c) {
c(node.tag, st, "Expression"); c(node.tag, st, "Expression");
c(node.quasi, st, "Expression"); c(node.quasi, st, "Expression");
}; };
base.ClassDeclaration = base.ClassExpression = function (node, st, c) { return c(node, st, "Class"); }; base.ClassDeclaration = base.ClassExpression = function (node, st, c) { return c(node, st, "Class"); };
base.Class = function (node, st, c) { base.Class = function (node, st, c) {
if (node.id) { c(node.id, st, "Pattern"); } if (node.id) { c(node.id, st, "Pattern"); }
if (node.superClass) { c(node.superClass, st, "Expression"); } if (node.superClass) { c(node.superClass, st, "Expression"); }
c(node.body, st); c(node.body, st);
}; };
base.ClassBody = function (node, st, c) { base.ClassBody = function (node, st, c) {
for (var i = 0, list = node.body; i < list.length; i += 1) for (var i = 0, list = node.body; i < list.length; i += 1)
{ {
var elt = list[i]; var elt = list[i];
c(elt, st); c(elt, st);
} }
}; };
base.MethodDefinition = base.Property = function (node, st, c) { base.MethodDefinition = base.Property = function (node, st, c) {
if (node.computed) { c(node.key, st, "Expression"); } if (node.computed) { c(node.key, st, "Expression"); }
c(node.value, st, "Expression"); c(node.value, st, "Expression");
}; };
exports.simple = simple; exports.ancestor = ancestor;
exports.ancestor = ancestor; exports.base = base;
exports.recursive = recursive; exports.findNodeAfter = findNodeAfter;
exports.full = full; exports.findNodeAround = findNodeAround;
exports.fullAncestor = fullAncestor; exports.findNodeAt = findNodeAt;
exports.findNodeAt = findNodeAt; exports.findNodeBefore = findNodeBefore;
exports.findNodeAround = findNodeAround; exports.full = full;
exports.findNodeAfter = findNodeAfter; exports.fullAncestor = fullAncestor;
exports.findNodeBefore = findNodeBefore; exports.make = make;
exports.make = make; exports.recursive = recursive;
exports.base = base; exports.simple = simple;
Object.defineProperty(exports, '__esModule', { value: true }); Object.defineProperty(exports, '__esModule', { value: true });
}))); }));
//# sourceMappingURL=walk.js.map

View File

@ -4,7 +4,7 @@
"homepage": "https://github.com/acornjs/acorn", "homepage": "https://github.com/acornjs/acorn",
"main": "dist/walk.js", "main": "dist/walk.js",
"module": "dist/walk.mjs", "module": "dist/walk.mjs",
"version": "6.1.1", "version": "6.2.0",
"engines": {"node": ">=0.4.0"}, "engines": {"node": ">=0.4.0"},
"maintainers": [ "maintainers": [
{ {

View File

@ -1,3 +1,25 @@
## 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
Fix bug that caused parsing default exports of with names to fail.
## 6.1.0 (2019-02-08) ## 6.1.0 (2019-02-08)
### Bug fixes ### Bug fixes

View File

@ -54,7 +54,7 @@ an object containing any of these fields:
- **ecmaVersion**: Indicates the ECMAScript version to parse. Must be - **ecmaVersion**: Indicates the ECMAScript version to parse. Must be
either 3, 5, 6 (2015), 7 (2016), 8 (2017), 9 (2018) or 10 (2019, partial 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 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 **NOTE**: Only 'stage 4' (finalized) ECMAScript features are being
implemented by Acorn. Other proposed new features can be implemented 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: Plugins for ECMAScript proposals:
- [`acorn-stage3`](https://github.com/acornjs/acorn-stage3): Parse most stage 3 proposals, bundling: - [`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-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-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-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 - [`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

File diff suppressed because it is too large Load Diff

View File

@ -4,7 +4,7 @@
"homepage": "https://github.com/acornjs/acorn", "homepage": "https://github.com/acornjs/acorn",
"main": "dist/acorn.js", "main": "dist/acorn.js",
"module": "dist/acorn.mjs", "module": "dist/acorn.mjs",
"version": "6.1.0", "version": "6.2.0",
"engines": {"node": ">=0.4.0"}, "engines": {"node": ">=0.4.0"},
"maintainers": [ "maintainers": [
{ {

View File

@ -204,7 +204,6 @@ function parseCode(code, offset) {
const acorn = require('internal/deps/acorn/acorn/dist/acorn'); const acorn = require('internal/deps/acorn/acorn/dist/acorn');
const privateMethods = const privateMethods =
require('internal/deps/acorn-plugins/acorn-private-methods/index'); require('internal/deps/acorn-plugins/acorn-private-methods/index');
const bigInt = require('internal/deps/acorn-plugins/acorn-bigint/index');
const classFields = const classFields =
require('internal/deps/acorn-plugins/acorn-class-fields/index'); require('internal/deps/acorn-plugins/acorn-class-fields/index');
const numericSeparator = const numericSeparator =
@ -216,7 +215,6 @@ function parseCode(code, offset) {
const Parser = acorn.Parser.extend( const Parser = acorn.Parser.extend(
privateMethods, privateMethods,
bigInt,
classFields, classFields,
numericSeparator, numericSeparator,
staticClassFeatures staticClassFeatures
@ -228,7 +226,7 @@ function parseCode(code, offset) {
// Parse the read code until the correct expression is found. // Parse the read code until the correct expression is found.
do { do {
try { try {
node = parseExpressionAt(code, start); node = parseExpressionAt(code, start, { ecmaVersion: 11 });
start = node.end + 1 || start; start = node.end + 1 || start;
// Find the CallExpression in the tree. // Find the CallExpression in the tree.
node = findNodeAround(node, offset, 'CallExpression'); node = findNodeAround(node, offset, 'CallExpression');

View File

@ -6,7 +6,6 @@ const acorn = require('internal/deps/acorn/acorn/dist/acorn');
const walk = require('internal/deps/acorn/acorn-walk/dist/walk'); const walk = require('internal/deps/acorn/acorn-walk/dist/walk');
const privateMethods = const privateMethods =
require('internal/deps/acorn-plugins/acorn-private-methods/index'); require('internal/deps/acorn-plugins/acorn-private-methods/index');
const bigInt = require('internal/deps/acorn-plugins/acorn-bigint/index');
const classFields = const classFields =
require('internal/deps/acorn-plugins/acorn-class-fields/index'); require('internal/deps/acorn-plugins/acorn-class-fields/index');
const numericSeparator = const numericSeparator =
@ -16,7 +15,6 @@ const staticClassFeatures =
const parser = acorn.Parser.extend( const parser = acorn.Parser.extend(
privateMethods, privateMethods,
bigInt,
classFields, classFields,
numericSeparator, numericSeparator,
staticClassFeatures staticClassFeatures
@ -93,7 +91,7 @@ function processTopLevelAwait(src) {
const wrappedArray = wrapped.split(''); const wrappedArray = wrapped.split('');
let root; let root;
try { try {
root = parser.parse(wrapped, { ecmaVersion: 10 }); root = parser.parse(wrapped, { ecmaVersion: 11 });
} catch { } catch {
return null; return null;
} }

View File

@ -3,7 +3,6 @@
const acorn = require('internal/deps/acorn/acorn/dist/acorn'); const acorn = require('internal/deps/acorn/acorn/dist/acorn');
const privateMethods = const privateMethods =
require('internal/deps/acorn-plugins/acorn-private-methods/index'); require('internal/deps/acorn-plugins/acorn-private-methods/index');
const bigInt = require('internal/deps/acorn-plugins/acorn-bigint/index');
const classFields = const classFields =
require('internal/deps/acorn-plugins/acorn-class-fields/index'); require('internal/deps/acorn-plugins/acorn-class-fields/index');
const numericSeparator = const numericSeparator =
@ -44,7 +43,6 @@ function isRecoverableError(e, code) {
const RecoverableParser = AcornParser const RecoverableParser = AcornParser
.extend( .extend(
privateMethods, privateMethods,
bigInt,
classFields, classFields,
numericSeparator, numericSeparator,
staticClassFeatures, staticClassFeatures,
@ -78,7 +76,7 @@ function isRecoverableError(e, code) {
// Try to parse the code with acorn. If the parse fails, ignore the acorn // Try to parse the code with acorn. If the parse fails, ignore the acorn
// error and return the recoverable status. // error and return the recoverable status.
try { try {
RecoverableParser.parse(code, { ecmaVersion: 10 }); RecoverableParser.parse(code, { ecmaVersion: 11 });
// Odd case: the underlying JS engine (V8, Chakra) rejected this input // Odd case: the underlying JS engine (V8, Chakra) rejected this input
// but Acorn detected no issue. Presume that additional text won't // but Acorn detected no issue. Presume that additional text won't

View File

@ -223,7 +223,6 @@
'deps/node-inspect/lib/internal/inspect_repl.js', 'deps/node-inspect/lib/internal/inspect_repl.js',
'deps/acorn/acorn/dist/acorn.js', 'deps/acorn/acorn/dist/acorn.js',
'deps/acorn/acorn-walk/dist/walk.js', 'deps/acorn/acorn-walk/dist/walk.js',
'deps/acorn-plugins/acorn-bigint/index.js',
'deps/acorn-plugins/acorn-class-fields/index.js', 'deps/acorn-plugins/acorn-class-fields/index.js',
'deps/acorn-plugins/acorn-numeric-separator/index.js', 'deps/acorn-plugins/acorn-numeric-separator/index.js',
'deps/acorn-plugins/acorn-private-class-elements/index.js', 'deps/acorn-plugins/acorn-private-class-elements/index.js',

View File

@ -30,7 +30,7 @@ fi
# Dependencies bundled in distributions # Dependencies bundled in distributions
addlicense "Acorn" "deps/acorn" "$(cat ${rootdir}/deps/acorn/acorn/LICENSE)" addlicense "Acorn" "deps/acorn" "$(cat ${rootdir}/deps/acorn/acorn/LICENSE)"
addlicense "Acorn plugins" "deps/acorn-plugins" "$(cat ${rootdir}/deps/acorn-plugins/acorn-bigint/LICENSE)" addlicense "Acorn plugins" "deps/acorn-plugins" "$(cat ${rootdir}/deps/acorn-plugins/acorn-class-fields/LICENSE)"
addlicense "c-ares" "deps/cares" "$(tail -n +3 ${rootdir}/deps/cares/LICENSE.md)" addlicense "c-ares" "deps/cares" "$(tail -n +3 ${rootdir}/deps/cares/LICENSE.md)"
addlicense "HTTP Parser" "deps/http_parser" "$(cat deps/http_parser/LICENSE-MIT)" addlicense "HTTP Parser" "deps/http_parser" "$(cat deps/http_parser/LICENSE-MIT)"
if [ -f "${rootdir}/deps/icu/LICENSE" ]; then if [ -f "${rootdir}/deps/icu/LICENSE" ]; then