diff options
author | Ruben Bridgewater <ruben@bridgewater.de> | 2019-04-24 22:49:32 +0200 |
---|---|---|
committer | Ruben Bridgewater <ruben@bridgewater.de> | 2019-04-30 16:22:56 +0200 |
commit | 72c6ea26830025c9b7cecb2b1dfd1002481d93ad (patch) | |
tree | 51d789d32ffaa3834862722521e1f02ad02a8eae /deps/acorn-plugins/acorn-class-fields | |
parent | 98e9de7db930e505884ca8d0ca6588afbe43f127 (diff) | |
download | android-node-v8-72c6ea26830025c9b7cecb2b1dfd1002481d93ad.tar.gz android-node-v8-72c6ea26830025c9b7cecb2b1dfd1002481d93ad.tar.bz2 android-node-v8-72c6ea26830025c9b7cecb2b1dfd1002481d93ad.zip |
deps: add acorn stage-3 plugins
This adds bigint, class-fields, numeric-separators, static-class
features, private class methods and fields as dependency. That way
it's possible to use these in combination with acorn to parse these
language features.
This also removes a couple of files that were not necessary for
Node.js to reduce the code base.
PR-URL: https://github.com/nodejs/node/pull/27400
Refs: https://github.com/nodejs/node/issues/27391
Refs: https://github.com/nodejs/node/issues/25835
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Michaƫl Zasso <targos@protonmail.com>
Diffstat (limited to 'deps/acorn-plugins/acorn-class-fields')
-rw-r--r-- | deps/acorn-plugins/acorn-class-fields/CHANGELOG.md | 28 | ||||
-rw-r--r-- | deps/acorn-plugins/acorn-class-fields/LICENSE | 19 | ||||
-rw-r--r-- | deps/acorn-plugins/acorn-class-fields/README.md | 21 | ||||
-rw-r--r-- | deps/acorn-plugins/acorn-class-fields/index.js | 59 | ||||
-rw-r--r-- | deps/acorn-plugins/acorn-class-fields/package.json | 68 |
5 files changed, 195 insertions, 0 deletions
diff --git a/deps/acorn-plugins/acorn-class-fields/CHANGELOG.md b/deps/acorn-plugins/acorn-class-fields/CHANGELOG.md new file mode 100644 index 0000000000..de2c66b0c3 --- /dev/null +++ b/deps/acorn-plugins/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/deps/acorn-plugins/acorn-class-fields/LICENSE b/deps/acorn-plugins/acorn-class-fields/LICENSE new file mode 100644 index 0000000000..7c2b27a19c --- /dev/null +++ b/deps/acorn-plugins/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/deps/acorn-plugins/acorn-class-fields/README.md b/deps/acorn-plugins/acorn-class-fields/README.md new file mode 100644 index 0000000000..60f3463e94 --- /dev/null +++ b/deps/acorn-plugins/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/deps/acorn-plugins/acorn-class-fields/index.js b/deps/acorn-plugins/acorn-class-fields/index.js new file mode 100644 index 0000000000..20348c80c6 --- /dev/null +++ b/deps/acorn-plugins/acorn-class-fields/index.js @@ -0,0 +1,59 @@ +"use strict" + +const acorn = require('internal/deps/acorn/acorn/dist/acorn') +const tt = acorn.tokTypes +const privateClassElements = require('internal/deps/acorn-plugins/acorn-private-class-elements/index') + +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/deps/acorn-plugins/acorn-class-fields/package.json b/deps/acorn-plugins/acorn-class-fields/package.json new file mode 100644 index 0000000000..4df166ba19 --- /dev/null +++ b/deps/acorn-plugins/acorn-class-fields/package.json @@ -0,0 +1,68 @@ +{ + "_from": "acorn-class-fields", + "_id": "acorn-class-fields@0.3.1", + "_inBundle": false, + "_integrity": "sha512-X/8hSJuregAnrvfV1Y80VJNfeJx1uhw7yskOwvL631ygYeCGVLPumCnnPDHYZ8acV3ytHhg53K171H3tAemgiw==", + "_location": "/acorn-class-fields", + "_phantomChildren": {}, + "_requested": { + "type": "tag", + "registry": true, + "raw": "acorn-class-fields", + "name": "acorn-class-fields", + "escapedName": "acorn-class-fields", + "rawSpec": "", + "saveSpec": null, + "fetchSpec": "latest" + }, + "_requiredBy": [ + "#USER", + "/" + ], + "_resolved": "https://registry.npmjs.org/acorn-class-fields/-/acorn-class-fields-0.3.1.tgz", + "_shasum": "032ce47a9688a71d4713ee366fadcb7fefaea9e0", + "_spec": "acorn-class-fields", + "_where": "/home/ruben/repos/node/node", + "bugs": { + "url": "https://github.com/acornjs/acorn-class-fields/issues" + }, + "bundleDependencies": false, + "contributors": [ + { + "name": "Adrian Heine", + "email": "mail@adrianheine.de" + } + ], + "dependencies": { + "acorn-private-class-elements": "^0.1.1" + }, + "deprecated": false, + "description": "Support for class fields in acorn", + "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" + }, + "engines": { + "node": ">=4.8.2" + }, + "homepage": "https://github.com/acornjs/acorn-class-fields", + "license": "MIT", + "name": "acorn-class-fields", + "peerDependencies": { + "acorn": "^6.0.0" + }, + "repository": { + "type": "git", + "url": "git+https://github.com/acornjs/acorn-class-fields.git" + }, + "scripts": { + "lint": "eslint -c .eslintrc.json .", + "test": "mocha", + "test:test262": "node run_test262.js" + }, + "version": "0.3.1" +} |