summaryrefslogtreecommitdiff
path: root/lib/internal/repl
diff options
context:
space:
mode:
authorRuben Bridgewater <ruben@bridgewater.de>2019-04-24 23:55:43 +0200
committerRuben Bridgewater <ruben@bridgewater.de>2019-04-30 16:22:56 +0200
commitf37e40af2b34990540337cfa2932650a584d413c (patch)
treecdd773ac860316f6237f425311a9d8e496d86389 /lib/internal/repl
parent04b7c007d6e95303953bab3f9bac63f026f283cb (diff)
downloadandroid-node-v8-f37e40af2b34990540337cfa2932650a584d413c.tar.gz
android-node-v8-f37e40af2b34990540337cfa2932650a584d413c.tar.bz2
android-node-v8-f37e40af2b34990540337cfa2932650a584d413c.zip
repl: add new language features to top level await statements
This adds stage-3 language features to acorn so that it's possible to parse these features when using top level await in the REPL. 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 'lib/internal/repl')
-rw-r--r--lib/internal/repl/await.js19
1 files changed, 18 insertions, 1 deletions
diff --git a/lib/internal/repl/await.js b/lib/internal/repl/await.js
index ac0445311b..6fb10bbba0 100644
--- a/lib/internal/repl/await.js
+++ b/lib/internal/repl/await.js
@@ -4,6 +4,23 @@ const { Object } = primordials;
const acorn = require('internal/deps/acorn/acorn/dist/acorn');
const walk = require('internal/deps/acorn/acorn-walk/dist/walk');
+const privateMethods =
+ require('internal/deps/acorn-plugins/acorn-private-methods/index');
+const bigInt = require('internal/deps/acorn-plugins/acorn-bigint/index');
+const classFields =
+ require('internal/deps/acorn-plugins/acorn-class-fields/index');
+const numericSeparator =
+ require('internal/deps/acorn-plugins/acorn-numeric-separator/index');
+const staticClassFeatures =
+ require('internal/deps/acorn-plugins/acorn-static-class-features/index');
+
+const parser = acorn.Parser.extend(
+ privateMethods,
+ bigInt,
+ classFields,
+ numericSeparator,
+ staticClassFeatures
+);
const noop = () => {};
const visitorsWithoutAncestors = {
@@ -76,7 +93,7 @@ function processTopLevelAwait(src) {
const wrappedArray = wrapped.split('');
let root;
try {
- root = acorn.parse(wrapped, { ecmaVersion: 10 });
+ root = parser.parse(wrapped, { ecmaVersion: 10 });
} catch {
return null;
}