Skip to content

Commit

Permalink
repl: add new language features to top level await statements
Browse files Browse the repository at this point in the history
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: #27400
Refs: #27391
Refs: #25835
Reviewed-By: Anna Henningsen <[email protected]>
Reviewed-By: Michaël Zasso <[email protected]>
  • Loading branch information
BridgeAR authored and targos committed Apr 30, 2019
1 parent c0ab2a1 commit 01d632d
Showing 1 changed file with 18 additions and 1 deletion.
19 changes: 18 additions & 1 deletion lib/internal/repl/await.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {
Expand Down Expand Up @@ -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;
}
Expand Down

0 comments on commit 01d632d

Please sign in to comment.