├── test
├── input
│ ├── empty.js
│ ├── this.js
│ ├── bigint-zero.js
│ ├── semicolon.js
│ ├── bigint.js
│ ├── named-empty.js
│ ├── expression-extra.js
│ ├── extra-semicolon.js
│ ├── leading-semicolon.js
│ ├── named-class.js
│ ├── simple-identifier.js
│ ├── this-as-name.js
│ ├── viewof-orphan.js
│ ├── anonymous-expression-cell.js
│ ├── binary-expression.js
│ ├── comment.js
│ ├── mutable-constant.js
│ ├── named-expression-cell.js
│ ├── object-literal.js
│ ├── sequence-expression.js
│ ├── var-statement.js
│ ├── bare-dynamic-import.js
│ ├── dynamic-import.js
│ ├── import-side-effect.js
│ ├── member-assignment.js
│ ├── viewof-member.js
│ ├── yield-expression-cell.js
│ ├── illegal-arguments.js
│ ├── import-default.js
│ ├── import-empty.js
│ ├── mutable-member.js
│ ├── mutable-reference.js
│ ├── spread-element.js
│ ├── template-literal-semicolon.js
│ ├── viewof-let.js
│ ├── viewof-member-expression.js
│ ├── viewof-property.js
│ ├── viewof-reference.js
│ ├── yield-star-expression-cell.js
│ ├── anonymous-block-cell.js
│ ├── anonymous-function.js
│ ├── await-block-cell.js
│ ├── global-assignment.js
│ ├── import.js
│ ├── mutable-as-property.js
│ ├── mutable-var.js
│ ├── named-function.js
│ ├── yield-block-cell.js
│ ├── comma-then-comment.js
│ ├── computed-property-name.js
│ ├── illegal-arrow-arguments.js
│ ├── import-duplicate.js
│ ├── import-mutable.js
│ ├── import-viewof.js
│ ├── mutable-destructure-array.js
│ ├── named-block-cell.js
│ ├── viewof-assignment.js
│ ├── viewof-binding.js
│ ├── viewof-expression-cell.js
│ ├── expression-trailing-comment.js
│ ├── file-attachment-forbidden.js
│ ├── import-default-as.js
│ ├── import-extra.js
│ ├── import-with-empty.js
│ ├── legal-arguments.js
│ ├── mutable-assignment.js
│ ├── mutable-internal-comment.js
│ ├── named-generator-function.js
│ ├── await-yield.js
│ ├── file-attachment-forbidden-1.js
│ ├── import-as-duplicate.js
│ ├── import-mutable-as.js
│ ├── import-semicolon.js
│ ├── import-viewof-as.js
│ ├── import-with.js
│ ├── named-async-function.js
│ ├── viewof-reference-internal-comment.js
│ ├── yield-await.js
│ ├── destructured-arrow-with-default.js
│ ├── import-with-duplicate.js
│ ├── named-function-in-named-cell.js
│ ├── viewof-argument.js
│ ├── viewof-block-cell.js
│ ├── viewof-internal-comment.js
│ ├── destructured-object-with-default.js
│ ├── import-with-default.js
│ ├── mutable-argument.js
│ ├── mutable-assign-default.js
│ ├── mutable-block-cell.js
│ ├── mutable-destructure-object.js
│ ├── await-in-arrow-function-expression.js
│ ├── block-trailing-comment.js
│ ├── import-with-as-duplicate.js
│ ├── import-with-default-as.js
│ ├── mutable-default-value.js
│ ├── mutable-destructure-property.js
│ ├── shadowed-view.js
│ ├── block-leading-comment.js
│ ├── yield-in-function.js
│ ├── await-in-function.js
│ ├── await-in-arrow-function.js
│ ├── for-await-generator.js
│ ├── await-in-class.js
│ ├── catch-clause.js
│ ├── for-await.js
│ ├── file-attachment.js
│ ├── multiple-input-references.js
│ ├── for-await-in-function.js
│ └── file-attachment-nested.js
├── parse-test.js
└── references-test.js
├── .eslintignore
├── .gitignore
├── src
├── index.js
├── walk.js
├── globals.js
├── file-attachments.js
├── references.js
└── parse.js
├── .eslintrc.json
├── parser.sublime-project
├── .github
└── workflows
│ └── nodejs.yml
├── LICENSE
├── rollup.config.js
├── package.json
├── README.md
└── tap-snapshots
└── test-parse-test.js-TAP.test.js
/test/input/empty.js:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/test/input/this.js:
--------------------------------------------------------------------------------
1 | this
2 |
--------------------------------------------------------------------------------
/test/input/bigint-zero.js:
--------------------------------------------------------------------------------
1 | 0n
2 |
--------------------------------------------------------------------------------
/test/input/semicolon.js:
--------------------------------------------------------------------------------
1 | ;
2 |
--------------------------------------------------------------------------------
/test/input/bigint.js:
--------------------------------------------------------------------------------
1 | foo + 42n
2 |
--------------------------------------------------------------------------------
/test/input/named-empty.js:
--------------------------------------------------------------------------------
1 | foo =
2 |
--------------------------------------------------------------------------------
/test/input/expression-extra.js:
--------------------------------------------------------------------------------
1 | foo bar
2 |
--------------------------------------------------------------------------------
/test/input/extra-semicolon.js:
--------------------------------------------------------------------------------
1 | foo = 42;
2 |
--------------------------------------------------------------------------------
/test/input/leading-semicolon.js:
--------------------------------------------------------------------------------
1 | ;42
2 |
--------------------------------------------------------------------------------
/test/input/named-class.js:
--------------------------------------------------------------------------------
1 | class Foo {}
2 |
--------------------------------------------------------------------------------
/test/input/simple-identifier.js:
--------------------------------------------------------------------------------
1 | foo
2 |
--------------------------------------------------------------------------------
/test/input/this-as-name.js:
--------------------------------------------------------------------------------
1 | this = 42
2 |
--------------------------------------------------------------------------------
/test/input/viewof-orphan.js:
--------------------------------------------------------------------------------
1 | viewof 42
2 |
--------------------------------------------------------------------------------
/test/input/anonymous-expression-cell.js:
--------------------------------------------------------------------------------
1 | 42
2 |
--------------------------------------------------------------------------------
/test/input/binary-expression.js:
--------------------------------------------------------------------------------
1 | foo + 42
2 |
--------------------------------------------------------------------------------
/test/input/comment.js:
--------------------------------------------------------------------------------
1 | // Hello, comment.
2 |
--------------------------------------------------------------------------------
/test/input/mutable-constant.js:
--------------------------------------------------------------------------------
1 | mutable 101
2 |
--------------------------------------------------------------------------------
/test/input/named-expression-cell.js:
--------------------------------------------------------------------------------
1 | foo = 42
2 |
--------------------------------------------------------------------------------
/test/input/object-literal.js:
--------------------------------------------------------------------------------
1 | ({foo: 42})
2 |
--------------------------------------------------------------------------------
/test/input/sequence-expression.js:
--------------------------------------------------------------------------------
1 | 1, 2, 3
2 |
--------------------------------------------------------------------------------
/test/input/var-statement.js:
--------------------------------------------------------------------------------
1 | var foo = 42
2 |
--------------------------------------------------------------------------------
/.eslintignore:
--------------------------------------------------------------------------------
1 | dist/
2 | test/
3 | tap-snapshots/
4 |
--------------------------------------------------------------------------------
/test/input/bare-dynamic-import.js:
--------------------------------------------------------------------------------
1 | import("bar")
2 |
--------------------------------------------------------------------------------
/test/input/dynamic-import.js:
--------------------------------------------------------------------------------
1 | foo = import("bar")
2 |
--------------------------------------------------------------------------------
/test/input/import-side-effect.js:
--------------------------------------------------------------------------------
1 | import "module"
2 |
--------------------------------------------------------------------------------
/test/input/member-assignment.js:
--------------------------------------------------------------------------------
1 | window.foo = 2
2 |
--------------------------------------------------------------------------------
/test/input/viewof-member.js:
--------------------------------------------------------------------------------
1 | object.viewof foo + 2
2 |
--------------------------------------------------------------------------------
/test/input/yield-expression-cell.js:
--------------------------------------------------------------------------------
1 | yield value
2 |
--------------------------------------------------------------------------------
/test/input/illegal-arguments.js:
--------------------------------------------------------------------------------
1 | 1 + arguments.length
2 |
--------------------------------------------------------------------------------
/test/input/import-default.js:
--------------------------------------------------------------------------------
1 | import foo from "module"
2 |
--------------------------------------------------------------------------------
/test/input/import-empty.js:
--------------------------------------------------------------------------------
1 | import {} from "module"
2 |
--------------------------------------------------------------------------------
/test/input/mutable-member.js:
--------------------------------------------------------------------------------
1 | object.mutable foo + 1
2 |
--------------------------------------------------------------------------------
/test/input/mutable-reference.js:
--------------------------------------------------------------------------------
1 | mutable value.property
2 |
--------------------------------------------------------------------------------
/test/input/spread-element.js:
--------------------------------------------------------------------------------
1 | ({foo, ...bar}) => bar
2 |
--------------------------------------------------------------------------------
/test/input/template-literal-semicolon.js:
--------------------------------------------------------------------------------
1 | html`hello`;
2 |
--------------------------------------------------------------------------------
/test/input/viewof-let.js:
--------------------------------------------------------------------------------
1 | {
2 | let viewof = 2;
3 | }
4 |
--------------------------------------------------------------------------------
/test/input/viewof-member-expression.js:
--------------------------------------------------------------------------------
1 | viewof foo.name
2 |
--------------------------------------------------------------------------------
/test/input/viewof-property.js:
--------------------------------------------------------------------------------
1 | object[viewof foo] + 2
2 |
--------------------------------------------------------------------------------
/test/input/viewof-reference.js:
--------------------------------------------------------------------------------
1 | viewof input.tagName
2 |
--------------------------------------------------------------------------------
/test/input/yield-star-expression-cell.js:
--------------------------------------------------------------------------------
1 | yield* values
2 |
--------------------------------------------------------------------------------
/test/input/anonymous-block-cell.js:
--------------------------------------------------------------------------------
1 | {
2 | return 42;
3 | }
4 |
--------------------------------------------------------------------------------
/test/input/anonymous-function.js:
--------------------------------------------------------------------------------
1 | function() { return 42; }
2 |
--------------------------------------------------------------------------------
/test/input/await-block-cell.js:
--------------------------------------------------------------------------------
1 | {
2 | await promise;
3 | }
4 |
--------------------------------------------------------------------------------
/test/input/global-assignment.js:
--------------------------------------------------------------------------------
1 | {
2 | foo = 42;
3 | }
4 |
--------------------------------------------------------------------------------
/test/input/import.js:
--------------------------------------------------------------------------------
1 | import {foo, bar as baz} from "module"
2 |
--------------------------------------------------------------------------------
/test/input/mutable-as-property.js:
--------------------------------------------------------------------------------
1 | object[mutable foo] + 1
2 |
--------------------------------------------------------------------------------
/test/input/mutable-var.js:
--------------------------------------------------------------------------------
1 | {
2 | var mutable = 2;
3 | }
4 |
--------------------------------------------------------------------------------
/test/input/named-function.js:
--------------------------------------------------------------------------------
1 | function foo() { return 42; }
2 |
--------------------------------------------------------------------------------
/test/input/yield-block-cell.js:
--------------------------------------------------------------------------------
1 | {
2 | yield value;
3 | }
4 |
--------------------------------------------------------------------------------
/test/input/comma-then-comment.js:
--------------------------------------------------------------------------------
1 | foo, // Oops, invalid syntax.
2 |
--------------------------------------------------------------------------------
/test/input/computed-property-name.js:
--------------------------------------------------------------------------------
1 | ({[field]: value}) => value
2 |
--------------------------------------------------------------------------------
/test/input/illegal-arrow-arguments.js:
--------------------------------------------------------------------------------
1 | () => arguments.length
2 |
--------------------------------------------------------------------------------
/test/input/import-duplicate.js:
--------------------------------------------------------------------------------
1 | import {foo, foo} from "module"
2 |
--------------------------------------------------------------------------------
/test/input/import-mutable.js:
--------------------------------------------------------------------------------
1 | import {mutable foo} from "module"
2 |
--------------------------------------------------------------------------------
/test/input/import-viewof.js:
--------------------------------------------------------------------------------
1 | import {viewof foo} from "module"
2 |
--------------------------------------------------------------------------------
/test/input/mutable-destructure-array.js:
--------------------------------------------------------------------------------
1 | ([mutable x] = [42])
2 |
--------------------------------------------------------------------------------
/test/input/named-block-cell.js:
--------------------------------------------------------------------------------
1 | foo = {
2 | return 42;
3 | }
4 |
--------------------------------------------------------------------------------
/test/input/viewof-assignment.js:
--------------------------------------------------------------------------------
1 | {
2 | viewof foo = 2;
3 | }
4 |
--------------------------------------------------------------------------------
/test/input/viewof-binding.js:
--------------------------------------------------------------------------------
1 | {
2 | let viewof foo = 2;
3 | }
4 |
--------------------------------------------------------------------------------
/test/input/viewof-expression-cell.js:
--------------------------------------------------------------------------------
1 | viewof foo = DOM.input()
2 |
--------------------------------------------------------------------------------
/test/input/expression-trailing-comment.js:
--------------------------------------------------------------------------------
1 | foo = 42 // Hello, comment.
2 |
--------------------------------------------------------------------------------
/test/input/file-attachment-forbidden.js:
--------------------------------------------------------------------------------
1 | x = FileAttachment("hi" + 1)
2 |
--------------------------------------------------------------------------------
/test/input/import-default-as.js:
--------------------------------------------------------------------------------
1 | import {default as foo} from "module"
2 |
--------------------------------------------------------------------------------
/test/input/import-extra.js:
--------------------------------------------------------------------------------
1 | import {foo, bar as baz} from "module" foo
2 |
--------------------------------------------------------------------------------
/test/input/import-with-empty.js:
--------------------------------------------------------------------------------
1 | import {foo} with {} from "module"
2 |
--------------------------------------------------------------------------------
/test/input/legal-arguments.js:
--------------------------------------------------------------------------------
1 | function() { return arguments.length; }
2 |
--------------------------------------------------------------------------------
/test/input/mutable-assignment.js:
--------------------------------------------------------------------------------
1 | {
2 | mutable value = 101;
3 | }
4 |
--------------------------------------------------------------------------------
/test/input/mutable-internal-comment.js:
--------------------------------------------------------------------------------
1 | mutable /* comment */ value
2 |
--------------------------------------------------------------------------------
/test/input/named-generator-function.js:
--------------------------------------------------------------------------------
1 | function* foo() { yield 42; }
2 |
--------------------------------------------------------------------------------
/test/input/await-yield.js:
--------------------------------------------------------------------------------
1 | {
2 | await promise;
3 | yield value;
4 | }
5 |
--------------------------------------------------------------------------------
/test/input/file-attachment-forbidden-1.js:
--------------------------------------------------------------------------------
1 | x = FileAttachment(`hi ${1}`)
2 |
--------------------------------------------------------------------------------
/test/input/import-as-duplicate.js:
--------------------------------------------------------------------------------
1 | import {foo, bar as foo} from "module"
2 |
--------------------------------------------------------------------------------
/test/input/import-mutable-as.js:
--------------------------------------------------------------------------------
1 | import {mutable foo as bar} from "module"
2 |
--------------------------------------------------------------------------------
/test/input/import-semicolon.js:
--------------------------------------------------------------------------------
1 | import {foo, bar as baz} from "module";
2 |
--------------------------------------------------------------------------------
/test/input/import-viewof-as.js:
--------------------------------------------------------------------------------
1 | import {viewof foo as bar} from "module"
2 |
--------------------------------------------------------------------------------
/test/input/import-with.js:
--------------------------------------------------------------------------------
1 | import {foo} with {bar as baz} from "module"
2 |
--------------------------------------------------------------------------------
/test/input/named-async-function.js:
--------------------------------------------------------------------------------
1 | async function foo() { await promise; }
2 |
--------------------------------------------------------------------------------
/test/input/viewof-reference-internal-comment.js:
--------------------------------------------------------------------------------
1 | viewof /* comment */ bar
2 |
--------------------------------------------------------------------------------
/test/input/yield-await.js:
--------------------------------------------------------------------------------
1 | {
2 | yield value;
3 | await promise;
4 | }
5 |
--------------------------------------------------------------------------------
/test/input/destructured-arrow-with-default.js:
--------------------------------------------------------------------------------
1 | fun = ({foo = "default"}) => {}
2 |
--------------------------------------------------------------------------------
/test/input/import-with-duplicate.js:
--------------------------------------------------------------------------------
1 | import {} with {foo, foo} from "module"
2 |
--------------------------------------------------------------------------------
/test/input/named-function-in-named-cell.js:
--------------------------------------------------------------------------------
1 | foo = function bar() { return 42; }
2 |
--------------------------------------------------------------------------------
/test/input/viewof-argument.js:
--------------------------------------------------------------------------------
1 | function foo(viewof) {
2 | return viewof;
3 | }
4 |
--------------------------------------------------------------------------------
/test/input/viewof-block-cell.js:
--------------------------------------------------------------------------------
1 | viewof foo = {
2 | return DOM.input();
3 | }
4 |
--------------------------------------------------------------------------------
/test/input/viewof-internal-comment.js:
--------------------------------------------------------------------------------
1 | viewof /* comment */ bar = DOM.range()
2 |
--------------------------------------------------------------------------------
/test/input/destructured-object-with-default.js:
--------------------------------------------------------------------------------
1 | function fun({foo = "default"}) {}
2 |
--------------------------------------------------------------------------------
/test/input/import-with-default.js:
--------------------------------------------------------------------------------
1 | import {foo} with {default as baz} from "module"
2 |
--------------------------------------------------------------------------------
/test/input/mutable-argument.js:
--------------------------------------------------------------------------------
1 | function fn(mutable) {
2 | return mutable;
3 | }
4 |
--------------------------------------------------------------------------------
/test/input/mutable-assign-default.js:
--------------------------------------------------------------------------------
1 | mutable state = await Service.fetch(config)
2 |
--------------------------------------------------------------------------------
/test/input/mutable-block-cell.js:
--------------------------------------------------------------------------------
1 | mutable foo = {
2 | return {x: 0, y: 0};
3 | }
4 |
--------------------------------------------------------------------------------
/test/input/mutable-destructure-object.js:
--------------------------------------------------------------------------------
1 | ({property: mutable x} = {property: value})
2 |
--------------------------------------------------------------------------------
/test/input/await-in-arrow-function-expression.js:
--------------------------------------------------------------------------------
1 | async () => {
2 | await promise;
3 | }
4 |
--------------------------------------------------------------------------------
/test/input/block-trailing-comment.js:
--------------------------------------------------------------------------------
1 | foo = {
2 | return 42;
3 | } // Hello, comment.
4 |
--------------------------------------------------------------------------------
/test/input/import-with-as-duplicate.js:
--------------------------------------------------------------------------------
1 | import {} with {foo, bar as foo} from "module"
2 |
--------------------------------------------------------------------------------
/test/input/import-with-default-as.js:
--------------------------------------------------------------------------------
1 | import {foo} with {baz as default} from "module"
2 |
--------------------------------------------------------------------------------
/test/input/mutable-default-value.js:
--------------------------------------------------------------------------------
1 | function fn(y = mutable x) {
2 | return y;
3 | }
4 |
--------------------------------------------------------------------------------
/test/input/mutable-destructure-property.js:
--------------------------------------------------------------------------------
1 | ({mutable property} = {mutable property: 42})
2 |
--------------------------------------------------------------------------------
/test/input/shadowed-view.js:
--------------------------------------------------------------------------------
1 | {
2 | let x = 2;
3 | x = 4;
4 | return viewof x;
5 | }
6 |
--------------------------------------------------------------------------------
/test/input/block-leading-comment.js:
--------------------------------------------------------------------------------
1 | // Hello, comment.
2 | foo = {
3 | return 42;
4 | }
5 |
--------------------------------------------------------------------------------
/test/input/yield-in-function.js:
--------------------------------------------------------------------------------
1 | {
2 | function* inner() {
3 | yield value;
4 | }
5 | }
6 |
--------------------------------------------------------------------------------
/test/input/await-in-function.js:
--------------------------------------------------------------------------------
1 | {
2 | async function inner() {
3 | await promise;
4 | }
5 | }
6 |
--------------------------------------------------------------------------------
/test/input/await-in-arrow-function.js:
--------------------------------------------------------------------------------
1 | {
2 | const inner = async () => {
3 | await promise;
4 | };
5 | }
6 |
--------------------------------------------------------------------------------
/test/input/for-await-generator.js:
--------------------------------------------------------------------------------
1 | {
2 | for await (const value of foo()) {
3 | yield value;
4 | }
5 | }
6 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | *.sublime-workspace
2 | .DS_Store
3 | .nyc_output
4 | dist/
5 | node_modules
6 | npm-debug.log
7 | .idea
8 |
--------------------------------------------------------------------------------
/test/input/await-in-class.js:
--------------------------------------------------------------------------------
1 | {
2 | class Inner {
3 | async method() {
4 | await promise;
5 | }
6 | }
7 | }
8 |
--------------------------------------------------------------------------------
/src/index.js:
--------------------------------------------------------------------------------
1 | export {parseCell, peekId, CellParser, parseModule, ModuleParser} from "./parse.js";
2 | export {default as walk} from "./walk.js";
3 |
--------------------------------------------------------------------------------
/test/input/catch-clause.js:
--------------------------------------------------------------------------------
1 | {
2 | try {
3 | let [x] = y;
4 | x++;
5 | return x;
6 | } catch (e) {
7 | return e;
8 | }
9 | }
10 |
--------------------------------------------------------------------------------
/test/input/for-await.js:
--------------------------------------------------------------------------------
1 | {
2 | const values = [];
3 | for await (const value of foo()) {
4 | values.push(value);
5 | }
6 | return values;
7 | }
8 |
--------------------------------------------------------------------------------
/test/input/file-attachment.js:
--------------------------------------------------------------------------------
1 | {
2 | let a = FileAttachment("a");
3 | let b = FileAttachment('b');
4 | let c = FileAttachment(`c`);
5 | let c2 = FileAttachment("c");
6 | }
7 |
--------------------------------------------------------------------------------
/test/input/multiple-input-references.js:
--------------------------------------------------------------------------------
1 | cell = {
2 | const sum = a + b;
3 | const product = a * b;
4 | const difference = a - b;
5 | return {sum, product, difference};
6 | }
7 |
--------------------------------------------------------------------------------
/test/input/for-await-in-function.js:
--------------------------------------------------------------------------------
1 | async function bar() {
2 | const values = [];
3 | for await (const value of foo()) {
4 | values.push(value);
5 | }
6 | return values;
7 | }
8 |
--------------------------------------------------------------------------------
/src/walk.js:
--------------------------------------------------------------------------------
1 | import {make} from "acorn-walk";
2 |
3 | export default make({
4 | Import() {},
5 | ViewExpression(node, st, c) {
6 | c(node.id, st, "Identifier");
7 | },
8 | MutableExpression(node, st, c) {
9 | c(node.id, st, "Identifier");
10 | }
11 | });
12 |
--------------------------------------------------------------------------------
/test/input/file-attachment-nested.js:
--------------------------------------------------------------------------------
1 | viewof slider = {
2 | while (count > 0) {
3 | let b, c;
4 | const a = FileAttachment("a");
5 | if (condition) {
6 | b = defaultFile ? defaultFileValue : FileAttachment('b');
7 | c = FileAttachment(`c`);
8 | }
9 | }
10 | return input(a, b, c);
11 | }
12 |
--------------------------------------------------------------------------------
/.eslintrc.json:
--------------------------------------------------------------------------------
1 | {
2 | "extends": "eslint:recommended",
3 | "parserOptions": {
4 | "sourceType": "module",
5 | "ecmaVersion": 2018
6 | },
7 | "env": {
8 | "es6": true,
9 | "node": true
10 | },
11 | "rules": {
12 | "semi": 2,
13 | "no-cond-assign": 0,
14 | "no-process-env": 2,
15 | "no-var": 2,
16 | "quotes": ["error", "double", {"allowTemplateLiterals": true}]
17 | }
18 | }
19 |
--------------------------------------------------------------------------------
/parser.sublime-project:
--------------------------------------------------------------------------------
1 | {
2 | "folders": [
3 | {
4 | "path": ".",
5 | "file_exclude_patterns": [
6 | "*.sublime-workspace",
7 | "yarn.lock"
8 | ],
9 | "folder_exclude_patterns": [
10 | ".esm-cache"
11 | ]
12 | }
13 | ],
14 | "build_systems": [
15 | {
16 | "name": "yarn test",
17 | "cmd": ["yarn", "test"],
18 | "file_regex": "\\((...*?):([0-9]*):([0-9]*)\\)",
19 | "working_dir": "$project_path"
20 | }
21 | ]
22 | }
23 |
--------------------------------------------------------------------------------
/.github/workflows/nodejs.yml:
--------------------------------------------------------------------------------
1 | name: Node CI
2 |
3 | on: [push]
4 |
5 | jobs:
6 | build:
7 |
8 | strategy:
9 | matrix:
10 | os: [ubuntu-latest]
11 | node-version: [10.x, 12.x]
12 |
13 | runs-on: ${{ matrix.os }}
14 |
15 | steps:
16 | - uses: actions/checkout@v1
17 | - name: Use Node.js ${{ matrix.node-version }}
18 | uses: actions/setup-node@v1
19 | with:
20 | node-version: ${{ matrix.node-version }}
21 | - name: yarn install and test
22 | run: |
23 | yarn install --frozen-lockfile
24 | yarn test
25 | env:
26 | CI: true
27 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | Copyright 2018 Observable, Inc.
2 |
3 | Permission to use, copy, modify, and/or distribute this software for any purpose
4 | with or without fee is hereby granted, provided that the above copyright notice
5 | and this permission notice appear in all copies.
6 |
7 | THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
8 | REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
9 | FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
10 | INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS
11 | OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
12 | TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF
13 | THIS SOFTWARE.
14 |
--------------------------------------------------------------------------------
/rollup.config.js:
--------------------------------------------------------------------------------
1 | import commonjs from "rollup-plugin-commonjs";
2 | import node from "rollup-plugin-node-resolve";
3 | import {terser} from "rollup-plugin-terser";
4 | import * as meta from "./package.json";
5 |
6 | const copyright = `// @observablehq/parser v${meta.version} Copyright ${(new Date).getFullYear()} Observable, Inc.`;
7 |
8 | export default [
9 | {
10 | input: "src/index.js",
11 | plugins: [
12 | node(),
13 | commonjs(),
14 | terser({
15 | output: {preamble: copyright},
16 | mangle: {reserved: ["RequireError"]}
17 | })
18 | ],
19 | external: [
20 | "acorn",
21 | "acorn-walk"
22 | ],
23 | output: {
24 | globals: {
25 | "acorn": "acorn",
26 | "acorn-walk": "acorn.walk"
27 | },
28 | format: "umd",
29 | extend: true,
30 | name: "observablehq",
31 | file: "dist/parser.min.js"
32 | }
33 | }
34 | ];
35 |
--------------------------------------------------------------------------------
/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "@observablehq/parser",
3 | "version": "4.0.1",
4 | "license": "ISC",
5 | "main": "dist/parser.min.js",
6 | "module": "src/index.js",
7 | "author": {
8 | "name": "Observable, Inc.",
9 | "url": "https://observablehq.com"
10 | },
11 | "repository": {
12 | "type": "git",
13 | "url": "https://github.com/observablehq/parser.git"
14 | },
15 | "scripts": {
16 | "test": "eslint . && tap 'test/**/*-test.js'",
17 | "prepublishOnly": "rm -rf dist && rollup -c",
18 | "postpublish": "git push && git push --tags"
19 | },
20 | "husky": {
21 | "hooks": {
22 | "pre-commit": "yarn test"
23 | }
24 | },
25 | "dependencies": {
26 | "acorn": "^7.1.1",
27 | "acorn-walk": "^7.0.0"
28 | },
29 | "devDependencies": {
30 | "eslint": "^6.7.2",
31 | "esm": "^3.0.84",
32 | "rollup": "^1.27.8",
33 | "rollup-plugin-commonjs": "^10.1.0",
34 | "rollup-plugin-node-resolve": "^5.0.0",
35 | "rollup-plugin-terser": "^5.2.0",
36 | "tap": "^14.10.2",
37 | "husky": "^3.1.0"
38 | },
39 | "files": [
40 | "dist/**/*.js",
41 | "src/**/*.js"
42 | ]
43 | }
44 |
--------------------------------------------------------------------------------
/src/globals.js:
--------------------------------------------------------------------------------
1 | export default new Set([
2 | "Array",
3 | "ArrayBuffer",
4 | "atob",
5 | "AudioContext",
6 | "Blob",
7 | "Boolean",
8 | "BigInt",
9 | "btoa",
10 | "clearInterval",
11 | "clearTimeout",
12 | "console",
13 | "crypto",
14 | "CustomEvent",
15 | "DataView",
16 | "Date",
17 | "decodeURI",
18 | "decodeURIComponent",
19 | "devicePixelRatio",
20 | "document",
21 | "encodeURI",
22 | "encodeURIComponent",
23 | "Error",
24 | "escape",
25 | "eval",
26 | "fetch",
27 | "File",
28 | "FileList",
29 | "FileReader",
30 | "Float32Array",
31 | "Float64Array",
32 | "Function",
33 | "Headers",
34 | "Image",
35 | "ImageData",
36 | "Infinity",
37 | "Int16Array",
38 | "Int32Array",
39 | "Int8Array",
40 | "Intl",
41 | "isFinite",
42 | "isNaN",
43 | "JSON",
44 | "Map",
45 | "Math",
46 | "NaN",
47 | "Number",
48 | "navigator",
49 | "Object",
50 | "parseFloat",
51 | "parseInt",
52 | "performance",
53 | "Path2D",
54 | "Promise",
55 | "Proxy",
56 | "RangeError",
57 | "ReferenceError",
58 | "Reflect",
59 | "RegExp",
60 | "cancelAnimationFrame",
61 | "requestAnimationFrame",
62 | "Set",
63 | "setInterval",
64 | "setTimeout",
65 | "String",
66 | "Symbol",
67 | "SyntaxError",
68 | "TextDecoder",
69 | "TextEncoder",
70 | "this",
71 | "TypeError",
72 | "Uint16Array",
73 | "Uint32Array",
74 | "Uint8Array",
75 | "Uint8ClampedArray",
76 | "undefined",
77 | "unescape",
78 | "URIError",
79 | "URL",
80 | "WeakMap",
81 | "WeakSet",
82 | "WebSocket",
83 | "Worker",
84 | "window"
85 | ]);
86 |
--------------------------------------------------------------------------------
/src/file-attachments.js:
--------------------------------------------------------------------------------
1 | import {simple} from "acorn-walk";
2 | import walk from "./walk.js";
3 |
4 | export default function findFileAttachments(cell) {
5 | const ast = {type: "Program", body: [cell.body]};
6 | const references = new Map();
7 |
8 | simple(
9 | ast,
10 | {
11 | CallExpression: node => {
12 | const {callee, arguments: args} = node;
13 |
14 | // Ignore function calls that are not references to FileAttachment
15 | if (!(callee.type === "Identifier" && callee.name === "FileAttachment")) return;
16 |
17 | // Forbid all sorts of dynamic uses of FileAttachment
18 | if (
19 | !(
20 | args.length === 1 &&
21 | ((args[0].type === "Literal" && /^['"]/.test(args[0].raw)) ||
22 | (args[0].type === "TemplateLiteral" &&
23 | args[0].expressions.length === 0))
24 | )
25 | ) {
26 | throw Object.assign(
27 | new SyntaxError(
28 | `FileAttachment() requires a single literal string as its argument.`
29 | ),
30 | {node}
31 | );
32 | }
33 |
34 | const fileReference =
35 | args[0].type === "Literal" ? args[0].value : args[0].quasis[0].value.cooked;
36 | const fileLocation = {start: args[0].start, end: args[0].end};
37 |
38 | if (references.has(fileReference)) {
39 | references.get(fileReference).push(fileLocation);
40 | } else {
41 | references.set(fileReference, [fileLocation]);
42 | }
43 | }
44 | },
45 | walk
46 | );
47 |
48 | return references;
49 | }
50 |
--------------------------------------------------------------------------------
/test/parse-test.js:
--------------------------------------------------------------------------------
1 | import {simple} from "acorn-walk";
2 | import {test} from "tap";
3 | import {readdirSync, readFileSync, writeFileSync} from "fs";
4 | import {basename, extname, join} from "path";
5 | import {parseCell, peekId, parseModule} from "../src/index.js";
6 | import walk from "../src/walk.js";
7 |
8 | test("peekId", t => {
9 | t.equal(peekId("a = 1"), "a");
10 | t.equal(peekId("viewof a = 1"), "a");
11 | t.equal(peekId("mutable a = 1"), "a");
12 | t.equal(peekId("mutable async = 1"), "async");
13 | t.equal(peekId("class A {"), "A");
14 | t.equal(peekId("class Z"), undefined);
15 | t.equal(peekId("class Z "), "Z");
16 | t.equal(peekId("function a"), undefined);
17 | t.equal(peekId("function a()"), "a");
18 | t.equal(peekId("async function a()"), "a");
19 | t.equal(peekId("function* a"), undefined);
20 | t.equal(peekId("function /* yeah */ a()"), "a");
21 | t.equal(peekId("function"), undefined);
22 | t.equal(peekId("1"), undefined);
23 | t.equal(peekId("#"), undefined, "Ignores syntax errors");
24 | t.equal(peekId("abc /"), undefined, "Needs a = for a name to be identified");
25 | t.equal(peekId("({ a: 1 })"), undefined);
26 | t.equal(
27 | peekId(`function queryAll(text, values) {
28 | return fetch("https://api.observable.localh`),
29 | "queryAll"
30 | );
31 | t.end();
32 | });
33 |
34 | test("parseModule", t => {
35 | t.matchSnapshot(
36 | parseModule(`a = 1;
37 |
38 | b = 2;
39 |
40 | c = a + b`)
41 | );
42 | t.end();
43 | });
44 |
45 | readdirSync(join("test", "input")).forEach(file => {
46 | if (extname(file) !== ".js") return;
47 | test(`parse ${file}`, test => {
48 | const infile = join("test", "input", file);
49 | const outfile = join("test", "output", basename(file, ".js") + ".json");
50 | let actual, expected;
51 |
52 | try {
53 | actual = parseCell(readFileSync(infile, "utf8"), {globals: null});
54 | } catch (error) {
55 | if (
56 | error instanceof ReferenceError ||
57 | error instanceof SyntaxError ||
58 | error instanceof TypeError
59 | ) {
60 | actual = {
61 | error: {
62 | type: error.constructor.name,
63 | message: error.message,
64 | pos: error.pos,
65 | loc: {
66 | line: error.loc.line,
67 | column: error.loc.column
68 | }
69 | }
70 | };
71 | } else {
72 | throw error;
73 | }
74 | }
75 |
76 | // Treat BigInt as Number for test purposes.
77 | if (actual.body) {
78 | simple(
79 | actual.body,
80 | {
81 | Literal(node) {
82 | if (node.bigint) {
83 | node.value = Number(node.value);
84 | }
85 | }
86 | },
87 | walk
88 | );
89 | }
90 |
91 | test.matchSnapshot(actual);
92 | test.end();
93 | });
94 | });
95 |
--------------------------------------------------------------------------------
/test/references-test.js:
--------------------------------------------------------------------------------
1 | import {test} from "tap";
2 | import {parseCell} from "../src/index.js";
3 |
4 | test("finds references in expressions", t => {
5 | t.deepEqual(parseCell(`foo + bar`).references, [
6 | {type: "Identifier", start: 0, end: 3, name: "foo"},
7 | {type: "Identifier", start: 6, end: 9, name: "bar"}
8 | ]);
9 | t.end();
10 | });
11 |
12 | test("finds references in blocks", t => {
13 | t.deepEqual(parseCell(`{ foo + bar; }`).references, [
14 | {type: "Identifier", start: 2, end: 5, name: "foo"},
15 | {type: "Identifier", start: 8, end: 11, name: "bar"}
16 | ]);
17 | t.end();
18 | });
19 |
20 | test("finds viewof references", t => {
21 | t.deepEqual(parseCell(`viewof foo + bar`).references, [
22 | {
23 | type: "ViewExpression",
24 | start: 0,
25 | end: 10,
26 | id: {type: "Identifier", start: 7, end: 10, name: "foo"}
27 | },
28 | {type: "Identifier", start: 13, end: 16, name: "bar"}
29 | ]);
30 | t.end();
31 | });
32 |
33 | test("finds mutable references", t => {
34 | t.deepEqual(parseCell(`mutable foo + bar`).references, [
35 | {
36 | type: "MutableExpression",
37 | start: 0,
38 | end: 11,
39 | id: {type: "Identifier", start: 8, end: 11, name: "foo"}
40 | },
41 | {type: "Identifier", start: 14, end: 17, name: "bar"}
42 | ]);
43 | t.end();
44 | });
45 |
46 | test("finds multiple references", t => {
47 | t.deepEqual(parseCell(`cell = {
48 | const a = b + c;
49 | const d = c - b;
50 | }`).references, [
51 | {type: "Identifier", start: 21, end: 22, name: "b"},
52 | {type: "Identifier", start: 25, end: 26, name: "c"},
53 | {type: "Identifier", start: 40, end: 41, name: "c"},
54 | {type: "Identifier", start: 44, end: 45, name: "b"}
55 | ]);
56 | t.end();
57 | });
58 |
59 | test("doesn’t consider the identifier a reference", t => {
60 | t.deepEqual(parseCell(`foo = bar`).references, [
61 | {type: "Identifier", start: 6, end: 9, name: "bar"}
62 | ]);
63 | t.end();
64 | });
65 |
66 | test("local variables can mask references", t => {
67 | t.deepEqual(parseCell(`{ let foo; foo + bar; }`).references, [
68 | {type: "Identifier", start: 17, end: 20, name: "bar"}
69 | ]);
70 | t.end();
71 | });
72 |
73 | test("local variables can not mask references", t => {
74 | t.deepEqual(parseCell(`{ foo + bar; { let foo; } }`).references, [
75 | {type: "Identifier", start: 2, end: 5, name: "foo"},
76 | {type: "Identifier", start: 8, end: 11, name: "bar"}
77 | ]);
78 | t.end();
79 | });
80 |
81 | test("function parameters can mask references", t => {
82 | t.deepEqual(parseCell(`foo => foo + bar`).references, [
83 | {type: "Identifier", start: 13, end: 16, name: "bar"}
84 | ]);
85 | t.end();
86 | });
87 |
88 | test("function rest parameters can mask references", t => {
89 | t.deepEqual(parseCell(`(...foo) => foo + bar`).references, [
90 | {type: "Identifier", start: 18, end: 21, name: "bar"}
91 | ]);
92 | t.end();
93 | });
94 |
95 | test("destructured variables can mask references", t => {
96 | t.deepEqual(parseCell(`{ let {foo} = null; foo + bar; }`).references, [
97 | {type: "Identifier", start: 26, end: 29, name: "bar"}
98 | ]);
99 | t.end();
100 | });
101 |
102 | test("destructured rest variables can mask references", t => {
103 | t.deepEqual(parseCell(`{ let {...foo} = null; foo + bar; }`).references, [
104 | {type: "Identifier", start: 29, end: 32, name: "bar"}
105 | ]);
106 | t.end();
107 | });
108 |
109 | test("ignores globals", t => {
110 | t.deepEqual(parseCell(`foo + bar`, {globals: ["foo"]}).references, [
111 | {type: "Identifier", start: 6, end: 9, name: "bar"}
112 | ]);
113 | t.end();
114 | });
115 |
--------------------------------------------------------------------------------
/src/references.js:
--------------------------------------------------------------------------------
1 | // Base on https://github.com/ForbesLindesay/acorn-globals
2 | // Copyright (c) 2014 Forbes Lindesay
3 | // https://github.com/ForbesLindesay/acorn-globals/blob/master/LICENSE
4 |
5 | import {ancestor} from "acorn-walk";
6 | import walk from "./walk.js";
7 |
8 | function isScope(node) {
9 | return node.type === "FunctionExpression"
10 | || node.type === "FunctionDeclaration"
11 | || node.type === "ArrowFunctionExpression"
12 | || node.type === "Program";
13 | }
14 |
15 | function isBlockScope(node) {
16 | return node.type === "BlockStatement"
17 | || node.type === "ForInStatement"
18 | || node.type === "ForOfStatement"
19 | || node.type === "ForStatement"
20 | || isScope(node);
21 | }
22 |
23 | function declaresArguments(node) {
24 | return node.type === "FunctionExpression"
25 | || node.type === "FunctionDeclaration";
26 | }
27 |
28 | export default function findReferences(cell, globals) {
29 | const ast = {type: "Program", body: [cell.body]};
30 | const locals = new Map;
31 | const globalSet = new Set(globals);
32 | const references = [];
33 |
34 | function hasLocal(node, name) {
35 | const l = locals.get(node);
36 | return l ? l.has(name) : false;
37 | }
38 |
39 | function declareLocal(node, id) {
40 | const l = locals.get(node);
41 | if (l) l.add(id.name);
42 | else locals.set(node, new Set([id.name]));
43 | }
44 |
45 | function declareClass(node) {
46 | if (node.id) declareLocal(node, node.id);
47 | }
48 |
49 | function declareFunction(node) {
50 | node.params.forEach(param => declarePattern(param, node));
51 | if (node.id) declareLocal(node, node.id);
52 | }
53 |
54 | function declareCatchClause(node) {
55 | if (node.param) declarePattern(node.param, node);
56 | }
57 |
58 | function declarePattern(node, parent) {
59 | switch (node.type) {
60 | case "Identifier":
61 | declareLocal(parent, node);
62 | break;
63 | case "ObjectPattern":
64 | node.properties.forEach(node => declarePattern(node, parent));
65 | break;
66 | case "ArrayPattern":
67 | node.elements.forEach(node => node && declarePattern(node, parent));
68 | break;
69 | case "Property":
70 | declarePattern(node.value, parent);
71 | break;
72 | case "RestElement":
73 | declarePattern(node.argument, parent);
74 | break;
75 | case "AssignmentPattern":
76 | declarePattern(node.left, parent);
77 | break;
78 | default:
79 | throw new Error("Unrecognized pattern type: " + node.type);
80 | }
81 | }
82 |
83 | function declareModuleSpecifier(node) {
84 | declareLocal(ast, node.local);
85 | }
86 |
87 | ancestor(
88 | ast,
89 | {
90 | VariableDeclaration: (node, parents) => {
91 | let parent = null;
92 | for (let i = parents.length - 1; i >= 0 && parent === null; --i) {
93 | if (node.kind === "var" ? isScope(parents[i]) : isBlockScope(parents[i])) {
94 | parent = parents[i];
95 | }
96 | }
97 | node.declarations.forEach(declaration => declarePattern(declaration.id, parent));
98 | },
99 | FunctionDeclaration: (node, parents) => {
100 | let parent = null;
101 | for (let i = parents.length - 2; i >= 0 && parent === null; --i) {
102 | if (isScope(parents[i])) {
103 | parent = parents[i];
104 | }
105 | }
106 | declareLocal(parent, node.id);
107 | declareFunction(node);
108 | },
109 | Function: declareFunction,
110 | ClassDeclaration: (node, parents) => {
111 | let parent = null;
112 | for (let i = parents.length - 2; i >= 0 && parent === null; i--) {
113 | if (isScope(parents[i])) {
114 | parent = parents[i];
115 | }
116 | }
117 | declareLocal(parent, node.id);
118 | },
119 | Class: declareClass,
120 | CatchClause: declareCatchClause,
121 | ImportDefaultSpecifier: declareModuleSpecifier,
122 | ImportSpecifier: declareModuleSpecifier,
123 | ImportNamespaceSpecifier: declareModuleSpecifier
124 | },
125 | walk
126 | );
127 |
128 | function identifier(node, parents) {
129 | let name = node.name;
130 | if (name === "undefined") return;
131 | for (let i = parents.length - 2; i >= 0; --i) {
132 | if (name === "arguments") {
133 | if (declaresArguments(parents[i])) {
134 | return;
135 | }
136 | }
137 | if (hasLocal(parents[i], name)) {
138 | return;
139 | }
140 | if (parents[i].type === "ViewExpression") {
141 | node = parents[i];
142 | name = `viewof ${node.id.name}`;
143 | }
144 | if (parents[i].type === "MutableExpression") {
145 | node = parents[i];
146 | name = `mutable ${node.id.name}`;
147 | }
148 | }
149 | if (!globalSet.has(name)) {
150 | if (name === "arguments") {
151 | throw Object.assign(new SyntaxError(`arguments is not allowed`), {node});
152 | }
153 | references.push(node);
154 | }
155 | }
156 |
157 | ancestor(
158 | ast,
159 | {
160 | VariablePattern: identifier,
161 | Identifier: identifier
162 | },
163 | walk
164 | );
165 |
166 | function checkConst(node, parents) {
167 | switch (node.type) {
168 | case "Identifier":
169 | case "VariablePattern": {
170 | identifier(node, parents);
171 | break;
172 | }
173 | case "ArrayPattern":
174 | case "ObjectPattern": {
175 | ancestor(
176 | node,
177 | {
178 | Identifier: identifier,
179 | VariablePattern: identifier
180 | },
181 | walk
182 | );
183 | break;
184 | }
185 | }
186 | function identifier(node, nodeParents) {
187 | for (const parent of parents) {
188 | if (hasLocal(parent, node.name)) {
189 | return;
190 | }
191 | }
192 | if (nodeParents[nodeParents.length - 2].type === "MutableExpression") {
193 | return;
194 | }
195 | throw Object.assign(new SyntaxError(`Assignment to constant variable ${node.name}`), {node});
196 | }
197 | }
198 |
199 | function checkConstArgument(node, parents) {
200 | checkConst(node.argument, parents);
201 | }
202 |
203 | function checkConstLeft(node, parents) {
204 | checkConst(node.left, parents);
205 | }
206 |
207 | ancestor(
208 | ast,
209 | {
210 | AssignmentExpression: checkConstLeft,
211 | UpdateExpression: checkConstArgument,
212 | ForOfStatement: checkConstLeft,
213 | ForInStatement: checkConstLeft
214 | },
215 | walk
216 | );
217 |
218 | return references;
219 | }
220 |
--------------------------------------------------------------------------------
/src/parse.js:
--------------------------------------------------------------------------------
1 | import {getLineInfo, tokTypes as tt, Parser} from "acorn";
2 | import defaultGlobals from "./globals.js";
3 | import findReferences from "./references.js";
4 | import findFileAttachments from "./file-attachments.js";
5 |
6 | const SCOPE_FUNCTION = 2;
7 | const SCOPE_ASYNC = 4;
8 | const SCOPE_GENERATOR = 8;
9 |
10 | const STATE_START = Symbol("start");
11 | const STATE_MODIFIER = Symbol("modifier");
12 | const STATE_FUNCTION = Symbol("function");
13 | const STATE_NAME = Symbol("name");
14 |
15 | export function parseCell(input, {globals} = {}) {
16 | return parseFileAttachments(parseReferences(CellParser.parse(input), input, globals));
17 | }
18 |
19 | /*
20 | ┌─────┐
21 | ┌───────────│START│─function|class
22 | │ └─────┘ │
23 | viewof|mutable|async │ ▼
24 | │ │ ┌────────┐ ┌─┐
25 | ▼ │ │FUNCTION│◀───▶│*│
26 | ┌────────┐ │ └────────┘ └─┘
27 | │MODIFIER│ │ │
28 | └────────┘ name name
29 | │ │ │
30 | └──name─┐ │ ▼
31 | ▼ │ ┌─────────────┐
32 | ┌────────┐ │ │FUNCTION_NAME│
33 | │ NAME │◀─┘ └─────────────┘
34 | └────────┘
35 | │
36 | =
37 | ▼
38 | ┌────────┐
39 | │ EQ │
40 | └────────┘
41 | */
42 |
43 | export function peekId(input) {
44 | let state = STATE_START;
45 | let name;
46 | try {
47 | for (const token of Parser.tokenizer(input, {ecmaVersion: 11})) {
48 | switch (state) {
49 | case STATE_START:
50 | case STATE_MODIFIER: {
51 | if (token.type === tt.name) {
52 | if (
53 | state === STATE_START &&
54 | (token.value === "viewof" ||
55 | token.value === "mutable" ||
56 | token.value === "async")
57 | ) {
58 | state = STATE_MODIFIER;
59 | continue;
60 | }
61 | state = STATE_NAME;
62 | name = token;
63 | continue;
64 | }
65 | if (token.type === tt._function || token.type === tt._class) {
66 | state = STATE_FUNCTION;
67 | continue;
68 | }
69 | break;
70 | }
71 | case STATE_NAME: {
72 | if (token.type === tt.eq) return name.value;
73 | break;
74 | }
75 | case STATE_FUNCTION: {
76 | if (token.type === tt.star) continue;
77 | if (token.type === tt.name && token.end < input.length)
78 | return token.value;
79 | break;
80 | }
81 | }
82 | return;
83 | }
84 | } catch (ignore) {
85 | return;
86 | }
87 | }
88 |
89 | export class CellParser extends Parser {
90 | constructor(options, ...args) {
91 | super(Object.assign({ecmaVersion: 11}, options), ...args);
92 | }
93 | enterScope(flags) {
94 | if (flags & SCOPE_FUNCTION) ++this.O_function;
95 | return super.enterScope(flags);
96 | }
97 | exitScope() {
98 | if (this.currentScope().flags & SCOPE_FUNCTION) --this.O_function;
99 | return super.exitScope();
100 | }
101 | parseForIn(node, init) {
102 | if (this.O_function === 1 && node.await) this.O_async = true;
103 | return super.parseForIn(node, init);
104 | }
105 | parseAwait() {
106 | if (this.O_function === 1) this.O_async = true;
107 | return super.parseAwait();
108 | }
109 | parseYield(noIn) {
110 | if (this.O_function === 1) this.O_generator = true;
111 | return super.parseYield(noIn);
112 | }
113 | parseImport(node) {
114 | this.next();
115 | node.specifiers = this.parseImportSpecifiers();
116 | if (this.type === tt._with) {
117 | this.next();
118 | node.injections = this.parseImportSpecifiers();
119 | }
120 | this.expectContextual("from");
121 | node.source = this.type === tt.string ? this.parseExprAtom() : this.unexpected();
122 | return this.finishNode(node, "ImportDeclaration");
123 | }
124 | parseImportSpecifiers() {
125 | const nodes = [];
126 | const identifiers = new Set;
127 | let first = true;
128 | this.expect(tt.braceL);
129 | while (!this.eat(tt.braceR)) {
130 | if (first) {
131 | first = false;
132 | } else {
133 | this.expect(tt.comma);
134 | if (this.afterTrailingComma(tt.braceR)) break;
135 | }
136 | const node = this.startNode();
137 | node.view = this.eatContextual("viewof");
138 | if (!node.view) node.mutable = this.eatContextual("mutable");
139 | node.imported = this.parseIdent();
140 | if (this.eatContextual("as")) {
141 | node.local = this.parseIdent();
142 | } else {
143 | this.checkUnreserved(node.imported);
144 | node.local = node.imported;
145 | }
146 | this.checkLVal(node.local, "let");
147 | if (identifiers.has(node.local.name)) {
148 | this.raise(node.local.start, `Identifier '${node.local.name}' has already been declared`);
149 | }
150 | identifiers.add(node.local.name);
151 | nodes.push(this.finishNode(node, "ImportSpecifier"));
152 | }
153 | return nodes;
154 | }
155 | parseExprAtom(refDestructuringErrors) {
156 | return (
157 | this.parseMaybeKeywordExpression("viewof", "ViewExpression") ||
158 | this.parseMaybeKeywordExpression("mutable", "MutableExpression") ||
159 | super.parseExprAtom(refDestructuringErrors)
160 | );
161 | }
162 | parseCell(node, eof) {
163 | const lookahead = new CellParser({}, this.input, this.start);
164 | let token = lookahead.getToken();
165 | let body = null;
166 | let id = null;
167 |
168 | this.O_function = 0;
169 | this.O_async = false;
170 | this.O_generator = false;
171 | this.strict = true;
172 | this.enterScope(SCOPE_FUNCTION | SCOPE_ASYNC | SCOPE_GENERATOR);
173 |
174 | // An import?
175 | if (token.type === tt._import && lookahead.getToken().type !== tt.parenL) {
176 | body = this.parseImport(this.startNode());
177 | }
178 |
179 | // A non-empty cell?
180 | else if (token.type !== tt.eof && token.type !== tt.semi) {
181 | // A named cell?
182 | if (token.type === tt.name) {
183 | if (token.value === "viewof" || token.value === "mutable") {
184 | token = lookahead.getToken();
185 | if (token.type !== tt.name) {
186 | lookahead.unexpected();
187 | }
188 | }
189 | token = lookahead.getToken();
190 | if (token.type === tt.eq) {
191 | id =
192 | this.parseMaybeKeywordExpression("viewof", "ViewExpression") ||
193 | this.parseMaybeKeywordExpression("mutable", "MutableExpression") ||
194 | this.parseIdent();
195 | token = lookahead.getToken();
196 | this.expect(tt.eq);
197 | }
198 | }
199 |
200 | // A block?
201 | if (token.type === tt.braceL) {
202 | body = this.parseBlock();
203 | }
204 |
205 | // An expression?
206 | // Possibly a function or class declaration?
207 | else {
208 | body = this.parseExpression();
209 | if (
210 | id === null &&
211 | (body.type === "FunctionExpression" ||
212 | body.type === "ClassExpression")
213 | ) {
214 | id = body.id;
215 | }
216 | }
217 | }
218 |
219 | this.semicolon();
220 | if (eof) this.expect(tt.eof); // TODO
221 |
222 | node.id = id;
223 | node.async = this.O_async;
224 | node.generator = this.O_generator;
225 | node.body = body;
226 | this.exitScope();
227 | return this.finishNode(node, "Cell");
228 | }
229 | parseTopLevel(node) {
230 | return this.parseCell(node, true);
231 | }
232 | toAssignable(node, isBinding, refDestructuringErrors) {
233 | return node.type === "MutableExpression"
234 | ? node
235 | : super.toAssignable(node, isBinding, refDestructuringErrors);
236 | }
237 | checkUnreserved(node) {
238 | if (node.name === "viewof" || node.name === "mutable") {
239 | this.raise(node.start, `Unexpected keyword '${node.name}'`);
240 | }
241 | return super.checkUnreserved(node);
242 | }
243 | checkLVal(expr, bindingType, checkClashes) {
244 | return super.checkLVal(
245 | expr.type === "MutableExpression" ? expr.id : expr,
246 | bindingType,
247 | checkClashes
248 | );
249 | }
250 | unexpected(pos) {
251 | this.raise(
252 | pos != null ? pos : this.start,
253 | this.type === tt.eof ? "Unexpected end of input" : "Unexpected token"
254 | );
255 | }
256 | parseMaybeKeywordExpression(keyword, type) {
257 | if (this.isContextual(keyword)) {
258 | const node = this.startNode();
259 | this.next();
260 | node.id = this.parseIdent();
261 | return this.finishNode(node, type);
262 | }
263 | }
264 | }
265 |
266 | export function parseModule(input, {globals} = {}) {
267 | const program = ModuleParser.parse(input);
268 | for (const cell of program.cells) {
269 | parseReferences(cell, input, globals);
270 | parseFileAttachments(cell, input, globals);
271 | }
272 | return program;
273 | }
274 |
275 | export class ModuleParser extends CellParser {
276 | parseTopLevel(node) {
277 | if (!node.cells) node.cells = [];
278 | while (this.type !== tt.eof) {
279 | const cell = this.parseCell(this.startNode());
280 | cell.input = this.input;
281 | node.cells.push(cell);
282 | }
283 | this.next();
284 | return this.finishNode(node, "Program");
285 | }
286 | }
287 |
288 | // Find references.
289 | // Check for illegal references to arguments.
290 | // Check for illegal assignments to global references.
291 | function parseReferences(cell, input, globals = defaultGlobals) {
292 | if (cell.body && cell.body.type !== "ImportDeclaration") {
293 | try {
294 | cell.references = findReferences(cell, globals);
295 | } catch (error) {
296 | if (error.node) {
297 | const loc = getLineInfo(input, error.node.start);
298 | error.message += ` (${loc.line}:${loc.column})`;
299 | error.pos = error.node.start;
300 | error.loc = loc;
301 | delete error.node;
302 | }
303 | throw error;
304 | }
305 | }
306 | return cell;
307 | }
308 |
309 | // Find references.
310 | // Check for illegal references to arguments.
311 | // Check for illegal assignments to global references.
312 | function parseFileAttachments(cell, input) {
313 | if (cell.body && cell.body.type !== "ImportDeclaration") {
314 | try {
315 | cell.fileAttachments = findFileAttachments(cell);
316 | } catch (error) {
317 | if (error.node) {
318 | const loc = getLineInfo(input, error.node.start);
319 | error.message += ` (${loc.line}:${loc.column})`;
320 | error.pos = error.node.start;
321 | error.loc = loc;
322 | delete error.node;
323 | }
324 | throw error;
325 | }
326 | } else {
327 | cell.fileAttachments = new Map();
328 | }
329 | return cell;
330 | }
331 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # @observablehq/parser
2 |
3 | [](https://github.com/observablehq/parser/actions?workflow=Node+CI)
4 |
5 | To parse a cell:
6 |
7 | ```js
8 | import {parseCell} from "@observablehq/parser";
9 |
10 | const cell = parseCell(`hello = "world"`);
11 | ```
12 |
13 | ## Examples
14 |
15 | (In these examples, the *node*.start and *node*.end indexes into the *input* string are not shown for brevity. If *options*.locations is true, *node*.loc will also be populated with the line and column numbers.)
16 |
17 | An expression cell (where [*cell*.body](#cell_body) is a type of expression):
18 |
19 | ```js
20 | 1 + 2
21 | ```
22 |
23 | ```json
24 | {
25 | "type": "Cell",
26 | "id": null,
27 | "async": false,
28 | "generator": false,
29 | "body": {
30 | "type": "BinaryExpression",
31 | "left": {
32 | "type": "Literal",
33 | "value": 1,
34 | "raw": "1"
35 | },
36 | "operator": "+",
37 | "right": {
38 | "type": "Literal",
39 | "value": 2,
40 | "raw": "2"
41 | }
42 | }
43 | }
44 | ```
45 |
46 | A block cell (where [*cell*.body](#cell_body) is a BlockStatement):
47 |
48 | ```js
49 | {
50 | return 1 + 2;
51 | }
52 | ```
53 |
54 | ```json
55 | {
56 | "type": "Cell",
57 | "id": null,
58 | "async": false,
59 | "generator": false,
60 | "body": {
61 | "type": "BlockStatement",
62 | "body": [
63 | {
64 | "type": "ReturnStatement",
65 | "argument": {
66 | "type": "BinaryExpression",
67 | "left": {
68 | "type": "Literal",
69 | "value": 1,
70 | "raw": "1"
71 | },
72 | "operator": "+",
73 | "right": {
74 | "type": "Literal",
75 | "value": 2,
76 | "raw": "2"
77 | }
78 | }
79 | }
80 | ]
81 | }
82 | }
83 | ```
84 |
85 | An empty cell (where [*cell*.body](#cell_body) is null):
86 |
87 | ```js
88 | ```
89 |
90 | ```json
91 | {
92 | "type": "Cell",
93 | "id": null,
94 | "async": false,
95 | "generator": false,
96 | "body": null
97 | }
98 | ```
99 |
100 | A named expression cell (where [*cell*.id](#cell_id) is an Identifier):
101 |
102 | ```js
103 | foo = 42
104 | ```
105 |
106 | ```json
107 | {
108 | "type": "Cell",
109 | "id": {
110 | "type": "Identifier",
111 | "name": "foo"
112 | },
113 | "async": false,
114 | "generator": false,
115 | "body": {
116 | "type": "Literal",
117 | "value": 42,
118 | "raw": "42"
119 | }
120 | }
121 | ```
122 |
123 | A named block cell (where [*cell*.id](#cell_id) is an Identifier):
124 |
125 | ```js
126 | foo = {
127 | return 42;
128 | }
129 | ```
130 |
131 | ```json
132 | {
133 | "type": "Cell",
134 | "id": {
135 | "type": "Identifier",
136 | "name": "foo"
137 | },
138 | "async": false,
139 | "generator": false,
140 | "body": {
141 | "type": "BlockStatement",
142 | "body": [
143 | {
144 | "type": "ReturnStatement",
145 | "argument": {
146 | "type": "Literal",
147 | "value": 42,
148 | "raw": "42"
149 | }
150 | }
151 | ]
152 | }
153 | }
154 | ```
155 |
156 | An asynchronous expression cell (where [*cell*.async](#cell_async) is true):
157 |
158 | ```js
159 | 2 * await value
160 | ```
161 |
162 | ```json
163 | {
164 | "type": "Cell",
165 | "id": null,
166 | "async": true,
167 | "generator": false,
168 | "body": {
169 | "type": "BinaryExpression",
170 | "left": {
171 | "type": "Literal",
172 | "value": 2,
173 | "raw": "2"
174 | },
175 | "operator": "*",
176 | "right": {
177 | "type": "AwaitExpression",
178 | "argument": {
179 | "type": "Identifier",
180 | "name": "value"
181 | }
182 | }
183 | }
184 | }
185 | ```
186 |
187 | A generator expression cell (where [*cell*.generator](#cell_generator) is true):
188 |
189 | ```js
190 | yield* [1, 2, 3]
191 | ```
192 |
193 | ```json
194 | {
195 | "type": "Cell",
196 | "id": null,
197 | "async": false,
198 | "generator": true,
199 | "body": {
200 | "type": "YieldExpression",
201 | "delegate": true,
202 | "argument": {
203 | "type": "ArrayExpression",
204 | "elements": [
205 | {
206 | "type": "Literal",
207 | "value": 1,
208 | "raw": "1"
209 | },
210 | {
211 | "type": "Literal",
212 | "value": 2,
213 | "raw": "2"
214 | },
215 | {
216 | "type": "Literal",
217 | "value": 3,
218 | "raw": "3"
219 | }
220 | ]
221 | }
222 | }
223 | }
224 | ```
225 |
226 | A viewof expression cell (where [*cell*.id](#cell_id) is a [ViewExpression](#viewexpression)):
227 |
228 | ```js
229 | viewof x = DOM.range()
230 | ```
231 |
232 | ```json
233 | {
234 | "type": "Cell",
235 | "id": {
236 | "type": "ViewExpression",
237 | "id": {
238 | "type": "Identifier",
239 | "name": "x"
240 | }
241 | },
242 | "async": false,
243 | "generator": false,
244 | "body": {
245 | "type": "CallExpression",
246 | "callee": {
247 | "type": "MemberExpression",
248 | "object": {
249 | "type": "Identifier",
250 | "name": "DOM"
251 | },
252 | "property": {
253 | "type": "Identifier",
254 | "name": "range"
255 | },
256 | "computed": false
257 | },
258 | "arguments": []
259 | }
260 | }
261 | ```
262 |
263 | A viewof reference within an expression cell (where [*cell*.body](#cell_body) contains a [ViewExpression](#viewexpression)):
264 |
265 | ```js
266 | viewof x.tagName
267 | ```
268 |
269 | ```json
270 | {
271 | "type": "Cell",
272 | "id": null,
273 | "async": false,
274 | "generator": false,
275 | "body": {
276 | "type": "MemberExpression",
277 | "object": {
278 | "type": "ViewExpression",
279 | "id": {
280 | "type": "Identifier",
281 | "name": "x"
282 | }
283 | },
284 | "property": {
285 | "type": "Identifier",
286 | "name": "tagName"
287 | },
288 | "computed": false
289 | }
290 | }
291 | ```
292 |
293 | An import cell (where [*cell*.body](#cell_body) is an [ImportDeclaration](#importdeclaration)):
294 |
295 | ```js
296 | import {foo} from "module"
297 | ```
298 |
299 | ```json
300 | {
301 | "type": "Cell",
302 | "id": null,
303 | "async": false,
304 | "generator": false,
305 | "body": {
306 | "type": "ImportDeclaration",
307 | "specifiers": [
308 | {
309 | "type": "ImportSpecifier",
310 | "view": false,
311 | "imported": {
312 | "type": "Identifier",
313 | "name": "foo"
314 | },
315 | "local": {
316 | "type": "Identifier",
317 | "name": "foo"
318 | }
319 | }
320 | ],
321 | "source": {
322 | "type": "Literal",
323 | "value": "module",
324 | "raw": "\"module\""
325 | }
326 | }
327 | }
328 | ```
329 |
330 | Importing a view (where [*specifier*.view](#specifier_view) is true):
331 |
332 | ```js
333 | import {viewof foo} from "module"
334 | ```
335 |
336 | ```json
337 | {
338 | "type": "Cell",
339 | "id": null,
340 | "async": false,
341 | "generator": false,
342 | "body": {
343 | "type": "ImportDeclaration",
344 | "specifiers": [
345 | {
346 | "type": "ImportSpecifier",
347 | "view": true,
348 | "imported": {
349 | "type": "Identifier",
350 | "name": "foo"
351 | },
352 | "local": {
353 | "type": "Identifier",
354 | "name": "foo"
355 | }
356 | }
357 | ],
358 | "source": {
359 | "type": "Literal",
360 | "value": "module",
361 | "raw": "\"module\""
362 | }
363 | }
364 | }
365 | ```
366 |
367 | Importing a view imports both the view symbol (`viewof foo`) and the value symbol (`foo`). Likewise, if the specified view is renamed during import (*e.g.*, `viewof foo as bar`), both the view symbol and the value symbol are renamed (*e.g.*, `viewof bar` and `bar`).
368 |
369 | Importing with injection (where [*declaration*.injections](#declaration_injections) is present):
370 |
371 | ```js
372 | import {chart} with {sales as data} from "@mbostock/d3-bar-chart"
373 | ```
374 |
375 | ```json
376 | {
377 | "type": "Cell",
378 | "id": null,
379 | "async": false,
380 | "generator": false,
381 | "body": {
382 | "type": "ImportDeclaration",
383 | "specifiers": [
384 | {
385 | "type": "ImportSpecifier",
386 | "view": false,
387 | "imported": {
388 | "type": "Identifier",
389 | "name": "chart"
390 | },
391 | "local": {
392 | "type": "Identifier",
393 | "name": "chart"
394 | }
395 | }
396 | ],
397 | "injections": [
398 | {
399 | "type": "ImportSpecifier",
400 | "view": false,
401 | "imported": {
402 | "type": "Identifier",
403 | "name": "sales"
404 | },
405 | "local": {
406 | "type": "Identifier",
407 | "name": "data"
408 | }
409 | }
410 | ],
411 | "source": {
412 | "type": "Literal",
413 | "value": "@mbostock/d3-bar-chart",
414 | "raw": "\"@mbostock/d3-bar-chart\""
415 | }
416 | }
417 | }
418 | ```
419 |
420 | For an injection, *specifier*.imported and *specifier*.local are reversed compared to a normal specifier: they are from the perspective of the imported module rather than the importing module. So in the example above, the importing module’s variable *sales* is injected into the imported module (the chart), replacing the variable *data*.
421 |
422 | Injecting a view injects both the view symbol (`viewof foo`) and the value symbol (`foo`). Likewise, if the specified view is renamed during injection (*e.g.*, `viewof foo as bar`), both the view symbol and the value symbol are renamed (*e.g.*, `viewof bar` and `bar`).
423 |
424 | ## API Reference
425 |
426 | # parseCell(input[, options]) [<>](https://github.com/observablehq/parser/blob/master/src/parse.js "Source")
427 |
428 | Returns a [cell](#cell).
429 |
430 | # parseModule(input[, options]) [<>](https://github.com/observablehq/parser/blob/master/src/parse.js "Source")
431 |
432 | Returns a [program](#program).
433 |
434 | # peekId(input) [<>](https://github.com/observablehq/parser/blob/master/src/parse.js "Source")
435 |
436 | Tries to find the ID of a cell given a snippet of its contents, and returns it as a string if found.
437 |
438 | ### Cell
439 |
440 | # cell.id
441 |
442 | The name of the cell: null if the cell is anonymous; otherwise an Identifier or a ViewExpression.
443 |
444 | # cell.body
445 |
446 | The body of the cell: null for an empty cell; an ImportDeclaration for an import cell; otherwise a BlockStatement or an expression node.
447 |
448 | # cell.async
449 |
450 | A boolean indicating whether the cell body is asynchronous (*i.e.*, whether it contains an `await` statement). False for import and empty cells.
451 |
452 | # cell.generator
453 |
454 | A boolean indicating whether the cell body is a generator (*i.e.*, whether it contains a `yield` statement). False for import and empty cells.
455 |
456 | ### ViewExpression
457 |
458 | # view.id
459 |
460 | The view identifier: an Identifier.
461 |
462 | ### ImportDeclaration
463 |
464 | # declaration.injections
465 |
466 | An array of ImportSpecifier nodes, if the import declaration has a `with` clause, and otherwise null.
467 |
468 | ### ImportSpecifier
469 |
470 | # specifier.view
471 |
472 | A boolean indicating whether the import specifies a view.
473 |
474 | ### Program
475 |
476 | # program.cells
477 |
478 | An array of [cells](#cell).
479 |
--------------------------------------------------------------------------------
/tap-snapshots/test-parse-test.js-TAP.test.js:
--------------------------------------------------------------------------------
1 | /* IMPORTANT
2 | * This snapshot file is auto-generated, but designed for humans.
3 | * It should be checked into source control and tracked carefully.
4 | * Re-generate by setting TAP_SNAPSHOT=1 and running tests.
5 | * Make sure to inspect the output below. Do not ignore changes!
6 | */
7 | 'use strict'
8 | exports[`test/parse-test.js TAP parse anonymous-block-cell.js > must match snapshot 1`] = `
9 | Node {
10 | "async": false,
11 | "body": Node {
12 | "body": Array [
13 | Node {
14 | "argument": Node {
15 | "end": 13,
16 | "raw": "42",
17 | "start": 11,
18 | "type": "Literal",
19 | "value": 42,
20 | },
21 | "end": 14,
22 | "start": 4,
23 | "type": "ReturnStatement",
24 | },
25 | ],
26 | "end": 16,
27 | "start": 0,
28 | "type": "BlockStatement",
29 | },
30 | "end": 17,
31 | "fileAttachments": Map {},
32 | "generator": false,
33 | "id": null,
34 | "references": Array [],
35 | "start": 0,
36 | "type": "Cell",
37 | }
38 | `
39 |
40 | exports[`test/parse-test.js TAP parse anonymous-expression-cell.js > must match snapshot 1`] = `
41 | Node {
42 | "async": false,
43 | "body": Node {
44 | "end": 2,
45 | "raw": "42",
46 | "start": 0,
47 | "type": "Literal",
48 | "value": 42,
49 | },
50 | "end": 3,
51 | "fileAttachments": Map {},
52 | "generator": false,
53 | "id": null,
54 | "references": Array [],
55 | "start": 0,
56 | "type": "Cell",
57 | }
58 | `
59 |
60 | exports[`test/parse-test.js TAP parse anonymous-function.js > must match snapshot 1`] = `
61 | Node {
62 | "async": false,
63 | "body": Node {
64 | "async": false,
65 | "body": Node {
66 | "body": Array [
67 | Node {
68 | "argument": Node {
69 | "end": 22,
70 | "raw": "42",
71 | "start": 20,
72 | "type": "Literal",
73 | "value": 42,
74 | },
75 | "end": 23,
76 | "start": 13,
77 | "type": "ReturnStatement",
78 | },
79 | ],
80 | "end": 25,
81 | "start": 11,
82 | "type": "BlockStatement",
83 | },
84 | "end": 25,
85 | "expression": false,
86 | "generator": false,
87 | "id": null,
88 | "params": Array [],
89 | "start": 0,
90 | "type": "FunctionExpression",
91 | },
92 | "end": 26,
93 | "fileAttachments": Map {},
94 | "generator": false,
95 | "id": null,
96 | "references": Array [],
97 | "start": 0,
98 | "type": "Cell",
99 | }
100 | `
101 |
102 | exports[`test/parse-test.js TAP parse await-block-cell.js > must match snapshot 1`] = `
103 | Node {
104 | "async": true,
105 | "body": Node {
106 | "body": Array [
107 | Node {
108 | "end": 18,
109 | "expression": Node {
110 | "argument": Node {
111 | "end": 17,
112 | "name": "promise",
113 | "start": 10,
114 | "type": "Identifier",
115 | },
116 | "end": 17,
117 | "start": 4,
118 | "type": "AwaitExpression",
119 | },
120 | "start": 4,
121 | "type": "ExpressionStatement",
122 | },
123 | ],
124 | "end": 20,
125 | "start": 0,
126 | "type": "BlockStatement",
127 | },
128 | "end": 21,
129 | "fileAttachments": Map {},
130 | "generator": false,
131 | "id": null,
132 | "references": Array [
133 | Node {
134 | "end": 17,
135 | "name": "promise",
136 | "start": 10,
137 | "type": "Identifier",
138 | },
139 | ],
140 | "start": 0,
141 | "type": "Cell",
142 | }
143 | `
144 |
145 | exports[`test/parse-test.js TAP parse await-in-arrow-function-expression.js > must match snapshot 1`] = `
146 | Node {
147 | "async": false,
148 | "body": Node {
149 | "async": true,
150 | "body": Node {
151 | "body": Array [
152 | Node {
153 | "end": 30,
154 | "expression": Node {
155 | "argument": Node {
156 | "end": 29,
157 | "name": "promise",
158 | "start": 22,
159 | "type": "Identifier",
160 | },
161 | "end": 29,
162 | "start": 16,
163 | "type": "AwaitExpression",
164 | },
165 | "start": 16,
166 | "type": "ExpressionStatement",
167 | },
168 | ],
169 | "end": 32,
170 | "start": 12,
171 | "type": "BlockStatement",
172 | },
173 | "end": 32,
174 | "expression": false,
175 | "generator": false,
176 | "id": null,
177 | "params": Array [],
178 | "start": 0,
179 | "type": "ArrowFunctionExpression",
180 | },
181 | "end": 33,
182 | "fileAttachments": Map {},
183 | "generator": false,
184 | "id": null,
185 | "references": Array [
186 | Node {
187 | "end": 29,
188 | "name": "promise",
189 | "start": 22,
190 | "type": "Identifier",
191 | },
192 | ],
193 | "start": 0,
194 | "type": "Cell",
195 | }
196 | `
197 |
198 | exports[`test/parse-test.js TAP parse await-in-arrow-function.js > must match snapshot 1`] = `
199 | Node {
200 | "async": false,
201 | "body": Node {
202 | "body": Array [
203 | Node {
204 | "declarations": Array [
205 | Node {
206 | "end": 54,
207 | "id": Node {
208 | "end": 15,
209 | "name": "inner",
210 | "start": 10,
211 | "type": "Identifier",
212 | },
213 | "init": Node {
214 | "async": true,
215 | "body": Node {
216 | "body": Array [
217 | Node {
218 | "end": 50,
219 | "expression": Node {
220 | "argument": Node {
221 | "end": 49,
222 | "name": "promise",
223 | "start": 42,
224 | "type": "Identifier",
225 | },
226 | "end": 49,
227 | "start": 36,
228 | "type": "AwaitExpression",
229 | },
230 | "start": 36,
231 | "type": "ExpressionStatement",
232 | },
233 | ],
234 | "end": 54,
235 | "start": 30,
236 | "type": "BlockStatement",
237 | },
238 | "end": 54,
239 | "expression": false,
240 | "generator": false,
241 | "id": null,
242 | "params": Array [],
243 | "start": 18,
244 | "type": "ArrowFunctionExpression",
245 | },
246 | "start": 10,
247 | "type": "VariableDeclarator",
248 | },
249 | ],
250 | "end": 55,
251 | "kind": "const",
252 | "start": 4,
253 | "type": "VariableDeclaration",
254 | },
255 | ],
256 | "end": 57,
257 | "start": 0,
258 | "type": "BlockStatement",
259 | },
260 | "end": 58,
261 | "fileAttachments": Map {},
262 | "generator": false,
263 | "id": null,
264 | "references": Array [
265 | Node {
266 | "end": 49,
267 | "name": "promise",
268 | "start": 42,
269 | "type": "Identifier",
270 | },
271 | ],
272 | "start": 0,
273 | "type": "Cell",
274 | }
275 | `
276 |
277 | exports[`test/parse-test.js TAP parse await-in-class.js > must match snapshot 1`] = `
278 | Node {
279 | "async": false,
280 | "body": Node {
281 | "body": Array [
282 | Node {
283 | "body": Node {
284 | "body": Array [
285 | Node {
286 | "computed": false,
287 | "end": 65,
288 | "key": Node {
289 | "end": 34,
290 | "name": "method",
291 | "start": 28,
292 | "type": "Identifier",
293 | },
294 | "kind": "method",
295 | "start": 22,
296 | "static": false,
297 | "type": "MethodDefinition",
298 | "value": Node {
299 | "async": true,
300 | "body": Node {
301 | "body": Array [
302 | Node {
303 | "end": 59,
304 | "expression": Node {
305 | "argument": Node {
306 | "end": 58,
307 | "name": "promise",
308 | "start": 51,
309 | "type": "Identifier",
310 | },
311 | "end": 58,
312 | "start": 45,
313 | "type": "AwaitExpression",
314 | },
315 | "start": 45,
316 | "type": "ExpressionStatement",
317 | },
318 | ],
319 | "end": 65,
320 | "start": 37,
321 | "type": "BlockStatement",
322 | },
323 | "end": 65,
324 | "expression": false,
325 | "generator": false,
326 | "id": null,
327 | "params": Array [],
328 | "start": 34,
329 | "type": "FunctionExpression",
330 | },
331 | },
332 | ],
333 | "end": 69,
334 | "start": 16,
335 | "type": "ClassBody",
336 | },
337 | "end": 69,
338 | "id": Node {
339 | "end": 15,
340 | "name": "Inner",
341 | "start": 10,
342 | "type": "Identifier",
343 | },
344 | "start": 4,
345 | "superClass": null,
346 | "type": "ClassDeclaration",
347 | },
348 | ],
349 | "end": 71,
350 | "start": 0,
351 | "type": "BlockStatement",
352 | },
353 | "end": 72,
354 | "fileAttachments": Map {},
355 | "generator": false,
356 | "id": null,
357 | "references": Array [
358 | Node {
359 | "end": 58,
360 | "name": "promise",
361 | "start": 51,
362 | "type": "Identifier",
363 | },
364 | ],
365 | "start": 0,
366 | "type": "Cell",
367 | }
368 | `
369 |
370 | exports[`test/parse-test.js TAP parse await-in-function.js > must match snapshot 1`] = `
371 | Node {
372 | "async": false,
373 | "body": Node {
374 | "body": Array [
375 | Node {
376 | "async": true,
377 | "body": Node {
378 | "body": Array [
379 | Node {
380 | "end": 47,
381 | "expression": Node {
382 | "argument": Node {
383 | "end": 46,
384 | "name": "promise",
385 | "start": 39,
386 | "type": "Identifier",
387 | },
388 | "end": 46,
389 | "start": 33,
390 | "type": "AwaitExpression",
391 | },
392 | "start": 33,
393 | "type": "ExpressionStatement",
394 | },
395 | ],
396 | "end": 51,
397 | "start": 27,
398 | "type": "BlockStatement",
399 | },
400 | "end": 51,
401 | "expression": false,
402 | "generator": false,
403 | "id": Node {
404 | "end": 24,
405 | "name": "inner",
406 | "start": 19,
407 | "type": "Identifier",
408 | },
409 | "params": Array [],
410 | "start": 4,
411 | "type": "FunctionDeclaration",
412 | },
413 | ],
414 | "end": 53,
415 | "start": 0,
416 | "type": "BlockStatement",
417 | },
418 | "end": 54,
419 | "fileAttachments": Map {},
420 | "generator": false,
421 | "id": null,
422 | "references": Array [
423 | Node {
424 | "end": 46,
425 | "name": "promise",
426 | "start": 39,
427 | "type": "Identifier",
428 | },
429 | ],
430 | "start": 0,
431 | "type": "Cell",
432 | }
433 | `
434 |
435 | exports[`test/parse-test.js TAP parse await-yield.js > must match snapshot 1`] = `
436 | Node {
437 | "async": true,
438 | "body": Node {
439 | "body": Array [
440 | Node {
441 | "end": 18,
442 | "expression": Node {
443 | "argument": Node {
444 | "end": 17,
445 | "name": "promise",
446 | "start": 10,
447 | "type": "Identifier",
448 | },
449 | "end": 17,
450 | "start": 4,
451 | "type": "AwaitExpression",
452 | },
453 | "start": 4,
454 | "type": "ExpressionStatement",
455 | },
456 | Node {
457 | "end": 33,
458 | "expression": Node {
459 | "argument": Node {
460 | "end": 32,
461 | "name": "value",
462 | "start": 27,
463 | "type": "Identifier",
464 | },
465 | "delegate": false,
466 | "end": 32,
467 | "start": 21,
468 | "type": "YieldExpression",
469 | },
470 | "start": 21,
471 | "type": "ExpressionStatement",
472 | },
473 | ],
474 | "end": 35,
475 | "start": 0,
476 | "type": "BlockStatement",
477 | },
478 | "end": 36,
479 | "fileAttachments": Map {},
480 | "generator": true,
481 | "id": null,
482 | "references": Array [
483 | Node {
484 | "end": 17,
485 | "name": "promise",
486 | "start": 10,
487 | "type": "Identifier",
488 | },
489 | Node {
490 | "end": 32,
491 | "name": "value",
492 | "start": 27,
493 | "type": "Identifier",
494 | },
495 | ],
496 | "start": 0,
497 | "type": "Cell",
498 | }
499 | `
500 |
501 | exports[`test/parse-test.js TAP parse bare-dynamic-import.js > must match snapshot 1`] = `
502 | Node {
503 | "async": false,
504 | "body": Node {
505 | "end": 13,
506 | "source": Node {
507 | "end": 12,
508 | "raw": "\\"bar\\"",
509 | "start": 7,
510 | "type": "Literal",
511 | "value": "bar",
512 | },
513 | "start": 0,
514 | "type": "ImportExpression",
515 | },
516 | "end": 14,
517 | "fileAttachments": Map {},
518 | "generator": false,
519 | "id": null,
520 | "references": Array [],
521 | "start": 0,
522 | "type": "Cell",
523 | }
524 | `
525 |
526 | exports[`test/parse-test.js TAP parse bigint-zero.js > must match snapshot 1`] = `
527 | Node {
528 | "async": false,
529 | "body": Node {
530 | "bigint": "0",
531 | "end": 2,
532 | "raw": "0n",
533 | "start": 0,
534 | "type": "Literal",
535 | "value": 0,
536 | },
537 | "end": 3,
538 | "fileAttachments": Map {},
539 | "generator": false,
540 | "id": null,
541 | "references": Array [],
542 | "start": 0,
543 | "type": "Cell",
544 | }
545 | `
546 |
547 | exports[`test/parse-test.js TAP parse bigint.js > must match snapshot 1`] = `
548 | Node {
549 | "async": false,
550 | "body": Node {
551 | "end": 9,
552 | "left": Node {
553 | "end": 3,
554 | "name": "foo",
555 | "start": 0,
556 | "type": "Identifier",
557 | },
558 | "operator": "+",
559 | "right": Node {
560 | "bigint": "42",
561 | "end": 9,
562 | "raw": "42n",
563 | "start": 6,
564 | "type": "Literal",
565 | "value": 42,
566 | },
567 | "start": 0,
568 | "type": "BinaryExpression",
569 | },
570 | "end": 10,
571 | "fileAttachments": Map {},
572 | "generator": false,
573 | "id": null,
574 | "references": Array [
575 | Node {
576 | "end": 3,
577 | "name": "foo",
578 | "start": 0,
579 | "type": "Identifier",
580 | },
581 | ],
582 | "start": 0,
583 | "type": "Cell",
584 | }
585 | `
586 |
587 | exports[`test/parse-test.js TAP parse binary-expression.js > must match snapshot 1`] = `
588 | Node {
589 | "async": false,
590 | "body": Node {
591 | "end": 8,
592 | "left": Node {
593 | "end": 3,
594 | "name": "foo",
595 | "start": 0,
596 | "type": "Identifier",
597 | },
598 | "operator": "+",
599 | "right": Node {
600 | "end": 8,
601 | "raw": "42",
602 | "start": 6,
603 | "type": "Literal",
604 | "value": 42,
605 | },
606 | "start": 0,
607 | "type": "BinaryExpression",
608 | },
609 | "end": 9,
610 | "fileAttachments": Map {},
611 | "generator": false,
612 | "id": null,
613 | "references": Array [
614 | Node {
615 | "end": 3,
616 | "name": "foo",
617 | "start": 0,
618 | "type": "Identifier",
619 | },
620 | ],
621 | "start": 0,
622 | "type": "Cell",
623 | }
624 | `
625 |
626 | exports[`test/parse-test.js TAP parse block-leading-comment.js > must match snapshot 1`] = `
627 | Node {
628 | "async": false,
629 | "body": Node {
630 | "body": Array [
631 | Node {
632 | "argument": Node {
633 | "end": 40,
634 | "raw": "42",
635 | "start": 38,
636 | "type": "Literal",
637 | "value": 42,
638 | },
639 | "end": 41,
640 | "start": 31,
641 | "type": "ReturnStatement",
642 | },
643 | ],
644 | "end": 43,
645 | "start": 27,
646 | "type": "BlockStatement",
647 | },
648 | "end": 44,
649 | "fileAttachments": Map {},
650 | "generator": false,
651 | "id": Node {
652 | "end": 24,
653 | "name": "foo",
654 | "start": 21,
655 | "type": "Identifier",
656 | },
657 | "references": Array [],
658 | "start": 0,
659 | "type": "Cell",
660 | }
661 | `
662 |
663 | exports[`test/parse-test.js TAP parse block-trailing-comment.js > must match snapshot 1`] = `
664 | Node {
665 | "async": false,
666 | "body": Node {
667 | "body": Array [
668 | Node {
669 | "argument": Node {
670 | "end": 19,
671 | "raw": "42",
672 | "start": 17,
673 | "type": "Literal",
674 | "value": 42,
675 | },
676 | "end": 20,
677 | "start": 10,
678 | "type": "ReturnStatement",
679 | },
680 | ],
681 | "end": 22,
682 | "start": 6,
683 | "type": "BlockStatement",
684 | },
685 | "end": 42,
686 | "fileAttachments": Map {},
687 | "generator": false,
688 | "id": Node {
689 | "end": 3,
690 | "name": "foo",
691 | "start": 0,
692 | "type": "Identifier",
693 | },
694 | "references": Array [],
695 | "start": 0,
696 | "type": "Cell",
697 | }
698 | `
699 |
700 | exports[`test/parse-test.js TAP parse catch-clause.js > must match snapshot 1`] = `
701 | Node {
702 | "async": false,
703 | "body": Node {
704 | "body": Array [
705 | Node {
706 | "block": Node {
707 | "body": Array [
708 | Node {
709 | "declarations": Array [
710 | Node {
711 | "end": 25,
712 | "id": Node {
713 | "elements": Array [
714 | Node {
715 | "end": 20,
716 | "name": "x",
717 | "start": 19,
718 | "type": "Identifier",
719 | },
720 | ],
721 | "end": 21,
722 | "start": 18,
723 | "type": "ArrayPattern",
724 | },
725 | "init": Node {
726 | "end": 25,
727 | "name": "y",
728 | "start": 24,
729 | "type": "Identifier",
730 | },
731 | "start": 18,
732 | "type": "VariableDeclarator",
733 | },
734 | ],
735 | "end": 26,
736 | "kind": "let",
737 | "start": 14,
738 | "type": "VariableDeclaration",
739 | },
740 | Node {
741 | "end": 35,
742 | "expression": Node {
743 | "argument": Node {
744 | "end": 32,
745 | "name": "x",
746 | "start": 31,
747 | "type": "Identifier",
748 | },
749 | "end": 34,
750 | "operator": "++",
751 | "prefix": false,
752 | "start": 31,
753 | "type": "UpdateExpression",
754 | },
755 | "start": 31,
756 | "type": "ExpressionStatement",
757 | },
758 | Node {
759 | "argument": Node {
760 | "end": 48,
761 | "name": "x",
762 | "start": 47,
763 | "type": "Identifier",
764 | },
765 | "end": 49,
766 | "start": 40,
767 | "type": "ReturnStatement",
768 | },
769 | ],
770 | "end": 53,
771 | "start": 8,
772 | "type": "BlockStatement",
773 | },
774 | "end": 83,
775 | "finalizer": null,
776 | "handler": Node {
777 | "body": Node {
778 | "body": Array [
779 | Node {
780 | "argument": Node {
781 | "end": 78,
782 | "name": "e",
783 | "start": 77,
784 | "type": "Identifier",
785 | },
786 | "end": 79,
787 | "start": 70,
788 | "type": "ReturnStatement",
789 | },
790 | ],
791 | "end": 83,
792 | "start": 64,
793 | "type": "BlockStatement",
794 | },
795 | "end": 83,
796 | "param": Node {
797 | "end": 62,
798 | "name": "e",
799 | "start": 61,
800 | "type": "Identifier",
801 | },
802 | "start": 54,
803 | "type": "CatchClause",
804 | },
805 | "start": 4,
806 | "type": "TryStatement",
807 | },
808 | ],
809 | "end": 85,
810 | "start": 0,
811 | "type": "BlockStatement",
812 | },
813 | "end": 86,
814 | "fileAttachments": Map {},
815 | "generator": false,
816 | "id": null,
817 | "references": Array [
818 | Node {
819 | "end": 25,
820 | "name": "y",
821 | "start": 24,
822 | "type": "Identifier",
823 | },
824 | ],
825 | "start": 0,
826 | "type": "Cell",
827 | }
828 | `
829 |
830 | exports[`test/parse-test.js TAP parse comma-then-comment.js > must match snapshot 1`] = `
831 | Object {
832 | "error": Object {
833 | "loc": Object {
834 | "column": 0,
835 | "line": 2,
836 | },
837 | "message": "Unexpected end of input (2:0)",
838 | "pos": 30,
839 | "type": "SyntaxError",
840 | },
841 | }
842 | `
843 |
844 | exports[`test/parse-test.js TAP parse comment.js > must match snapshot 1`] = `
845 | Node {
846 | "async": false,
847 | "body": null,
848 | "end": 19,
849 | "fileAttachments": Map {},
850 | "generator": false,
851 | "id": null,
852 | "start": 0,
853 | "type": "Cell",
854 | }
855 | `
856 |
857 | exports[`test/parse-test.js TAP parse computed-property-name.js > must match snapshot 1`] = `
858 | Node {
859 | "async": false,
860 | "body": Node {
861 | "async": false,
862 | "body": Node {
863 | "end": 27,
864 | "name": "value",
865 | "start": 22,
866 | "type": "Identifier",
867 | },
868 | "end": 27,
869 | "expression": true,
870 | "generator": false,
871 | "id": null,
872 | "params": Array [
873 | Node {
874 | "end": 17,
875 | "properties": Array [
876 | Node {
877 | "computed": true,
878 | "end": 16,
879 | "key": Node {
880 | "end": 8,
881 | "name": "field",
882 | "start": 3,
883 | "type": "Identifier",
884 | },
885 | "kind": "init",
886 | "method": false,
887 | "shorthand": false,
888 | "start": 2,
889 | "type": "Property",
890 | "value": Node {
891 | "end": 16,
892 | "name": "value",
893 | "start": 11,
894 | "type": "Identifier",
895 | },
896 | },
897 | ],
898 | "start": 1,
899 | "type": "ObjectPattern",
900 | },
901 | ],
902 | "start": 0,
903 | "type": "ArrowFunctionExpression",
904 | },
905 | "end": 28,
906 | "fileAttachments": Map {},
907 | "generator": false,
908 | "id": null,
909 | "references": Array [
910 | Node {
911 | "end": 8,
912 | "name": "field",
913 | "start": 3,
914 | "type": "Identifier",
915 | },
916 | ],
917 | "start": 0,
918 | "type": "Cell",
919 | }
920 | `
921 |
922 | exports[`test/parse-test.js TAP parse destructured-arrow-with-default.js > must match snapshot 1`] = `
923 | Node {
924 | "async": false,
925 | "body": Node {
926 | "async": false,
927 | "body": Node {
928 | "body": Array [],
929 | "end": 31,
930 | "start": 29,
931 | "type": "BlockStatement",
932 | },
933 | "end": 31,
934 | "expression": false,
935 | "generator": false,
936 | "id": null,
937 | "params": Array [
938 | Node {
939 | "end": 24,
940 | "properties": Array [
941 | Node {
942 | "computed": false,
943 | "end": 23,
944 | "key": Node {
945 | "end": 11,
946 | "name": "foo",
947 | "start": 8,
948 | "type": "Identifier",
949 | },
950 | "kind": "init",
951 | "method": false,
952 | "shorthand": true,
953 | "start": 8,
954 | "type": "Property",
955 | "value": Node {
956 | "end": 23,
957 | "left": Node {
958 | "end": 11,
959 | "name": "foo",
960 | "start": 8,
961 | "type": "Identifier",
962 | },
963 | "right": Node {
964 | "end": 23,
965 | "raw": "\\"default\\"",
966 | "start": 14,
967 | "type": "Literal",
968 | "value": "default",
969 | },
970 | "start": 8,
971 | "type": "AssignmentPattern",
972 | },
973 | },
974 | ],
975 | "start": 7,
976 | "type": "ObjectPattern",
977 | },
978 | ],
979 | "start": 6,
980 | "type": "ArrowFunctionExpression",
981 | },
982 | "end": 32,
983 | "fileAttachments": Map {},
984 | "generator": false,
985 | "id": Node {
986 | "end": 3,
987 | "name": "fun",
988 | "start": 0,
989 | "type": "Identifier",
990 | },
991 | "references": Array [],
992 | "start": 0,
993 | "type": "Cell",
994 | }
995 | `
996 |
997 | exports[`test/parse-test.js TAP parse destructured-object-with-default.js > must match snapshot 1`] = `
998 | Node {
999 | "async": false,
1000 | "body": Node {
1001 | "async": false,
1002 | "body": Node {
1003 | "body": Array [],
1004 | "end": 34,
1005 | "start": 32,
1006 | "type": "BlockStatement",
1007 | },
1008 | "end": 34,
1009 | "expression": false,
1010 | "generator": false,
1011 | "id": Node {
1012 | "end": 12,
1013 | "name": "fun",
1014 | "start": 9,
1015 | "type": "Identifier",
1016 | },
1017 | "params": Array [
1018 | Node {
1019 | "end": 30,
1020 | "properties": Array [
1021 | Node {
1022 | "computed": false,
1023 | "end": 29,
1024 | "key": Node {
1025 | "end": 17,
1026 | "name": "foo",
1027 | "start": 14,
1028 | "type": "Identifier",
1029 | },
1030 | "kind": "init",
1031 | "method": false,
1032 | "shorthand": true,
1033 | "start": 14,
1034 | "type": "Property",
1035 | "value": Node {
1036 | "end": 29,
1037 | "left": Node {
1038 | "end": 17,
1039 | "name": "foo",
1040 | "start": 14,
1041 | "type": "Identifier",
1042 | },
1043 | "right": Node {
1044 | "end": 29,
1045 | "raw": "\\"default\\"",
1046 | "start": 20,
1047 | "type": "Literal",
1048 | "value": "default",
1049 | },
1050 | "start": 14,
1051 | "type": "AssignmentPattern",
1052 | },
1053 | },
1054 | ],
1055 | "start": 13,
1056 | "type": "ObjectPattern",
1057 | },
1058 | ],
1059 | "start": 0,
1060 | "type": "FunctionExpression",
1061 | },
1062 | "end": 35,
1063 | "fileAttachments": Map {},
1064 | "generator": false,
1065 | "id": Node {
1066 | "end": 12,
1067 | "name": "fun",
1068 | "start": 9,
1069 | "type": "Identifier",
1070 | },
1071 | "references": Array [],
1072 | "start": 0,
1073 | "type": "Cell",
1074 | }
1075 | `
1076 |
1077 | exports[`test/parse-test.js TAP parse dynamic-import.js > must match snapshot 1`] = `
1078 | Node {
1079 | "async": false,
1080 | "body": Node {
1081 | "end": 19,
1082 | "source": Node {
1083 | "end": 18,
1084 | "raw": "\\"bar\\"",
1085 | "start": 13,
1086 | "type": "Literal",
1087 | "value": "bar",
1088 | },
1089 | "start": 6,
1090 | "type": "ImportExpression",
1091 | },
1092 | "end": 20,
1093 | "fileAttachments": Map {},
1094 | "generator": false,
1095 | "id": Node {
1096 | "end": 3,
1097 | "name": "foo",
1098 | "start": 0,
1099 | "type": "Identifier",
1100 | },
1101 | "references": Array [],
1102 | "start": 0,
1103 | "type": "Cell",
1104 | }
1105 | `
1106 |
1107 | exports[`test/parse-test.js TAP parse empty.js > must match snapshot 1`] = `
1108 | Node {
1109 | "async": false,
1110 | "body": null,
1111 | "end": 0,
1112 | "fileAttachments": Map {},
1113 | "generator": false,
1114 | "id": null,
1115 | "start": 0,
1116 | "type": "Cell",
1117 | }
1118 | `
1119 |
1120 | exports[`test/parse-test.js TAP parse expression-extra.js > must match snapshot 1`] = `
1121 | Object {
1122 | "error": Object {
1123 | "loc": Object {
1124 | "column": 4,
1125 | "line": 1,
1126 | },
1127 | "message": "Unexpected token (1:4)",
1128 | "pos": 4,
1129 | "type": "SyntaxError",
1130 | },
1131 | }
1132 | `
1133 |
1134 | exports[`test/parse-test.js TAP parse expression-trailing-comment.js > must match snapshot 1`] = `
1135 | Node {
1136 | "async": false,
1137 | "body": Node {
1138 | "end": 8,
1139 | "raw": "42",
1140 | "start": 6,
1141 | "type": "Literal",
1142 | "value": 42,
1143 | },
1144 | "end": 28,
1145 | "fileAttachments": Map {},
1146 | "generator": false,
1147 | "id": Node {
1148 | "end": 3,
1149 | "name": "foo",
1150 | "start": 0,
1151 | "type": "Identifier",
1152 | },
1153 | "references": Array [],
1154 | "start": 0,
1155 | "type": "Cell",
1156 | }
1157 | `
1158 |
1159 | exports[`test/parse-test.js TAP parse extra-semicolon.js > must match snapshot 1`] = `
1160 | Node {
1161 | "async": false,
1162 | "body": Node {
1163 | "end": 8,
1164 | "raw": "42",
1165 | "start": 6,
1166 | "type": "Literal",
1167 | "value": 42,
1168 | },
1169 | "end": 10,
1170 | "fileAttachments": Map {},
1171 | "generator": false,
1172 | "id": Node {
1173 | "end": 3,
1174 | "name": "foo",
1175 | "start": 0,
1176 | "type": "Identifier",
1177 | },
1178 | "references": Array [],
1179 | "start": 0,
1180 | "type": "Cell",
1181 | }
1182 | `
1183 |
1184 | exports[`test/parse-test.js TAP parse file-attachment-forbidden-1.js > must match snapshot 1`] = `
1185 | Object {
1186 | "error": Object {
1187 | "loc": Object {
1188 | "column": 4,
1189 | "line": 1,
1190 | },
1191 | "message": "FileAttachment() requires a single literal string as its argument. (1:4)",
1192 | "pos": 4,
1193 | "type": "SyntaxError",
1194 | },
1195 | }
1196 | `
1197 |
1198 | exports[`test/parse-test.js TAP parse file-attachment-forbidden.js > must match snapshot 1`] = `
1199 | Object {
1200 | "error": Object {
1201 | "loc": Object {
1202 | "column": 4,
1203 | "line": 1,
1204 | },
1205 | "message": "FileAttachment() requires a single literal string as its argument. (1:4)",
1206 | "pos": 4,
1207 | "type": "SyntaxError",
1208 | },
1209 | }
1210 | `
1211 |
1212 | exports[`test/parse-test.js TAP parse file-attachment-nested.js > must match snapshot 1`] = `
1213 | Node {
1214 | "async": false,
1215 | "body": Node {
1216 | "body": Array [
1217 | Node {
1218 | "body": Node {
1219 | "body": Array [
1220 | Node {
1221 | "declarations": Array [
1222 | Node {
1223 | "end": 49,
1224 | "id": Node {
1225 | "end": 49,
1226 | "name": "b",
1227 | "start": 48,
1228 | "type": "Identifier",
1229 | },
1230 | "init": null,
1231 | "start": 48,
1232 | "type": "VariableDeclarator",
1233 | },
1234 | Node {
1235 | "end": 52,
1236 | "id": Node {
1237 | "end": 52,
1238 | "name": "c",
1239 | "start": 51,
1240 | "type": "Identifier",
1241 | },
1242 | "init": null,
1243 | "start": 51,
1244 | "type": "VariableDeclarator",
1245 | },
1246 | ],
1247 | "end": 53,
1248 | "kind": "let",
1249 | "start": 44,
1250 | "type": "VariableDeclaration",
1251 | },
1252 | Node {
1253 | "declarations": Array [
1254 | Node {
1255 | "end": 87,
1256 | "id": Node {
1257 | "end": 65,
1258 | "name": "a",
1259 | "start": 64,
1260 | "type": "Identifier",
1261 | },
1262 | "init": Node {
1263 | "arguments": Array [
1264 | Node {
1265 | "end": 86,
1266 | "raw": "\\"a\\"",
1267 | "start": 83,
1268 | "type": "Literal",
1269 | "value": "a",
1270 | },
1271 | ],
1272 | "callee": Node {
1273 | "end": 82,
1274 | "name": "FileAttachment",
1275 | "start": 68,
1276 | "type": "Identifier",
1277 | },
1278 | "end": 87,
1279 | "start": 68,
1280 | "type": "CallExpression",
1281 | },
1282 | "start": 64,
1283 | "type": "VariableDeclarator",
1284 | },
1285 | ],
1286 | "end": 88,
1287 | "kind": "const",
1288 | "start": 58,
1289 | "type": "VariableDeclaration",
1290 | },
1291 | Node {
1292 | "alternate": null,
1293 | "consequent": Node {
1294 | "body": Array [
1295 | Node {
1296 | "end": 173,
1297 | "expression": Node {
1298 | "end": 172,
1299 | "left": Node {
1300 | "end": 117,
1301 | "name": "b",
1302 | "start": 116,
1303 | "type": "Identifier",
1304 | },
1305 | "operator": "=",
1306 | "right": Node {
1307 | "alternate": Node {
1308 | "arguments": Array [
1309 | Node {
1310 | "end": 171,
1311 | "raw": "'b'",
1312 | "start": 168,
1313 | "type": "Literal",
1314 | "value": "b",
1315 | },
1316 | ],
1317 | "callee": Node {
1318 | "end": 167,
1319 | "name": "FileAttachment",
1320 | "start": 153,
1321 | "type": "Identifier",
1322 | },
1323 | "end": 172,
1324 | "start": 153,
1325 | "type": "CallExpression",
1326 | },
1327 | "consequent": Node {
1328 | "end": 150,
1329 | "name": "defaultFileValue",
1330 | "start": 134,
1331 | "type": "Identifier",
1332 | },
1333 | "end": 172,
1334 | "start": 120,
1335 | "test": Node {
1336 | "end": 131,
1337 | "name": "defaultFile",
1338 | "start": 120,
1339 | "type": "Identifier",
1340 | },
1341 | "type": "ConditionalExpression",
1342 | },
1343 | "start": 116,
1344 | "type": "AssignmentExpression",
1345 | },
1346 | "start": 116,
1347 | "type": "ExpressionStatement",
1348 | },
1349 | Node {
1350 | "end": 204,
1351 | "expression": Node {
1352 | "end": 203,
1353 | "left": Node {
1354 | "end": 181,
1355 | "name": "c",
1356 | "start": 180,
1357 | "type": "Identifier",
1358 | },
1359 | "operator": "=",
1360 | "right": Node {
1361 | "arguments": Array [
1362 | Node {
1363 | "end": 202,
1364 | "expressions": Array [],
1365 | "quasis": Array [
1366 | Node {
1367 | "end": 201,
1368 | "start": 200,
1369 | "tail": true,
1370 | "type": "TemplateElement",
1371 | "value": Object {
1372 | "cooked": "c",
1373 | "raw": "c",
1374 | },
1375 | },
1376 | ],
1377 | "start": 199,
1378 | "type": "TemplateLiteral",
1379 | },
1380 | ],
1381 | "callee": Node {
1382 | "end": 198,
1383 | "name": "FileAttachment",
1384 | "start": 184,
1385 | "type": "Identifier",
1386 | },
1387 | "end": 203,
1388 | "start": 184,
1389 | "type": "CallExpression",
1390 | },
1391 | "start": 180,
1392 | "type": "AssignmentExpression",
1393 | },
1394 | "start": 180,
1395 | "type": "ExpressionStatement",
1396 | },
1397 | ],
1398 | "end": 210,
1399 | "start": 108,
1400 | "type": "BlockStatement",
1401 | },
1402 | "end": 210,
1403 | "start": 93,
1404 | "test": Node {
1405 | "end": 106,
1406 | "name": "condition",
1407 | "start": 97,
1408 | "type": "Identifier",
1409 | },
1410 | "type": "IfStatement",
1411 | },
1412 | ],
1413 | "end": 214,
1414 | "start": 38,
1415 | "type": "BlockStatement",
1416 | },
1417 | "end": 214,
1418 | "start": 20,
1419 | "test": Node {
1420 | "end": 36,
1421 | "left": Node {
1422 | "end": 32,
1423 | "name": "count",
1424 | "start": 27,
1425 | "type": "Identifier",
1426 | },
1427 | "operator": ">",
1428 | "right": Node {
1429 | "end": 36,
1430 | "raw": "0",
1431 | "start": 35,
1432 | "type": "Literal",
1433 | "value": 0,
1434 | },
1435 | "start": 27,
1436 | "type": "BinaryExpression",
1437 | },
1438 | "type": "WhileStatement",
1439 | },
1440 | Node {
1441 | "argument": Node {
1442 | "arguments": Array [
1443 | Node {
1444 | "end": 231,
1445 | "name": "a",
1446 | "start": 230,
1447 | "type": "Identifier",
1448 | },
1449 | Node {
1450 | "end": 234,
1451 | "name": "b",
1452 | "start": 233,
1453 | "type": "Identifier",
1454 | },
1455 | Node {
1456 | "end": 237,
1457 | "name": "c",
1458 | "start": 236,
1459 | "type": "Identifier",
1460 | },
1461 | ],
1462 | "callee": Node {
1463 | "end": 229,
1464 | "name": "input",
1465 | "start": 224,
1466 | "type": "Identifier",
1467 | },
1468 | "end": 238,
1469 | "start": 224,
1470 | "type": "CallExpression",
1471 | },
1472 | "end": 239,
1473 | "start": 217,
1474 | "type": "ReturnStatement",
1475 | },
1476 | ],
1477 | "end": 241,
1478 | "start": 16,
1479 | "type": "BlockStatement",
1480 | },
1481 | "end": 242,
1482 | "fileAttachments": Map {
1483 | "a" => Array [
1484 | Object {
1485 | "end": 86,
1486 | "start": 83,
1487 | },
1488 | ],
1489 | "b" => Array [
1490 | Object {
1491 | "end": 171,
1492 | "start": 168,
1493 | },
1494 | ],
1495 | "c" => Array [
1496 | Object {
1497 | "end": 202,
1498 | "start": 199,
1499 | },
1500 | ],
1501 | },
1502 | "generator": false,
1503 | "id": Node {
1504 | "end": 13,
1505 | "id": Node {
1506 | "end": 13,
1507 | "name": "slider",
1508 | "start": 7,
1509 | "type": "Identifier",
1510 | },
1511 | "start": 0,
1512 | "type": "ViewExpression",
1513 | },
1514 | "references": Array [
1515 | Node {
1516 | "end": 32,
1517 | "name": "count",
1518 | "start": 27,
1519 | "type": "Identifier",
1520 | },
1521 | Node {
1522 | "end": 82,
1523 | "name": "FileAttachment",
1524 | "start": 68,
1525 | "type": "Identifier",
1526 | },
1527 | Node {
1528 | "end": 106,
1529 | "name": "condition",
1530 | "start": 97,
1531 | "type": "Identifier",
1532 | },
1533 | Node {
1534 | "end": 131,
1535 | "name": "defaultFile",
1536 | "start": 120,
1537 | "type": "Identifier",
1538 | },
1539 | Node {
1540 | "end": 150,
1541 | "name": "defaultFileValue",
1542 | "start": 134,
1543 | "type": "Identifier",
1544 | },
1545 | Node {
1546 | "end": 167,
1547 | "name": "FileAttachment",
1548 | "start": 153,
1549 | "type": "Identifier",
1550 | },
1551 | Node {
1552 | "end": 198,
1553 | "name": "FileAttachment",
1554 | "start": 184,
1555 | "type": "Identifier",
1556 | },
1557 | Node {
1558 | "end": 229,
1559 | "name": "input",
1560 | "start": 224,
1561 | "type": "Identifier",
1562 | },
1563 | Node {
1564 | "end": 231,
1565 | "name": "a",
1566 | "start": 230,
1567 | "type": "Identifier",
1568 | },
1569 | Node {
1570 | "end": 234,
1571 | "name": "b",
1572 | "start": 233,
1573 | "type": "Identifier",
1574 | },
1575 | Node {
1576 | "end": 237,
1577 | "name": "c",
1578 | "start": 236,
1579 | "type": "Identifier",
1580 | },
1581 | ],
1582 | "start": 0,
1583 | "type": "Cell",
1584 | }
1585 | `
1586 |
1587 | exports[`test/parse-test.js TAP parse file-attachment.js > must match snapshot 1`] = `
1588 | Node {
1589 | "async": false,
1590 | "body": Node {
1591 | "body": Array [
1592 | Node {
1593 | "declarations": Array [
1594 | Node {
1595 | "end": 31,
1596 | "id": Node {
1597 | "end": 9,
1598 | "name": "a",
1599 | "start": 8,
1600 | "type": "Identifier",
1601 | },
1602 | "init": Node {
1603 | "arguments": Array [
1604 | Node {
1605 | "end": 30,
1606 | "raw": "\\"a\\"",
1607 | "start": 27,
1608 | "type": "Literal",
1609 | "value": "a",
1610 | },
1611 | ],
1612 | "callee": Node {
1613 | "end": 26,
1614 | "name": "FileAttachment",
1615 | "start": 12,
1616 | "type": "Identifier",
1617 | },
1618 | "end": 31,
1619 | "start": 12,
1620 | "type": "CallExpression",
1621 | },
1622 | "start": 8,
1623 | "type": "VariableDeclarator",
1624 | },
1625 | ],
1626 | "end": 32,
1627 | "kind": "let",
1628 | "start": 4,
1629 | "type": "VariableDeclaration",
1630 | },
1631 | Node {
1632 | "declarations": Array [
1633 | Node {
1634 | "end": 62,
1635 | "id": Node {
1636 | "end": 40,
1637 | "name": "b",
1638 | "start": 39,
1639 | "type": "Identifier",
1640 | },
1641 | "init": Node {
1642 | "arguments": Array [
1643 | Node {
1644 | "end": 61,
1645 | "raw": "'b'",
1646 | "start": 58,
1647 | "type": "Literal",
1648 | "value": "b",
1649 | },
1650 | ],
1651 | "callee": Node {
1652 | "end": 57,
1653 | "name": "FileAttachment",
1654 | "start": 43,
1655 | "type": "Identifier",
1656 | },
1657 | "end": 62,
1658 | "start": 43,
1659 | "type": "CallExpression",
1660 | },
1661 | "start": 39,
1662 | "type": "VariableDeclarator",
1663 | },
1664 | ],
1665 | "end": 63,
1666 | "kind": "let",
1667 | "start": 35,
1668 | "type": "VariableDeclaration",
1669 | },
1670 | Node {
1671 | "declarations": Array [
1672 | Node {
1673 | "end": 93,
1674 | "id": Node {
1675 | "end": 71,
1676 | "name": "c",
1677 | "start": 70,
1678 | "type": "Identifier",
1679 | },
1680 | "init": Node {
1681 | "arguments": Array [
1682 | Node {
1683 | "end": 92,
1684 | "expressions": Array [],
1685 | "quasis": Array [
1686 | Node {
1687 | "end": 91,
1688 | "start": 90,
1689 | "tail": true,
1690 | "type": "TemplateElement",
1691 | "value": Object {
1692 | "cooked": "c",
1693 | "raw": "c",
1694 | },
1695 | },
1696 | ],
1697 | "start": 89,
1698 | "type": "TemplateLiteral",
1699 | },
1700 | ],
1701 | "callee": Node {
1702 | "end": 88,
1703 | "name": "FileAttachment",
1704 | "start": 74,
1705 | "type": "Identifier",
1706 | },
1707 | "end": 93,
1708 | "start": 74,
1709 | "type": "CallExpression",
1710 | },
1711 | "start": 70,
1712 | "type": "VariableDeclarator",
1713 | },
1714 | ],
1715 | "end": 94,
1716 | "kind": "let",
1717 | "start": 66,
1718 | "type": "VariableDeclaration",
1719 | },
1720 | Node {
1721 | "declarations": Array [
1722 | Node {
1723 | "end": 125,
1724 | "id": Node {
1725 | "end": 103,
1726 | "name": "c2",
1727 | "start": 101,
1728 | "type": "Identifier",
1729 | },
1730 | "init": Node {
1731 | "arguments": Array [
1732 | Node {
1733 | "end": 124,
1734 | "raw": "\\"c\\"",
1735 | "start": 121,
1736 | "type": "Literal",
1737 | "value": "c",
1738 | },
1739 | ],
1740 | "callee": Node {
1741 | "end": 120,
1742 | "name": "FileAttachment",
1743 | "start": 106,
1744 | "type": "Identifier",
1745 | },
1746 | "end": 125,
1747 | "start": 106,
1748 | "type": "CallExpression",
1749 | },
1750 | "start": 101,
1751 | "type": "VariableDeclarator",
1752 | },
1753 | ],
1754 | "end": 126,
1755 | "kind": "let",
1756 | "start": 97,
1757 | "type": "VariableDeclaration",
1758 | },
1759 | ],
1760 | "end": 128,
1761 | "start": 0,
1762 | "type": "BlockStatement",
1763 | },
1764 | "end": 129,
1765 | "fileAttachments": Map {
1766 | "a" => Array [
1767 | Object {
1768 | "end": 30,
1769 | "start": 27,
1770 | },
1771 | ],
1772 | "b" => Array [
1773 | Object {
1774 | "end": 61,
1775 | "start": 58,
1776 | },
1777 | ],
1778 | "c" => Array [
1779 | Object {
1780 | "end": 92,
1781 | "start": 89,
1782 | },
1783 | Object {
1784 | "end": 124,
1785 | "start": 121,
1786 | },
1787 | ],
1788 | },
1789 | "generator": false,
1790 | "id": null,
1791 | "references": Array [
1792 | Node {
1793 | "end": 26,
1794 | "name": "FileAttachment",
1795 | "start": 12,
1796 | "type": "Identifier",
1797 | },
1798 | Node {
1799 | "end": 57,
1800 | "name": "FileAttachment",
1801 | "start": 43,
1802 | "type": "Identifier",
1803 | },
1804 | Node {
1805 | "end": 88,
1806 | "name": "FileAttachment",
1807 | "start": 74,
1808 | "type": "Identifier",
1809 | },
1810 | Node {
1811 | "end": 120,
1812 | "name": "FileAttachment",
1813 | "start": 106,
1814 | "type": "Identifier",
1815 | },
1816 | ],
1817 | "start": 0,
1818 | "type": "Cell",
1819 | }
1820 | `
1821 |
1822 | exports[`test/parse-test.js TAP parse for-await-generator.js > must match snapshot 1`] = `
1823 | Node {
1824 | "async": true,
1825 | "body": Node {
1826 | "body": Array [
1827 | Node {
1828 | "await": true,
1829 | "body": Node {
1830 | "body": Array [
1831 | Node {
1832 | "end": 55,
1833 | "expression": Node {
1834 | "argument": Node {
1835 | "end": 54,
1836 | "name": "value",
1837 | "start": 49,
1838 | "type": "Identifier",
1839 | },
1840 | "delegate": false,
1841 | "end": 54,
1842 | "start": 43,
1843 | "type": "YieldExpression",
1844 | },
1845 | "start": 43,
1846 | "type": "ExpressionStatement",
1847 | },
1848 | ],
1849 | "end": 59,
1850 | "start": 37,
1851 | "type": "BlockStatement",
1852 | },
1853 | "end": 59,
1854 | "left": Node {
1855 | "declarations": Array [
1856 | Node {
1857 | "end": 26,
1858 | "id": Node {
1859 | "end": 26,
1860 | "name": "value",
1861 | "start": 21,
1862 | "type": "Identifier",
1863 | },
1864 | "init": null,
1865 | "start": 21,
1866 | "type": "VariableDeclarator",
1867 | },
1868 | ],
1869 | "end": 26,
1870 | "kind": "const",
1871 | "start": 15,
1872 | "type": "VariableDeclaration",
1873 | },
1874 | "right": Node {
1875 | "arguments": Array [],
1876 | "callee": Node {
1877 | "end": 33,
1878 | "name": "foo",
1879 | "start": 30,
1880 | "type": "Identifier",
1881 | },
1882 | "end": 35,
1883 | "start": 30,
1884 | "type": "CallExpression",
1885 | },
1886 | "start": 4,
1887 | "type": "ForOfStatement",
1888 | },
1889 | ],
1890 | "end": 61,
1891 | "start": 0,
1892 | "type": "BlockStatement",
1893 | },
1894 | "end": 62,
1895 | "fileAttachments": Map {},
1896 | "generator": true,
1897 | "id": null,
1898 | "references": Array [
1899 | Node {
1900 | "end": 33,
1901 | "name": "foo",
1902 | "start": 30,
1903 | "type": "Identifier",
1904 | },
1905 | ],
1906 | "start": 0,
1907 | "type": "Cell",
1908 | }
1909 | `
1910 |
1911 | exports[`test/parse-test.js TAP parse for-await-in-function.js > must match snapshot 1`] = `
1912 | Node {
1913 | "async": false,
1914 | "body": Node {
1915 | "async": true,
1916 | "body": Node {
1917 | "body": Array [
1918 | Node {
1919 | "declarations": Array [
1920 | Node {
1921 | "end": 42,
1922 | "id": Node {
1923 | "end": 37,
1924 | "name": "values",
1925 | "start": 31,
1926 | "type": "Identifier",
1927 | },
1928 | "init": Node {
1929 | "elements": Array [],
1930 | "end": 42,
1931 | "start": 40,
1932 | "type": "ArrayExpression",
1933 | },
1934 | "start": 31,
1935 | "type": "VariableDeclarator",
1936 | },
1937 | ],
1938 | "end": 43,
1939 | "kind": "const",
1940 | "start": 25,
1941 | "type": "VariableDeclaration",
1942 | },
1943 | Node {
1944 | "await": true,
1945 | "body": Node {
1946 | "body": Array [
1947 | Node {
1948 | "end": 104,
1949 | "expression": Node {
1950 | "arguments": Array [
1951 | Node {
1952 | "end": 102,
1953 | "name": "value",
1954 | "start": 97,
1955 | "type": "Identifier",
1956 | },
1957 | ],
1958 | "callee": Node {
1959 | "computed": false,
1960 | "end": 96,
1961 | "object": Node {
1962 | "end": 91,
1963 | "name": "values",
1964 | "start": 85,
1965 | "type": "Identifier",
1966 | },
1967 | "property": Node {
1968 | "end": 96,
1969 | "name": "push",
1970 | "start": 92,
1971 | "type": "Identifier",
1972 | },
1973 | "start": 85,
1974 | "type": "MemberExpression",
1975 | },
1976 | "end": 103,
1977 | "start": 85,
1978 | "type": "CallExpression",
1979 | },
1980 | "start": 85,
1981 | "type": "ExpressionStatement",
1982 | },
1983 | ],
1984 | "end": 108,
1985 | "start": 79,
1986 | "type": "BlockStatement",
1987 | },
1988 | "end": 108,
1989 | "left": Node {
1990 | "declarations": Array [
1991 | Node {
1992 | "end": 68,
1993 | "id": Node {
1994 | "end": 68,
1995 | "name": "value",
1996 | "start": 63,
1997 | "type": "Identifier",
1998 | },
1999 | "init": null,
2000 | "start": 63,
2001 | "type": "VariableDeclarator",
2002 | },
2003 | ],
2004 | "end": 68,
2005 | "kind": "const",
2006 | "start": 57,
2007 | "type": "VariableDeclaration",
2008 | },
2009 | "right": Node {
2010 | "arguments": Array [],
2011 | "callee": Node {
2012 | "end": 75,
2013 | "name": "foo",
2014 | "start": 72,
2015 | "type": "Identifier",
2016 | },
2017 | "end": 77,
2018 | "start": 72,
2019 | "type": "CallExpression",
2020 | },
2021 | "start": 46,
2022 | "type": "ForOfStatement",
2023 | },
2024 | Node {
2025 | "argument": Node {
2026 | "end": 124,
2027 | "name": "values",
2028 | "start": 118,
2029 | "type": "Identifier",
2030 | },
2031 | "end": 125,
2032 | "start": 111,
2033 | "type": "ReturnStatement",
2034 | },
2035 | ],
2036 | "end": 127,
2037 | "start": 21,
2038 | "type": "BlockStatement",
2039 | },
2040 | "end": 127,
2041 | "expression": false,
2042 | "generator": false,
2043 | "id": Node {
2044 | "end": 18,
2045 | "name": "bar",
2046 | "start": 15,
2047 | "type": "Identifier",
2048 | },
2049 | "params": Array [],
2050 | "start": 0,
2051 | "type": "FunctionExpression",
2052 | },
2053 | "end": 128,
2054 | "fileAttachments": Map {},
2055 | "generator": false,
2056 | "id": Node {
2057 | "end": 18,
2058 | "name": "bar",
2059 | "start": 15,
2060 | "type": "Identifier",
2061 | },
2062 | "references": Array [
2063 | Node {
2064 | "end": 75,
2065 | "name": "foo",
2066 | "start": 72,
2067 | "type": "Identifier",
2068 | },
2069 | ],
2070 | "start": 0,
2071 | "type": "Cell",
2072 | }
2073 | `
2074 |
2075 | exports[`test/parse-test.js TAP parse for-await.js > must match snapshot 1`] = `
2076 | Node {
2077 | "async": true,
2078 | "body": Node {
2079 | "body": Array [
2080 | Node {
2081 | "declarations": Array [
2082 | Node {
2083 | "end": 21,
2084 | "id": Node {
2085 | "end": 16,
2086 | "name": "values",
2087 | "start": 10,
2088 | "type": "Identifier",
2089 | },
2090 | "init": Node {
2091 | "elements": Array [],
2092 | "end": 21,
2093 | "start": 19,
2094 | "type": "ArrayExpression",
2095 | },
2096 | "start": 10,
2097 | "type": "VariableDeclarator",
2098 | },
2099 | ],
2100 | "end": 22,
2101 | "kind": "const",
2102 | "start": 4,
2103 | "type": "VariableDeclaration",
2104 | },
2105 | Node {
2106 | "await": true,
2107 | "body": Node {
2108 | "body": Array [
2109 | Node {
2110 | "end": 83,
2111 | "expression": Node {
2112 | "arguments": Array [
2113 | Node {
2114 | "end": 81,
2115 | "name": "value",
2116 | "start": 76,
2117 | "type": "Identifier",
2118 | },
2119 | ],
2120 | "callee": Node {
2121 | "computed": false,
2122 | "end": 75,
2123 | "object": Node {
2124 | "end": 70,
2125 | "name": "values",
2126 | "start": 64,
2127 | "type": "Identifier",
2128 | },
2129 | "property": Node {
2130 | "end": 75,
2131 | "name": "push",
2132 | "start": 71,
2133 | "type": "Identifier",
2134 | },
2135 | "start": 64,
2136 | "type": "MemberExpression",
2137 | },
2138 | "end": 82,
2139 | "start": 64,
2140 | "type": "CallExpression",
2141 | },
2142 | "start": 64,
2143 | "type": "ExpressionStatement",
2144 | },
2145 | ],
2146 | "end": 87,
2147 | "start": 58,
2148 | "type": "BlockStatement",
2149 | },
2150 | "end": 87,
2151 | "left": Node {
2152 | "declarations": Array [
2153 | Node {
2154 | "end": 47,
2155 | "id": Node {
2156 | "end": 47,
2157 | "name": "value",
2158 | "start": 42,
2159 | "type": "Identifier",
2160 | },
2161 | "init": null,
2162 | "start": 42,
2163 | "type": "VariableDeclarator",
2164 | },
2165 | ],
2166 | "end": 47,
2167 | "kind": "const",
2168 | "start": 36,
2169 | "type": "VariableDeclaration",
2170 | },
2171 | "right": Node {
2172 | "arguments": Array [],
2173 | "callee": Node {
2174 | "end": 54,
2175 | "name": "foo",
2176 | "start": 51,
2177 | "type": "Identifier",
2178 | },
2179 | "end": 56,
2180 | "start": 51,
2181 | "type": "CallExpression",
2182 | },
2183 | "start": 25,
2184 | "type": "ForOfStatement",
2185 | },
2186 | Node {
2187 | "argument": Node {
2188 | "end": 103,
2189 | "name": "values",
2190 | "start": 97,
2191 | "type": "Identifier",
2192 | },
2193 | "end": 104,
2194 | "start": 90,
2195 | "type": "ReturnStatement",
2196 | },
2197 | ],
2198 | "end": 106,
2199 | "start": 0,
2200 | "type": "BlockStatement",
2201 | },
2202 | "end": 107,
2203 | "fileAttachments": Map {},
2204 | "generator": false,
2205 | "id": null,
2206 | "references": Array [
2207 | Node {
2208 | "end": 54,
2209 | "name": "foo",
2210 | "start": 51,
2211 | "type": "Identifier",
2212 | },
2213 | ],
2214 | "start": 0,
2215 | "type": "Cell",
2216 | }
2217 | `
2218 |
2219 | exports[`test/parse-test.js TAP parse global-assignment.js > must match snapshot 1`] = `
2220 | Object {
2221 | "error": Object {
2222 | "loc": Object {
2223 | "column": 2,
2224 | "line": 2,
2225 | },
2226 | "message": "Assignment to constant variable foo (2:2)",
2227 | "pos": 4,
2228 | "type": "SyntaxError",
2229 | },
2230 | }
2231 | `
2232 |
2233 | exports[`test/parse-test.js TAP parse illegal-arguments.js > must match snapshot 1`] = `
2234 | Object {
2235 | "error": Object {
2236 | "loc": Object {
2237 | "column": 4,
2238 | "line": 1,
2239 | },
2240 | "message": "arguments is not allowed (1:4)",
2241 | "pos": 4,
2242 | "type": "SyntaxError",
2243 | },
2244 | }
2245 | `
2246 |
2247 | exports[`test/parse-test.js TAP parse illegal-arrow-arguments.js > must match snapshot 1`] = `
2248 | Object {
2249 | "error": Object {
2250 | "loc": Object {
2251 | "column": 6,
2252 | "line": 1,
2253 | },
2254 | "message": "arguments is not allowed (1:6)",
2255 | "pos": 6,
2256 | "type": "SyntaxError",
2257 | },
2258 | }
2259 | `
2260 |
2261 | exports[`test/parse-test.js TAP parse import-as-duplicate.js > must match snapshot 1`] = `
2262 | Object {
2263 | "error": Object {
2264 | "loc": Object {
2265 | "column": 20,
2266 | "line": 1,
2267 | },
2268 | "message": "Identifier 'foo' has already been declared (1:20)",
2269 | "pos": 20,
2270 | "type": "SyntaxError",
2271 | },
2272 | }
2273 | `
2274 |
2275 | exports[`test/parse-test.js TAP parse import-default-as.js > must match snapshot 1`] = `
2276 | Object {
2277 | "error": Object {
2278 | "loc": Object {
2279 | "column": 8,
2280 | "line": 1,
2281 | },
2282 | "message": "Unexpected keyword 'default' (1:8)",
2283 | "pos": 8,
2284 | "type": "SyntaxError",
2285 | },
2286 | }
2287 | `
2288 |
2289 | exports[`test/parse-test.js TAP parse import-default.js > must match snapshot 1`] = `
2290 | Object {
2291 | "error": Object {
2292 | "loc": Object {
2293 | "column": 7,
2294 | "line": 1,
2295 | },
2296 | "message": "Unexpected token (1:7)",
2297 | "pos": 7,
2298 | "type": "SyntaxError",
2299 | },
2300 | }
2301 | `
2302 |
2303 | exports[`test/parse-test.js TAP parse import-duplicate.js > must match snapshot 1`] = `
2304 | Object {
2305 | "error": Object {
2306 | "loc": Object {
2307 | "column": 13,
2308 | "line": 1,
2309 | },
2310 | "message": "Identifier 'foo' has already been declared (1:13)",
2311 | "pos": 13,
2312 | "type": "SyntaxError",
2313 | },
2314 | }
2315 | `
2316 |
2317 | exports[`test/parse-test.js TAP parse import-empty.js > must match snapshot 1`] = `
2318 | Node {
2319 | "async": false,
2320 | "body": Node {
2321 | "end": 23,
2322 | "source": Node {
2323 | "end": 23,
2324 | "raw": "\\"module\\"",
2325 | "start": 15,
2326 | "type": "Literal",
2327 | "value": "module",
2328 | },
2329 | "specifiers": Array [],
2330 | "start": 0,
2331 | "type": "ImportDeclaration",
2332 | },
2333 | "end": 24,
2334 | "fileAttachments": Map {},
2335 | "generator": false,
2336 | "id": null,
2337 | "start": 0,
2338 | "type": "Cell",
2339 | }
2340 | `
2341 |
2342 | exports[`test/parse-test.js TAP parse import-extra.js > must match snapshot 1`] = `
2343 | Object {
2344 | "error": Object {
2345 | "loc": Object {
2346 | "column": 39,
2347 | "line": 1,
2348 | },
2349 | "message": "Unexpected token (1:39)",
2350 | "pos": 39,
2351 | "type": "SyntaxError",
2352 | },
2353 | }
2354 | `
2355 |
2356 | exports[`test/parse-test.js TAP parse import-mutable-as.js > must match snapshot 1`] = `
2357 | Node {
2358 | "async": false,
2359 | "body": Node {
2360 | "end": 41,
2361 | "source": Node {
2362 | "end": 41,
2363 | "raw": "\\"module\\"",
2364 | "start": 33,
2365 | "type": "Literal",
2366 | "value": "module",
2367 | },
2368 | "specifiers": Array [
2369 | Node {
2370 | "end": 26,
2371 | "imported": Node {
2372 | "end": 19,
2373 | "name": "foo",
2374 | "start": 16,
2375 | "type": "Identifier",
2376 | },
2377 | "local": Node {
2378 | "end": 26,
2379 | "name": "bar",
2380 | "start": 23,
2381 | "type": "Identifier",
2382 | },
2383 | "mutable": true,
2384 | "start": 8,
2385 | "type": "ImportSpecifier",
2386 | "view": false,
2387 | },
2388 | ],
2389 | "start": 0,
2390 | "type": "ImportDeclaration",
2391 | },
2392 | "end": 42,
2393 | "fileAttachments": Map {},
2394 | "generator": false,
2395 | "id": null,
2396 | "start": 0,
2397 | "type": "Cell",
2398 | }
2399 | `
2400 |
2401 | exports[`test/parse-test.js TAP parse import-mutable.js > must match snapshot 1`] = `
2402 | Node {
2403 | "async": false,
2404 | "body": Node {
2405 | "end": 34,
2406 | "source": Node {
2407 | "end": 34,
2408 | "raw": "\\"module\\"",
2409 | "start": 26,
2410 | "type": "Literal",
2411 | "value": "module",
2412 | },
2413 | "specifiers": Array [
2414 | Node {
2415 | "end": 19,
2416 | "imported": Node {
2417 | "end": 19,
2418 | "name": "foo",
2419 | "start": 16,
2420 | "type": "Identifier",
2421 | },
2422 | "local": Node {
2423 | "end": 19,
2424 | "name": "foo",
2425 | "start": 16,
2426 | "type": "Identifier",
2427 | },
2428 | "mutable": true,
2429 | "start": 8,
2430 | "type": "ImportSpecifier",
2431 | "view": false,
2432 | },
2433 | ],
2434 | "start": 0,
2435 | "type": "ImportDeclaration",
2436 | },
2437 | "end": 35,
2438 | "fileAttachments": Map {},
2439 | "generator": false,
2440 | "id": null,
2441 | "start": 0,
2442 | "type": "Cell",
2443 | }
2444 | `
2445 |
2446 | exports[`test/parse-test.js TAP parse import-semicolon.js > must match snapshot 1`] = `
2447 | Node {
2448 | "async": false,
2449 | "body": Node {
2450 | "end": 38,
2451 | "source": Node {
2452 | "end": 38,
2453 | "raw": "\\"module\\"",
2454 | "start": 30,
2455 | "type": "Literal",
2456 | "value": "module",
2457 | },
2458 | "specifiers": Array [
2459 | Node {
2460 | "end": 11,
2461 | "imported": Node {
2462 | "end": 11,
2463 | "name": "foo",
2464 | "start": 8,
2465 | "type": "Identifier",
2466 | },
2467 | "local": Node {
2468 | "end": 11,
2469 | "name": "foo",
2470 | "start": 8,
2471 | "type": "Identifier",
2472 | },
2473 | "mutable": false,
2474 | "start": 8,
2475 | "type": "ImportSpecifier",
2476 | "view": false,
2477 | },
2478 | Node {
2479 | "end": 23,
2480 | "imported": Node {
2481 | "end": 16,
2482 | "name": "bar",
2483 | "start": 13,
2484 | "type": "Identifier",
2485 | },
2486 | "local": Node {
2487 | "end": 23,
2488 | "name": "baz",
2489 | "start": 20,
2490 | "type": "Identifier",
2491 | },
2492 | "mutable": false,
2493 | "start": 13,
2494 | "type": "ImportSpecifier",
2495 | "view": false,
2496 | },
2497 | ],
2498 | "start": 0,
2499 | "type": "ImportDeclaration",
2500 | },
2501 | "end": 40,
2502 | "fileAttachments": Map {},
2503 | "generator": false,
2504 | "id": null,
2505 | "start": 0,
2506 | "type": "Cell",
2507 | }
2508 | `
2509 |
2510 | exports[`test/parse-test.js TAP parse import-side-effect.js > must match snapshot 1`] = `
2511 | Object {
2512 | "error": Object {
2513 | "loc": Object {
2514 | "column": 7,
2515 | "line": 1,
2516 | },
2517 | "message": "Unexpected token (1:7)",
2518 | "pos": 7,
2519 | "type": "SyntaxError",
2520 | },
2521 | }
2522 | `
2523 |
2524 | exports[`test/parse-test.js TAP parse import-viewof-as.js > must match snapshot 1`] = `
2525 | Node {
2526 | "async": false,
2527 | "body": Node {
2528 | "end": 40,
2529 | "source": Node {
2530 | "end": 40,
2531 | "raw": "\\"module\\"",
2532 | "start": 32,
2533 | "type": "Literal",
2534 | "value": "module",
2535 | },
2536 | "specifiers": Array [
2537 | Node {
2538 | "end": 25,
2539 | "imported": Node {
2540 | "end": 18,
2541 | "name": "foo",
2542 | "start": 15,
2543 | "type": "Identifier",
2544 | },
2545 | "local": Node {
2546 | "end": 25,
2547 | "name": "bar",
2548 | "start": 22,
2549 | "type": "Identifier",
2550 | },
2551 | "start": 8,
2552 | "type": "ImportSpecifier",
2553 | "view": true,
2554 | },
2555 | ],
2556 | "start": 0,
2557 | "type": "ImportDeclaration",
2558 | },
2559 | "end": 41,
2560 | "fileAttachments": Map {},
2561 | "generator": false,
2562 | "id": null,
2563 | "start": 0,
2564 | "type": "Cell",
2565 | }
2566 | `
2567 |
2568 | exports[`test/parse-test.js TAP parse import-viewof.js > must match snapshot 1`] = `
2569 | Node {
2570 | "async": false,
2571 | "body": Node {
2572 | "end": 33,
2573 | "source": Node {
2574 | "end": 33,
2575 | "raw": "\\"module\\"",
2576 | "start": 25,
2577 | "type": "Literal",
2578 | "value": "module",
2579 | },
2580 | "specifiers": Array [
2581 | Node {
2582 | "end": 18,
2583 | "imported": Node {
2584 | "end": 18,
2585 | "name": "foo",
2586 | "start": 15,
2587 | "type": "Identifier",
2588 | },
2589 | "local": Node {
2590 | "end": 18,
2591 | "name": "foo",
2592 | "start": 15,
2593 | "type": "Identifier",
2594 | },
2595 | "start": 8,
2596 | "type": "ImportSpecifier",
2597 | "view": true,
2598 | },
2599 | ],
2600 | "start": 0,
2601 | "type": "ImportDeclaration",
2602 | },
2603 | "end": 34,
2604 | "fileAttachments": Map {},
2605 | "generator": false,
2606 | "id": null,
2607 | "start": 0,
2608 | "type": "Cell",
2609 | }
2610 | `
2611 |
2612 | exports[`test/parse-test.js TAP parse import-with-as-duplicate.js > must match snapshot 1`] = `
2613 | Object {
2614 | "error": Object {
2615 | "loc": Object {
2616 | "column": 28,
2617 | "line": 1,
2618 | },
2619 | "message": "Identifier 'foo' has already been declared (1:28)",
2620 | "pos": 28,
2621 | "type": "SyntaxError",
2622 | },
2623 | }
2624 | `
2625 |
2626 | exports[`test/parse-test.js TAP parse import-with-default-as.js > must match snapshot 1`] = `
2627 | Object {
2628 | "error": Object {
2629 | "loc": Object {
2630 | "column": 26,
2631 | "line": 1,
2632 | },
2633 | "message": "Unexpected keyword 'default' (1:26)",
2634 | "pos": 26,
2635 | "type": "SyntaxError",
2636 | },
2637 | }
2638 | `
2639 |
2640 | exports[`test/parse-test.js TAP parse import-with-default.js > must match snapshot 1`] = `
2641 | Object {
2642 | "error": Object {
2643 | "loc": Object {
2644 | "column": 19,
2645 | "line": 1,
2646 | },
2647 | "message": "Unexpected keyword 'default' (1:19)",
2648 | "pos": 19,
2649 | "type": "SyntaxError",
2650 | },
2651 | }
2652 | `
2653 |
2654 | exports[`test/parse-test.js TAP parse import-with-duplicate.js > must match snapshot 1`] = `
2655 | Object {
2656 | "error": Object {
2657 | "loc": Object {
2658 | "column": 21,
2659 | "line": 1,
2660 | },
2661 | "message": "Identifier 'foo' has already been declared (1:21)",
2662 | "pos": 21,
2663 | "type": "SyntaxError",
2664 | },
2665 | }
2666 | `
2667 |
2668 | exports[`test/parse-test.js TAP parse import-with-empty.js > must match snapshot 1`] = `
2669 | Node {
2670 | "async": false,
2671 | "body": Node {
2672 | "end": 34,
2673 | "injections": Array [],
2674 | "source": Node {
2675 | "end": 34,
2676 | "raw": "\\"module\\"",
2677 | "start": 26,
2678 | "type": "Literal",
2679 | "value": "module",
2680 | },
2681 | "specifiers": Array [
2682 | Node {
2683 | "end": 11,
2684 | "imported": Node {
2685 | "end": 11,
2686 | "name": "foo",
2687 | "start": 8,
2688 | "type": "Identifier",
2689 | },
2690 | "local": Node {
2691 | "end": 11,
2692 | "name": "foo",
2693 | "start": 8,
2694 | "type": "Identifier",
2695 | },
2696 | "mutable": false,
2697 | "start": 8,
2698 | "type": "ImportSpecifier",
2699 | "view": false,
2700 | },
2701 | ],
2702 | "start": 0,
2703 | "type": "ImportDeclaration",
2704 | },
2705 | "end": 35,
2706 | "fileAttachments": Map {},
2707 | "generator": false,
2708 | "id": null,
2709 | "start": 0,
2710 | "type": "Cell",
2711 | }
2712 | `
2713 |
2714 | exports[`test/parse-test.js TAP parse import-with.js > must match snapshot 1`] = `
2715 | Node {
2716 | "async": false,
2717 | "body": Node {
2718 | "end": 44,
2719 | "injections": Array [
2720 | Node {
2721 | "end": 29,
2722 | "imported": Node {
2723 | "end": 22,
2724 | "name": "bar",
2725 | "start": 19,
2726 | "type": "Identifier",
2727 | },
2728 | "local": Node {
2729 | "end": 29,
2730 | "name": "baz",
2731 | "start": 26,
2732 | "type": "Identifier",
2733 | },
2734 | "mutable": false,
2735 | "start": 19,
2736 | "type": "ImportSpecifier",
2737 | "view": false,
2738 | },
2739 | ],
2740 | "source": Node {
2741 | "end": 44,
2742 | "raw": "\\"module\\"",
2743 | "start": 36,
2744 | "type": "Literal",
2745 | "value": "module",
2746 | },
2747 | "specifiers": Array [
2748 | Node {
2749 | "end": 11,
2750 | "imported": Node {
2751 | "end": 11,
2752 | "name": "foo",
2753 | "start": 8,
2754 | "type": "Identifier",
2755 | },
2756 | "local": Node {
2757 | "end": 11,
2758 | "name": "foo",
2759 | "start": 8,
2760 | "type": "Identifier",
2761 | },
2762 | "mutable": false,
2763 | "start": 8,
2764 | "type": "ImportSpecifier",
2765 | "view": false,
2766 | },
2767 | ],
2768 | "start": 0,
2769 | "type": "ImportDeclaration",
2770 | },
2771 | "end": 45,
2772 | "fileAttachments": Map {},
2773 | "generator": false,
2774 | "id": null,
2775 | "start": 0,
2776 | "type": "Cell",
2777 | }
2778 | `
2779 |
2780 | exports[`test/parse-test.js TAP parse import.js > must match snapshot 1`] = `
2781 | Node {
2782 | "async": false,
2783 | "body": Node {
2784 | "end": 38,
2785 | "source": Node {
2786 | "end": 38,
2787 | "raw": "\\"module\\"",
2788 | "start": 30,
2789 | "type": "Literal",
2790 | "value": "module",
2791 | },
2792 | "specifiers": Array [
2793 | Node {
2794 | "end": 11,
2795 | "imported": Node {
2796 | "end": 11,
2797 | "name": "foo",
2798 | "start": 8,
2799 | "type": "Identifier",
2800 | },
2801 | "local": Node {
2802 | "end": 11,
2803 | "name": "foo",
2804 | "start": 8,
2805 | "type": "Identifier",
2806 | },
2807 | "mutable": false,
2808 | "start": 8,
2809 | "type": "ImportSpecifier",
2810 | "view": false,
2811 | },
2812 | Node {
2813 | "end": 23,
2814 | "imported": Node {
2815 | "end": 16,
2816 | "name": "bar",
2817 | "start": 13,
2818 | "type": "Identifier",
2819 | },
2820 | "local": Node {
2821 | "end": 23,
2822 | "name": "baz",
2823 | "start": 20,
2824 | "type": "Identifier",
2825 | },
2826 | "mutable": false,
2827 | "start": 13,
2828 | "type": "ImportSpecifier",
2829 | "view": false,
2830 | },
2831 | ],
2832 | "start": 0,
2833 | "type": "ImportDeclaration",
2834 | },
2835 | "end": 39,
2836 | "fileAttachments": Map {},
2837 | "generator": false,
2838 | "id": null,
2839 | "start": 0,
2840 | "type": "Cell",
2841 | }
2842 | `
2843 |
2844 | exports[`test/parse-test.js TAP parse leading-semicolon.js > must match snapshot 1`] = `
2845 | Object {
2846 | "error": Object {
2847 | "loc": Object {
2848 | "column": 1,
2849 | "line": 1,
2850 | },
2851 | "message": "Unexpected token (1:1)",
2852 | "pos": 1,
2853 | "type": "SyntaxError",
2854 | },
2855 | }
2856 | `
2857 |
2858 | exports[`test/parse-test.js TAP parse legal-arguments.js > must match snapshot 1`] = `
2859 | Node {
2860 | "async": false,
2861 | "body": Node {
2862 | "async": false,
2863 | "body": Node {
2864 | "body": Array [
2865 | Node {
2866 | "argument": Node {
2867 | "computed": false,
2868 | "end": 36,
2869 | "object": Node {
2870 | "end": 29,
2871 | "name": "arguments",
2872 | "start": 20,
2873 | "type": "Identifier",
2874 | },
2875 | "property": Node {
2876 | "end": 36,
2877 | "name": "length",
2878 | "start": 30,
2879 | "type": "Identifier",
2880 | },
2881 | "start": 20,
2882 | "type": "MemberExpression",
2883 | },
2884 | "end": 37,
2885 | "start": 13,
2886 | "type": "ReturnStatement",
2887 | },
2888 | ],
2889 | "end": 39,
2890 | "start": 11,
2891 | "type": "BlockStatement",
2892 | },
2893 | "end": 39,
2894 | "expression": false,
2895 | "generator": false,
2896 | "id": null,
2897 | "params": Array [],
2898 | "start": 0,
2899 | "type": "FunctionExpression",
2900 | },
2901 | "end": 40,
2902 | "fileAttachments": Map {},
2903 | "generator": false,
2904 | "id": null,
2905 | "references": Array [],
2906 | "start": 0,
2907 | "type": "Cell",
2908 | }
2909 | `
2910 |
2911 | exports[`test/parse-test.js TAP parse member-assignment.js > must match snapshot 1`] = `
2912 | Node {
2913 | "async": false,
2914 | "body": Node {
2915 | "end": 14,
2916 | "left": Node {
2917 | "computed": false,
2918 | "end": 10,
2919 | "object": Node {
2920 | "end": 6,
2921 | "name": "window",
2922 | "start": 0,
2923 | "type": "Identifier",
2924 | },
2925 | "property": Node {
2926 | "end": 10,
2927 | "name": "foo",
2928 | "start": 7,
2929 | "type": "Identifier",
2930 | },
2931 | "start": 0,
2932 | "type": "MemberExpression",
2933 | },
2934 | "operator": "=",
2935 | "right": Node {
2936 | "end": 14,
2937 | "raw": "2",
2938 | "start": 13,
2939 | "type": "Literal",
2940 | "value": 2,
2941 | },
2942 | "start": 0,
2943 | "type": "AssignmentExpression",
2944 | },
2945 | "end": 15,
2946 | "fileAttachments": Map {},
2947 | "generator": false,
2948 | "id": null,
2949 | "references": Array [
2950 | Node {
2951 | "end": 6,
2952 | "name": "window",
2953 | "start": 0,
2954 | "type": "Identifier",
2955 | },
2956 | ],
2957 | "start": 0,
2958 | "type": "Cell",
2959 | }
2960 | `
2961 |
2962 | exports[`test/parse-test.js TAP parse multiple-input-references.js > must match snapshot 1`] = `
2963 | Node {
2964 | "async": false,
2965 | "body": Node {
2966 | "body": Array [
2967 | Node {
2968 | "declarations": Array [
2969 | Node {
2970 | "end": 28,
2971 | "id": Node {
2972 | "end": 20,
2973 | "name": "sum",
2974 | "start": 17,
2975 | "type": "Identifier",
2976 | },
2977 | "init": Node {
2978 | "end": 28,
2979 | "left": Node {
2980 | "end": 24,
2981 | "name": "a",
2982 | "start": 23,
2983 | "type": "Identifier",
2984 | },
2985 | "operator": "+",
2986 | "right": Node {
2987 | "end": 28,
2988 | "name": "b",
2989 | "start": 27,
2990 | "type": "Identifier",
2991 | },
2992 | "start": 23,
2993 | "type": "BinaryExpression",
2994 | },
2995 | "start": 17,
2996 | "type": "VariableDeclarator",
2997 | },
2998 | ],
2999 | "end": 29,
3000 | "kind": "const",
3001 | "start": 11,
3002 | "type": "VariableDeclaration",
3003 | },
3004 | Node {
3005 | "declarations": Array [
3006 | Node {
3007 | "end": 53,
3008 | "id": Node {
3009 | "end": 45,
3010 | "name": "product",
3011 | "start": 38,
3012 | "type": "Identifier",
3013 | },
3014 | "init": Node {
3015 | "end": 53,
3016 | "left": Node {
3017 | "end": 49,
3018 | "name": "a",
3019 | "start": 48,
3020 | "type": "Identifier",
3021 | },
3022 | "operator": "*",
3023 | "right": Node {
3024 | "end": 53,
3025 | "name": "b",
3026 | "start": 52,
3027 | "type": "Identifier",
3028 | },
3029 | "start": 48,
3030 | "type": "BinaryExpression",
3031 | },
3032 | "start": 38,
3033 | "type": "VariableDeclarator",
3034 | },
3035 | ],
3036 | "end": 54,
3037 | "kind": "const",
3038 | "start": 32,
3039 | "type": "VariableDeclaration",
3040 | },
3041 | Node {
3042 | "declarations": Array [
3043 | Node {
3044 | "end": 81,
3045 | "id": Node {
3046 | "end": 73,
3047 | "name": "difference",
3048 | "start": 63,
3049 | "type": "Identifier",
3050 | },
3051 | "init": Node {
3052 | "end": 81,
3053 | "left": Node {
3054 | "end": 77,
3055 | "name": "a",
3056 | "start": 76,
3057 | "type": "Identifier",
3058 | },
3059 | "operator": "-",
3060 | "right": Node {
3061 | "end": 81,
3062 | "name": "b",
3063 | "start": 80,
3064 | "type": "Identifier",
3065 | },
3066 | "start": 76,
3067 | "type": "BinaryExpression",
3068 | },
3069 | "start": 63,
3070 | "type": "VariableDeclarator",
3071 | },
3072 | ],
3073 | "end": 82,
3074 | "kind": "const",
3075 | "start": 57,
3076 | "type": "VariableDeclaration",
3077 | },
3078 | Node {
3079 | "argument": Node {
3080 | "end": 118,
3081 | "properties": Array [
3082 | Node {
3083 | "computed": false,
3084 | "end": 96,
3085 | "key": Node {
3086 | "end": 96,
3087 | "name": "sum",
3088 | "start": 93,
3089 | "type": "Identifier",
3090 | },
3091 | "kind": "init",
3092 | "method": false,
3093 | "shorthand": true,
3094 | "start": 93,
3095 | "type": "Property",
3096 | "value": Node {
3097 | "end": 96,
3098 | "name": "sum",
3099 | "start": 93,
3100 | "type": "Identifier",
3101 | },
3102 | },
3103 | Node {
3104 | "computed": false,
3105 | "end": 105,
3106 | "key": Node {
3107 | "end": 105,
3108 | "name": "product",
3109 | "start": 98,
3110 | "type": "Identifier",
3111 | },
3112 | "kind": "init",
3113 | "method": false,
3114 | "shorthand": true,
3115 | "start": 98,
3116 | "type": "Property",
3117 | "value": Node {
3118 | "end": 105,
3119 | "name": "product",
3120 | "start": 98,
3121 | "type": "Identifier",
3122 | },
3123 | },
3124 | Node {
3125 | "computed": false,
3126 | "end": 117,
3127 | "key": Node {
3128 | "end": 117,
3129 | "name": "difference",
3130 | "start": 107,
3131 | "type": "Identifier",
3132 | },
3133 | "kind": "init",
3134 | "method": false,
3135 | "shorthand": true,
3136 | "start": 107,
3137 | "type": "Property",
3138 | "value": Node {
3139 | "end": 117,
3140 | "name": "difference",
3141 | "start": 107,
3142 | "type": "Identifier",
3143 | },
3144 | },
3145 | ],
3146 | "start": 92,
3147 | "type": "ObjectExpression",
3148 | },
3149 | "end": 119,
3150 | "start": 85,
3151 | "type": "ReturnStatement",
3152 | },
3153 | ],
3154 | "end": 121,
3155 | "start": 7,
3156 | "type": "BlockStatement",
3157 | },
3158 | "end": 122,
3159 | "fileAttachments": Map {},
3160 | "generator": false,
3161 | "id": Node {
3162 | "end": 4,
3163 | "name": "cell",
3164 | "start": 0,
3165 | "type": "Identifier",
3166 | },
3167 | "references": Array [
3168 | Node {
3169 | "end": 24,
3170 | "name": "a",
3171 | "start": 23,
3172 | "type": "Identifier",
3173 | },
3174 | Node {
3175 | "end": 28,
3176 | "name": "b",
3177 | "start": 27,
3178 | "type": "Identifier",
3179 | },
3180 | Node {
3181 | "end": 49,
3182 | "name": "a",
3183 | "start": 48,
3184 | "type": "Identifier",
3185 | },
3186 | Node {
3187 | "end": 53,
3188 | "name": "b",
3189 | "start": 52,
3190 | "type": "Identifier",
3191 | },
3192 | Node {
3193 | "end": 77,
3194 | "name": "a",
3195 | "start": 76,
3196 | "type": "Identifier",
3197 | },
3198 | Node {
3199 | "end": 81,
3200 | "name": "b",
3201 | "start": 80,
3202 | "type": "Identifier",
3203 | },
3204 | ],
3205 | "start": 0,
3206 | "type": "Cell",
3207 | }
3208 | `
3209 |
3210 | exports[`test/parse-test.js TAP parse mutable-argument.js > must match snapshot 1`] = `
3211 | Object {
3212 | "error": Object {
3213 | "loc": Object {
3214 | "column": 12,
3215 | "line": 1,
3216 | },
3217 | "message": "Unexpected keyword 'mutable' (1:12)",
3218 | "pos": 12,
3219 | "type": "SyntaxError",
3220 | },
3221 | }
3222 | `
3223 |
3224 | exports[`test/parse-test.js TAP parse mutable-as-property.js > must match snapshot 1`] = `
3225 | Node {
3226 | "async": false,
3227 | "body": Node {
3228 | "end": 23,
3229 | "left": Node {
3230 | "computed": true,
3231 | "end": 19,
3232 | "object": Node {
3233 | "end": 6,
3234 | "name": "object",
3235 | "start": 0,
3236 | "type": "Identifier",
3237 | },
3238 | "property": Node {
3239 | "end": 18,
3240 | "id": Node {
3241 | "end": 18,
3242 | "name": "foo",
3243 | "start": 15,
3244 | "type": "Identifier",
3245 | },
3246 | "start": 7,
3247 | "type": "MutableExpression",
3248 | },
3249 | "start": 0,
3250 | "type": "MemberExpression",
3251 | },
3252 | "operator": "+",
3253 | "right": Node {
3254 | "end": 23,
3255 | "raw": "1",
3256 | "start": 22,
3257 | "type": "Literal",
3258 | "value": 1,
3259 | },
3260 | "start": 0,
3261 | "type": "BinaryExpression",
3262 | },
3263 | "end": 24,
3264 | "fileAttachments": Map {},
3265 | "generator": false,
3266 | "id": null,
3267 | "references": Array [
3268 | Node {
3269 | "end": 6,
3270 | "name": "object",
3271 | "start": 0,
3272 | "type": "Identifier",
3273 | },
3274 | Node {
3275 | "end": 18,
3276 | "id": Node {
3277 | "end": 18,
3278 | "name": "foo",
3279 | "start": 15,
3280 | "type": "Identifier",
3281 | },
3282 | "start": 7,
3283 | "type": "MutableExpression",
3284 | },
3285 | ],
3286 | "start": 0,
3287 | "type": "Cell",
3288 | }
3289 | `
3290 |
3291 | exports[`test/parse-test.js TAP parse mutable-assign-default.js > must match snapshot 1`] = `
3292 | Node {
3293 | "async": true,
3294 | "body": Node {
3295 | "argument": Node {
3296 | "arguments": Array [
3297 | Node {
3298 | "end": 42,
3299 | "name": "config",
3300 | "start": 36,
3301 | "type": "Identifier",
3302 | },
3303 | ],
3304 | "callee": Node {
3305 | "computed": false,
3306 | "end": 35,
3307 | "object": Node {
3308 | "end": 29,
3309 | "name": "Service",
3310 | "start": 22,
3311 | "type": "Identifier",
3312 | },
3313 | "property": Node {
3314 | "end": 35,
3315 | "name": "fetch",
3316 | "start": 30,
3317 | "type": "Identifier",
3318 | },
3319 | "start": 22,
3320 | "type": "MemberExpression",
3321 | },
3322 | "end": 43,
3323 | "start": 22,
3324 | "type": "CallExpression",
3325 | },
3326 | "end": 43,
3327 | "start": 16,
3328 | "type": "AwaitExpression",
3329 | },
3330 | "end": 44,
3331 | "fileAttachments": Map {},
3332 | "generator": false,
3333 | "id": Node {
3334 | "end": 13,
3335 | "id": Node {
3336 | "end": 13,
3337 | "name": "state",
3338 | "start": 8,
3339 | "type": "Identifier",
3340 | },
3341 | "start": 0,
3342 | "type": "MutableExpression",
3343 | },
3344 | "references": Array [
3345 | Node {
3346 | "end": 29,
3347 | "name": "Service",
3348 | "start": 22,
3349 | "type": "Identifier",
3350 | },
3351 | Node {
3352 | "end": 42,
3353 | "name": "config",
3354 | "start": 36,
3355 | "type": "Identifier",
3356 | },
3357 | ],
3358 | "start": 0,
3359 | "type": "Cell",
3360 | }
3361 | `
3362 |
3363 | exports[`test/parse-test.js TAP parse mutable-assignment.js > must match snapshot 1`] = `
3364 | Node {
3365 | "async": false,
3366 | "body": Node {
3367 | "body": Array [
3368 | Node {
3369 | "end": 24,
3370 | "expression": Node {
3371 | "end": 23,
3372 | "left": Node {
3373 | "end": 17,
3374 | "id": Node {
3375 | "end": 17,
3376 | "name": "value",
3377 | "start": 12,
3378 | "type": "Identifier",
3379 | },
3380 | "start": 4,
3381 | "type": "MutableExpression",
3382 | },
3383 | "operator": "=",
3384 | "right": Node {
3385 | "end": 23,
3386 | "raw": "101",
3387 | "start": 20,
3388 | "type": "Literal",
3389 | "value": 101,
3390 | },
3391 | "start": 4,
3392 | "type": "AssignmentExpression",
3393 | },
3394 | "start": 4,
3395 | "type": "ExpressionStatement",
3396 | },
3397 | ],
3398 | "end": 26,
3399 | "start": 0,
3400 | "type": "BlockStatement",
3401 | },
3402 | "end": 27,
3403 | "fileAttachments": Map {},
3404 | "generator": false,
3405 | "id": null,
3406 | "references": Array [
3407 | Node {
3408 | "end": 17,
3409 | "id": Node {
3410 | "end": 17,
3411 | "name": "value",
3412 | "start": 12,
3413 | "type": "Identifier",
3414 | },
3415 | "start": 4,
3416 | "type": "MutableExpression",
3417 | },
3418 | ],
3419 | "start": 0,
3420 | "type": "Cell",
3421 | }
3422 | `
3423 |
3424 | exports[`test/parse-test.js TAP parse mutable-block-cell.js > must match snapshot 1`] = `
3425 | Node {
3426 | "async": false,
3427 | "body": Node {
3428 | "body": Array [
3429 | Node {
3430 | "argument": Node {
3431 | "end": 37,
3432 | "properties": Array [
3433 | Node {
3434 | "computed": false,
3435 | "end": 30,
3436 | "key": Node {
3437 | "end": 27,
3438 | "name": "x",
3439 | "start": 26,
3440 | "type": "Identifier",
3441 | },
3442 | "kind": "init",
3443 | "method": false,
3444 | "shorthand": false,
3445 | "start": 26,
3446 | "type": "Property",
3447 | "value": Node {
3448 | "end": 30,
3449 | "raw": "0",
3450 | "start": 29,
3451 | "type": "Literal",
3452 | "value": 0,
3453 | },
3454 | },
3455 | Node {
3456 | "computed": false,
3457 | "end": 36,
3458 | "key": Node {
3459 | "end": 33,
3460 | "name": "y",
3461 | "start": 32,
3462 | "type": "Identifier",
3463 | },
3464 | "kind": "init",
3465 | "method": false,
3466 | "shorthand": false,
3467 | "start": 32,
3468 | "type": "Property",
3469 | "value": Node {
3470 | "end": 36,
3471 | "raw": "0",
3472 | "start": 35,
3473 | "type": "Literal",
3474 | "value": 0,
3475 | },
3476 | },
3477 | ],
3478 | "start": 25,
3479 | "type": "ObjectExpression",
3480 | },
3481 | "end": 38,
3482 | "start": 18,
3483 | "type": "ReturnStatement",
3484 | },
3485 | ],
3486 | "end": 40,
3487 | "start": 14,
3488 | "type": "BlockStatement",
3489 | },
3490 | "end": 41,
3491 | "fileAttachments": Map {},
3492 | "generator": false,
3493 | "id": Node {
3494 | "end": 11,
3495 | "id": Node {
3496 | "end": 11,
3497 | "name": "foo",
3498 | "start": 8,
3499 | "type": "Identifier",
3500 | },
3501 | "start": 0,
3502 | "type": "MutableExpression",
3503 | },
3504 | "references": Array [],
3505 | "start": 0,
3506 | "type": "Cell",
3507 | }
3508 | `
3509 |
3510 | exports[`test/parse-test.js TAP parse mutable-constant.js > must match snapshot 1`] = `
3511 | Object {
3512 | "error": Object {
3513 | "loc": Object {
3514 | "column": 8,
3515 | "line": 1,
3516 | },
3517 | "message": "Unexpected token (1:8)",
3518 | "pos": 8,
3519 | "type": "SyntaxError",
3520 | },
3521 | }
3522 | `
3523 |
3524 | exports[`test/parse-test.js TAP parse mutable-default-value.js > must match snapshot 1`] = `
3525 | Node {
3526 | "async": false,
3527 | "body": Node {
3528 | "async": false,
3529 | "body": Node {
3530 | "body": Array [
3531 | Node {
3532 | "argument": Node {
3533 | "end": 39,
3534 | "name": "y",
3535 | "start": 38,
3536 | "type": "Identifier",
3537 | },
3538 | "end": 40,
3539 | "start": 31,
3540 | "type": "ReturnStatement",
3541 | },
3542 | ],
3543 | "end": 42,
3544 | "start": 27,
3545 | "type": "BlockStatement",
3546 | },
3547 | "end": 42,
3548 | "expression": false,
3549 | "generator": false,
3550 | "id": Node {
3551 | "end": 11,
3552 | "name": "fn",
3553 | "start": 9,
3554 | "type": "Identifier",
3555 | },
3556 | "params": Array [
3557 | Node {
3558 | "end": 25,
3559 | "left": Node {
3560 | "end": 13,
3561 | "name": "y",
3562 | "start": 12,
3563 | "type": "Identifier",
3564 | },
3565 | "right": Node {
3566 | "end": 25,
3567 | "id": Node {
3568 | "end": 25,
3569 | "name": "x",
3570 | "start": 24,
3571 | "type": "Identifier",
3572 | },
3573 | "start": 16,
3574 | "type": "MutableExpression",
3575 | },
3576 | "start": 12,
3577 | "type": "AssignmentPattern",
3578 | },
3579 | ],
3580 | "start": 0,
3581 | "type": "FunctionExpression",
3582 | },
3583 | "end": 43,
3584 | "fileAttachments": Map {},
3585 | "generator": false,
3586 | "id": Node {
3587 | "end": 11,
3588 | "name": "fn",
3589 | "start": 9,
3590 | "type": "Identifier",
3591 | },
3592 | "references": Array [
3593 | Node {
3594 | "end": 25,
3595 | "id": Node {
3596 | "end": 25,
3597 | "name": "x",
3598 | "start": 24,
3599 | "type": "Identifier",
3600 | },
3601 | "start": 16,
3602 | "type": "MutableExpression",
3603 | },
3604 | ],
3605 | "start": 0,
3606 | "type": "Cell",
3607 | }
3608 | `
3609 |
3610 | exports[`test/parse-test.js TAP parse mutable-destructure-array.js > must match snapshot 1`] = `
3611 | Node {
3612 | "async": false,
3613 | "body": Node {
3614 | "end": 19,
3615 | "left": Node {
3616 | "elements": Array [
3617 | Node {
3618 | "end": 11,
3619 | "id": Node {
3620 | "end": 11,
3621 | "name": "x",
3622 | "start": 10,
3623 | "type": "Identifier",
3624 | },
3625 | "start": 2,
3626 | "type": "MutableExpression",
3627 | },
3628 | ],
3629 | "end": 12,
3630 | "start": 1,
3631 | "type": "ArrayPattern",
3632 | },
3633 | "operator": "=",
3634 | "right": Node {
3635 | "elements": Array [
3636 | Node {
3637 | "end": 18,
3638 | "raw": "42",
3639 | "start": 16,
3640 | "type": "Literal",
3641 | "value": 42,
3642 | },
3643 | ],
3644 | "end": 19,
3645 | "start": 15,
3646 | "type": "ArrayExpression",
3647 | },
3648 | "start": 1,
3649 | "type": "AssignmentExpression",
3650 | },
3651 | "end": 21,
3652 | "fileAttachments": Map {},
3653 | "generator": false,
3654 | "id": null,
3655 | "references": Array [
3656 | Node {
3657 | "end": 11,
3658 | "id": Node {
3659 | "end": 11,
3660 | "name": "x",
3661 | "start": 10,
3662 | "type": "Identifier",
3663 | },
3664 | "start": 2,
3665 | "type": "MutableExpression",
3666 | },
3667 | ],
3668 | "start": 0,
3669 | "type": "Cell",
3670 | }
3671 | `
3672 |
3673 | exports[`test/parse-test.js TAP parse mutable-destructure-object.js > must match snapshot 1`] = `
3674 | Node {
3675 | "async": false,
3676 | "body": Node {
3677 | "end": 42,
3678 | "left": Node {
3679 | "end": 22,
3680 | "properties": Array [
3681 | Node {
3682 | "computed": false,
3683 | "end": 21,
3684 | "key": Node {
3685 | "end": 10,
3686 | "name": "property",
3687 | "start": 2,
3688 | "type": "Identifier",
3689 | },
3690 | "kind": "init",
3691 | "method": false,
3692 | "shorthand": false,
3693 | "start": 2,
3694 | "type": "Property",
3695 | "value": Node {
3696 | "end": 21,
3697 | "id": Node {
3698 | "end": 21,
3699 | "name": "x",
3700 | "start": 20,
3701 | "type": "Identifier",
3702 | },
3703 | "start": 12,
3704 | "type": "MutableExpression",
3705 | },
3706 | },
3707 | ],
3708 | "start": 1,
3709 | "type": "ObjectPattern",
3710 | },
3711 | "operator": "=",
3712 | "right": Node {
3713 | "end": 42,
3714 | "properties": Array [
3715 | Node {
3716 | "computed": false,
3717 | "end": 41,
3718 | "key": Node {
3719 | "end": 34,
3720 | "name": "property",
3721 | "start": 26,
3722 | "type": "Identifier",
3723 | },
3724 | "kind": "init",
3725 | "method": false,
3726 | "shorthand": false,
3727 | "start": 26,
3728 | "type": "Property",
3729 | "value": Node {
3730 | "end": 41,
3731 | "name": "value",
3732 | "start": 36,
3733 | "type": "Identifier",
3734 | },
3735 | },
3736 | ],
3737 | "start": 25,
3738 | "type": "ObjectExpression",
3739 | },
3740 | "start": 1,
3741 | "type": "AssignmentExpression",
3742 | },
3743 | "end": 44,
3744 | "fileAttachments": Map {},
3745 | "generator": false,
3746 | "id": null,
3747 | "references": Array [
3748 | Node {
3749 | "end": 21,
3750 | "id": Node {
3751 | "end": 21,
3752 | "name": "x",
3753 | "start": 20,
3754 | "type": "Identifier",
3755 | },
3756 | "start": 12,
3757 | "type": "MutableExpression",
3758 | },
3759 | Node {
3760 | "end": 41,
3761 | "name": "value",
3762 | "start": 36,
3763 | "type": "Identifier",
3764 | },
3765 | ],
3766 | "start": 0,
3767 | "type": "Cell",
3768 | }
3769 | `
3770 |
3771 | exports[`test/parse-test.js TAP parse mutable-destructure-property.js > must match snapshot 1`] = `
3772 | Object {
3773 | "error": Object {
3774 | "loc": Object {
3775 | "column": 2,
3776 | "line": 1,
3777 | },
3778 | "message": "Unexpected keyword 'mutable' (1:2)",
3779 | "pos": 2,
3780 | "type": "SyntaxError",
3781 | },
3782 | }
3783 | `
3784 |
3785 | exports[`test/parse-test.js TAP parse mutable-internal-comment.js > must match snapshot 1`] = `
3786 | Node {
3787 | "async": false,
3788 | "body": Node {
3789 | "end": 27,
3790 | "id": Node {
3791 | "end": 27,
3792 | "name": "value",
3793 | "start": 22,
3794 | "type": "Identifier",
3795 | },
3796 | "start": 0,
3797 | "type": "MutableExpression",
3798 | },
3799 | "end": 28,
3800 | "fileAttachments": Map {},
3801 | "generator": false,
3802 | "id": null,
3803 | "references": Array [
3804 | Node {
3805 | "end": 27,
3806 | "id": Node {
3807 | "end": 27,
3808 | "name": "value",
3809 | "start": 22,
3810 | "type": "Identifier",
3811 | },
3812 | "start": 0,
3813 | "type": "MutableExpression",
3814 | },
3815 | ],
3816 | "start": 0,
3817 | "type": "Cell",
3818 | }
3819 | `
3820 |
3821 | exports[`test/parse-test.js TAP parse mutable-member.js > must match snapshot 1`] = `
3822 | Object {
3823 | "error": Object {
3824 | "loc": Object {
3825 | "column": 15,
3826 | "line": 1,
3827 | },
3828 | "message": "Unexpected token (1:15)",
3829 | "pos": 15,
3830 | "type": "SyntaxError",
3831 | },
3832 | }
3833 | `
3834 |
3835 | exports[`test/parse-test.js TAP parse mutable-reference.js > must match snapshot 1`] = `
3836 | Node {
3837 | "async": false,
3838 | "body": Node {
3839 | "computed": false,
3840 | "end": 22,
3841 | "object": Node {
3842 | "end": 13,
3843 | "id": Node {
3844 | "end": 13,
3845 | "name": "value",
3846 | "start": 8,
3847 | "type": "Identifier",
3848 | },
3849 | "start": 0,
3850 | "type": "MutableExpression",
3851 | },
3852 | "property": Node {
3853 | "end": 22,
3854 | "name": "property",
3855 | "start": 14,
3856 | "type": "Identifier",
3857 | },
3858 | "start": 0,
3859 | "type": "MemberExpression",
3860 | },
3861 | "end": 23,
3862 | "fileAttachments": Map {},
3863 | "generator": false,
3864 | "id": null,
3865 | "references": Array [
3866 | Node {
3867 | "end": 13,
3868 | "id": Node {
3869 | "end": 13,
3870 | "name": "value",
3871 | "start": 8,
3872 | "type": "Identifier",
3873 | },
3874 | "start": 0,
3875 | "type": "MutableExpression",
3876 | },
3877 | ],
3878 | "start": 0,
3879 | "type": "Cell",
3880 | }
3881 | `
3882 |
3883 | exports[`test/parse-test.js TAP parse mutable-var.js > must match snapshot 1`] = `
3884 | Object {
3885 | "error": Object {
3886 | "loc": Object {
3887 | "column": 6,
3888 | "line": 2,
3889 | },
3890 | "message": "Unexpected keyword 'mutable' (2:6)",
3891 | "pos": 8,
3892 | "type": "SyntaxError",
3893 | },
3894 | }
3895 | `
3896 |
3897 | exports[`test/parse-test.js TAP parse named-async-function.js > must match snapshot 1`] = `
3898 | Node {
3899 | "async": false,
3900 | "body": Node {
3901 | "async": true,
3902 | "body": Node {
3903 | "body": Array [
3904 | Node {
3905 | "end": 37,
3906 | "expression": Node {
3907 | "argument": Node {
3908 | "end": 36,
3909 | "name": "promise",
3910 | "start": 29,
3911 | "type": "Identifier",
3912 | },
3913 | "end": 36,
3914 | "start": 23,
3915 | "type": "AwaitExpression",
3916 | },
3917 | "start": 23,
3918 | "type": "ExpressionStatement",
3919 | },
3920 | ],
3921 | "end": 39,
3922 | "start": 21,
3923 | "type": "BlockStatement",
3924 | },
3925 | "end": 39,
3926 | "expression": false,
3927 | "generator": false,
3928 | "id": Node {
3929 | "end": 18,
3930 | "name": "foo",
3931 | "start": 15,
3932 | "type": "Identifier",
3933 | },
3934 | "params": Array [],
3935 | "start": 0,
3936 | "type": "FunctionExpression",
3937 | },
3938 | "end": 40,
3939 | "fileAttachments": Map {},
3940 | "generator": false,
3941 | "id": Node {
3942 | "end": 18,
3943 | "name": "foo",
3944 | "start": 15,
3945 | "type": "Identifier",
3946 | },
3947 | "references": Array [
3948 | Node {
3949 | "end": 36,
3950 | "name": "promise",
3951 | "start": 29,
3952 | "type": "Identifier",
3953 | },
3954 | ],
3955 | "start": 0,
3956 | "type": "Cell",
3957 | }
3958 | `
3959 |
3960 | exports[`test/parse-test.js TAP parse named-block-cell.js > must match snapshot 1`] = `
3961 | Node {
3962 | "async": false,
3963 | "body": Node {
3964 | "body": Array [
3965 | Node {
3966 | "argument": Node {
3967 | "end": 19,
3968 | "raw": "42",
3969 | "start": 17,
3970 | "type": "Literal",
3971 | "value": 42,
3972 | },
3973 | "end": 20,
3974 | "start": 10,
3975 | "type": "ReturnStatement",
3976 | },
3977 | ],
3978 | "end": 22,
3979 | "start": 6,
3980 | "type": "BlockStatement",
3981 | },
3982 | "end": 23,
3983 | "fileAttachments": Map {},
3984 | "generator": false,
3985 | "id": Node {
3986 | "end": 3,
3987 | "name": "foo",
3988 | "start": 0,
3989 | "type": "Identifier",
3990 | },
3991 | "references": Array [],
3992 | "start": 0,
3993 | "type": "Cell",
3994 | }
3995 | `
3996 |
3997 | exports[`test/parse-test.js TAP parse named-class.js > must match snapshot 1`] = `
3998 | Node {
3999 | "async": false,
4000 | "body": Node {
4001 | "body": Node {
4002 | "body": Array [],
4003 | "end": 12,
4004 | "start": 10,
4005 | "type": "ClassBody",
4006 | },
4007 | "end": 12,
4008 | "id": Node {
4009 | "end": 9,
4010 | "name": "Foo",
4011 | "start": 6,
4012 | "type": "Identifier",
4013 | },
4014 | "start": 0,
4015 | "superClass": null,
4016 | "type": "ClassExpression",
4017 | },
4018 | "end": 13,
4019 | "fileAttachments": Map {},
4020 | "generator": false,
4021 | "id": Node {
4022 | "end": 9,
4023 | "name": "Foo",
4024 | "start": 6,
4025 | "type": "Identifier",
4026 | },
4027 | "references": Array [],
4028 | "start": 0,
4029 | "type": "Cell",
4030 | }
4031 | `
4032 |
4033 | exports[`test/parse-test.js TAP parse named-empty.js > must match snapshot 1`] = `
4034 | Object {
4035 | "error": Object {
4036 | "loc": Object {
4037 | "column": 0,
4038 | "line": 2,
4039 | },
4040 | "message": "Unexpected end of input (2:0)",
4041 | "pos": 6,
4042 | "type": "SyntaxError",
4043 | },
4044 | }
4045 | `
4046 |
4047 | exports[`test/parse-test.js TAP parse named-expression-cell.js > must match snapshot 1`] = `
4048 | Node {
4049 | "async": false,
4050 | "body": Node {
4051 | "end": 8,
4052 | "raw": "42",
4053 | "start": 6,
4054 | "type": "Literal",
4055 | "value": 42,
4056 | },
4057 | "end": 9,
4058 | "fileAttachments": Map {},
4059 | "generator": false,
4060 | "id": Node {
4061 | "end": 3,
4062 | "name": "foo",
4063 | "start": 0,
4064 | "type": "Identifier",
4065 | },
4066 | "references": Array [],
4067 | "start": 0,
4068 | "type": "Cell",
4069 | }
4070 | `
4071 |
4072 | exports[`test/parse-test.js TAP parse named-function-in-named-cell.js > must match snapshot 1`] = `
4073 | Node {
4074 | "async": false,
4075 | "body": Node {
4076 | "async": false,
4077 | "body": Node {
4078 | "body": Array [
4079 | Node {
4080 | "argument": Node {
4081 | "end": 32,
4082 | "raw": "42",
4083 | "start": 30,
4084 | "type": "Literal",
4085 | "value": 42,
4086 | },
4087 | "end": 33,
4088 | "start": 23,
4089 | "type": "ReturnStatement",
4090 | },
4091 | ],
4092 | "end": 35,
4093 | "start": 21,
4094 | "type": "BlockStatement",
4095 | },
4096 | "end": 35,
4097 | "expression": false,
4098 | "generator": false,
4099 | "id": Node {
4100 | "end": 18,
4101 | "name": "bar",
4102 | "start": 15,
4103 | "type": "Identifier",
4104 | },
4105 | "params": Array [],
4106 | "start": 6,
4107 | "type": "FunctionExpression",
4108 | },
4109 | "end": 36,
4110 | "fileAttachments": Map {},
4111 | "generator": false,
4112 | "id": Node {
4113 | "end": 3,
4114 | "name": "foo",
4115 | "start": 0,
4116 | "type": "Identifier",
4117 | },
4118 | "references": Array [],
4119 | "start": 0,
4120 | "type": "Cell",
4121 | }
4122 | `
4123 |
4124 | exports[`test/parse-test.js TAP parse named-function.js > must match snapshot 1`] = `
4125 | Node {
4126 | "async": false,
4127 | "body": Node {
4128 | "async": false,
4129 | "body": Node {
4130 | "body": Array [
4131 | Node {
4132 | "argument": Node {
4133 | "end": 26,
4134 | "raw": "42",
4135 | "start": 24,
4136 | "type": "Literal",
4137 | "value": 42,
4138 | },
4139 | "end": 27,
4140 | "start": 17,
4141 | "type": "ReturnStatement",
4142 | },
4143 | ],
4144 | "end": 29,
4145 | "start": 15,
4146 | "type": "BlockStatement",
4147 | },
4148 | "end": 29,
4149 | "expression": false,
4150 | "generator": false,
4151 | "id": Node {
4152 | "end": 12,
4153 | "name": "foo",
4154 | "start": 9,
4155 | "type": "Identifier",
4156 | },
4157 | "params": Array [],
4158 | "start": 0,
4159 | "type": "FunctionExpression",
4160 | },
4161 | "end": 30,
4162 | "fileAttachments": Map {},
4163 | "generator": false,
4164 | "id": Node {
4165 | "end": 12,
4166 | "name": "foo",
4167 | "start": 9,
4168 | "type": "Identifier",
4169 | },
4170 | "references": Array [],
4171 | "start": 0,
4172 | "type": "Cell",
4173 | }
4174 | `
4175 |
4176 | exports[`test/parse-test.js TAP parse named-generator-function.js > must match snapshot 1`] = `
4177 | Node {
4178 | "async": false,
4179 | "body": Node {
4180 | "async": false,
4181 | "body": Node {
4182 | "body": Array [
4183 | Node {
4184 | "end": 27,
4185 | "expression": Node {
4186 | "argument": Node {
4187 | "end": 26,
4188 | "raw": "42",
4189 | "start": 24,
4190 | "type": "Literal",
4191 | "value": 42,
4192 | },
4193 | "delegate": false,
4194 | "end": 26,
4195 | "start": 18,
4196 | "type": "YieldExpression",
4197 | },
4198 | "start": 18,
4199 | "type": "ExpressionStatement",
4200 | },
4201 | ],
4202 | "end": 29,
4203 | "start": 16,
4204 | "type": "BlockStatement",
4205 | },
4206 | "end": 29,
4207 | "expression": false,
4208 | "generator": true,
4209 | "id": Node {
4210 | "end": 13,
4211 | "name": "foo",
4212 | "start": 10,
4213 | "type": "Identifier",
4214 | },
4215 | "params": Array [],
4216 | "start": 0,
4217 | "type": "FunctionExpression",
4218 | },
4219 | "end": 30,
4220 | "fileAttachments": Map {},
4221 | "generator": false,
4222 | "id": Node {
4223 | "end": 13,
4224 | "name": "foo",
4225 | "start": 10,
4226 | "type": "Identifier",
4227 | },
4228 | "references": Array [],
4229 | "start": 0,
4230 | "type": "Cell",
4231 | }
4232 | `
4233 |
4234 | exports[`test/parse-test.js TAP parse object-literal.js > must match snapshot 1`] = `
4235 | Node {
4236 | "async": false,
4237 | "body": Node {
4238 | "end": 10,
4239 | "properties": Array [
4240 | Node {
4241 | "computed": false,
4242 | "end": 9,
4243 | "key": Node {
4244 | "end": 5,
4245 | "name": "foo",
4246 | "start": 2,
4247 | "type": "Identifier",
4248 | },
4249 | "kind": "init",
4250 | "method": false,
4251 | "shorthand": false,
4252 | "start": 2,
4253 | "type": "Property",
4254 | "value": Node {
4255 | "end": 9,
4256 | "raw": "42",
4257 | "start": 7,
4258 | "type": "Literal",
4259 | "value": 42,
4260 | },
4261 | },
4262 | ],
4263 | "start": 1,
4264 | "type": "ObjectExpression",
4265 | },
4266 | "end": 12,
4267 | "fileAttachments": Map {},
4268 | "generator": false,
4269 | "id": null,
4270 | "references": Array [],
4271 | "start": 0,
4272 | "type": "Cell",
4273 | }
4274 | `
4275 |
4276 | exports[`test/parse-test.js TAP parse semicolon.js > must match snapshot 1`] = `
4277 | Node {
4278 | "async": false,
4279 | "body": null,
4280 | "end": 2,
4281 | "fileAttachments": Map {},
4282 | "generator": false,
4283 | "id": null,
4284 | "start": 0,
4285 | "type": "Cell",
4286 | }
4287 | `
4288 |
4289 | exports[`test/parse-test.js TAP parse sequence-expression.js > must match snapshot 1`] = `
4290 | Node {
4291 | "async": false,
4292 | "body": Node {
4293 | "end": 7,
4294 | "expressions": Array [
4295 | Node {
4296 | "end": 1,
4297 | "raw": "1",
4298 | "start": 0,
4299 | "type": "Literal",
4300 | "value": 1,
4301 | },
4302 | Node {
4303 | "end": 4,
4304 | "raw": "2",
4305 | "start": 3,
4306 | "type": "Literal",
4307 | "value": 2,
4308 | },
4309 | Node {
4310 | "end": 7,
4311 | "raw": "3",
4312 | "start": 6,
4313 | "type": "Literal",
4314 | "value": 3,
4315 | },
4316 | ],
4317 | "start": 0,
4318 | "type": "SequenceExpression",
4319 | },
4320 | "end": 8,
4321 | "fileAttachments": Map {},
4322 | "generator": false,
4323 | "id": null,
4324 | "references": Array [],
4325 | "start": 0,
4326 | "type": "Cell",
4327 | }
4328 | `
4329 |
4330 | exports[`test/parse-test.js TAP parse shadowed-view.js > must match snapshot 1`] = `
4331 | Node {
4332 | "async": false,
4333 | "body": Node {
4334 | "body": Array [
4335 | Node {
4336 | "declarations": Array [
4337 | Node {
4338 | "end": 13,
4339 | "id": Node {
4340 | "end": 9,
4341 | "name": "x",
4342 | "start": 8,
4343 | "type": "Identifier",
4344 | },
4345 | "init": Node {
4346 | "end": 13,
4347 | "raw": "2",
4348 | "start": 12,
4349 | "type": "Literal",
4350 | "value": 2,
4351 | },
4352 | "start": 8,
4353 | "type": "VariableDeclarator",
4354 | },
4355 | ],
4356 | "end": 14,
4357 | "kind": "let",
4358 | "start": 4,
4359 | "type": "VariableDeclaration",
4360 | },
4361 | Node {
4362 | "end": 23,
4363 | "expression": Node {
4364 | "end": 22,
4365 | "left": Node {
4366 | "end": 18,
4367 | "name": "x",
4368 | "start": 17,
4369 | "type": "Identifier",
4370 | },
4371 | "operator": "=",
4372 | "right": Node {
4373 | "end": 22,
4374 | "raw": "4",
4375 | "start": 21,
4376 | "type": "Literal",
4377 | "value": 4,
4378 | },
4379 | "start": 17,
4380 | "type": "AssignmentExpression",
4381 | },
4382 | "start": 17,
4383 | "type": "ExpressionStatement",
4384 | },
4385 | Node {
4386 | "argument": Node {
4387 | "end": 41,
4388 | "id": Node {
4389 | "end": 41,
4390 | "name": "x",
4391 | "start": 40,
4392 | "type": "Identifier",
4393 | },
4394 | "start": 33,
4395 | "type": "ViewExpression",
4396 | },
4397 | "end": 42,
4398 | "start": 26,
4399 | "type": "ReturnStatement",
4400 | },
4401 | ],
4402 | "end": 44,
4403 | "start": 0,
4404 | "type": "BlockStatement",
4405 | },
4406 | "end": 45,
4407 | "fileAttachments": Map {},
4408 | "generator": false,
4409 | "id": null,
4410 | "references": Array [
4411 | Node {
4412 | "end": 41,
4413 | "id": Node {
4414 | "end": 41,
4415 | "name": "x",
4416 | "start": 40,
4417 | "type": "Identifier",
4418 | },
4419 | "start": 33,
4420 | "type": "ViewExpression",
4421 | },
4422 | ],
4423 | "start": 0,
4424 | "type": "Cell",
4425 | }
4426 | `
4427 |
4428 | exports[`test/parse-test.js TAP parse simple-identifier.js > must match snapshot 1`] = `
4429 | Node {
4430 | "async": false,
4431 | "body": Node {
4432 | "end": 3,
4433 | "name": "foo",
4434 | "start": 0,
4435 | "type": "Identifier",
4436 | },
4437 | "end": 4,
4438 | "fileAttachments": Map {},
4439 | "generator": false,
4440 | "id": null,
4441 | "references": Array [
4442 | Node {
4443 | "end": 3,
4444 | "name": "foo",
4445 | "start": 0,
4446 | "type": "Identifier",
4447 | },
4448 | ],
4449 | "start": 0,
4450 | "type": "Cell",
4451 | }
4452 | `
4453 |
4454 | exports[`test/parse-test.js TAP parse spread-element.js > must match snapshot 1`] = `
4455 | Node {
4456 | "async": false,
4457 | "body": Node {
4458 | "async": false,
4459 | "body": Node {
4460 | "end": 22,
4461 | "name": "bar",
4462 | "start": 19,
4463 | "type": "Identifier",
4464 | },
4465 | "end": 22,
4466 | "expression": true,
4467 | "generator": false,
4468 | "id": null,
4469 | "params": Array [
4470 | Node {
4471 | "end": 14,
4472 | "properties": Array [
4473 | Node {
4474 | "computed": false,
4475 | "end": 5,
4476 | "key": Node {
4477 | "end": 5,
4478 | "name": "foo",
4479 | "start": 2,
4480 | "type": "Identifier",
4481 | },
4482 | "kind": "init",
4483 | "method": false,
4484 | "shorthand": true,
4485 | "start": 2,
4486 | "type": "Property",
4487 | "value": Node {
4488 | "end": 5,
4489 | "name": "foo",
4490 | "start": 2,
4491 | "type": "Identifier",
4492 | },
4493 | },
4494 | Node {
4495 | "argument": Node {
4496 | "end": 13,
4497 | "name": "bar",
4498 | "start": 10,
4499 | "type": "Identifier",
4500 | },
4501 | "end": 13,
4502 | "start": 7,
4503 | "type": "RestElement",
4504 | },
4505 | ],
4506 | "start": 1,
4507 | "type": "ObjectPattern",
4508 | },
4509 | ],
4510 | "start": 0,
4511 | "type": "ArrowFunctionExpression",
4512 | },
4513 | "end": 23,
4514 | "fileAttachments": Map {},
4515 | "generator": false,
4516 | "id": null,
4517 | "references": Array [],
4518 | "start": 0,
4519 | "type": "Cell",
4520 | }
4521 | `
4522 |
4523 | exports[`test/parse-test.js TAP parse template-literal-semicolon.js > must match snapshot 1`] = `
4524 | Node {
4525 | "async": false,
4526 | "body": Node {
4527 | "end": 11,
4528 | "quasi": Node {
4529 | "end": 11,
4530 | "expressions": Array [],
4531 | "quasis": Array [
4532 | Node {
4533 | "end": 10,
4534 | "start": 5,
4535 | "tail": true,
4536 | "type": "TemplateElement",
4537 | "value": Object {
4538 | "cooked": "hello",
4539 | "raw": "hello",
4540 | },
4541 | },
4542 | ],
4543 | "start": 4,
4544 | "type": "TemplateLiteral",
4545 | },
4546 | "start": 0,
4547 | "tag": Node {
4548 | "end": 4,
4549 | "name": "html",
4550 | "start": 0,
4551 | "type": "Identifier",
4552 | },
4553 | "type": "TaggedTemplateExpression",
4554 | },
4555 | "end": 13,
4556 | "fileAttachments": Map {},
4557 | "generator": false,
4558 | "id": null,
4559 | "references": Array [
4560 | Node {
4561 | "end": 4,
4562 | "name": "html",
4563 | "start": 0,
4564 | "type": "Identifier",
4565 | },
4566 | ],
4567 | "start": 0,
4568 | "type": "Cell",
4569 | }
4570 | `
4571 |
4572 | exports[`test/parse-test.js TAP parse this-as-name.js > must match snapshot 1`] = `
4573 | Object {
4574 | "error": Object {
4575 | "loc": Object {
4576 | "column": 0,
4577 | "line": 1,
4578 | },
4579 | "message": "Assigning to rvalue (1:0)",
4580 | "pos": 0,
4581 | "type": "SyntaxError",
4582 | },
4583 | }
4584 | `
4585 |
4586 | exports[`test/parse-test.js TAP parse this.js > must match snapshot 1`] = `
4587 | Node {
4588 | "async": false,
4589 | "body": Node {
4590 | "end": 4,
4591 | "start": 0,
4592 | "type": "ThisExpression",
4593 | },
4594 | "end": 5,
4595 | "fileAttachments": Map {},
4596 | "generator": false,
4597 | "id": null,
4598 | "references": Array [],
4599 | "start": 0,
4600 | "type": "Cell",
4601 | }
4602 | `
4603 |
4604 | exports[`test/parse-test.js TAP parse var-statement.js > must match snapshot 1`] = `
4605 | Object {
4606 | "error": Object {
4607 | "loc": Object {
4608 | "column": 0,
4609 | "line": 1,
4610 | },
4611 | "message": "Unexpected token (1:0)",
4612 | "pos": 0,
4613 | "type": "SyntaxError",
4614 | },
4615 | }
4616 | `
4617 |
4618 | exports[`test/parse-test.js TAP parse viewof-argument.js > must match snapshot 1`] = `
4619 | Object {
4620 | "error": Object {
4621 | "loc": Object {
4622 | "column": 13,
4623 | "line": 1,
4624 | },
4625 | "message": "Unexpected keyword 'viewof' (1:13)",
4626 | "pos": 13,
4627 | "type": "SyntaxError",
4628 | },
4629 | }
4630 | `
4631 |
4632 | exports[`test/parse-test.js TAP parse viewof-assignment.js > must match snapshot 1`] = `
4633 | Object {
4634 | "error": Object {
4635 | "loc": Object {
4636 | "column": 2,
4637 | "line": 2,
4638 | },
4639 | "message": "Assigning to rvalue (2:2)",
4640 | "pos": 4,
4641 | "type": "SyntaxError",
4642 | },
4643 | }
4644 | `
4645 |
4646 | exports[`test/parse-test.js TAP parse viewof-binding.js > must match snapshot 1`] = `
4647 | Object {
4648 | "error": Object {
4649 | "loc": Object {
4650 | "column": 6,
4651 | "line": 2,
4652 | },
4653 | "message": "Unexpected keyword 'viewof' (2:6)",
4654 | "pos": 8,
4655 | "type": "SyntaxError",
4656 | },
4657 | }
4658 | `
4659 |
4660 | exports[`test/parse-test.js TAP parse viewof-block-cell.js > must match snapshot 1`] = `
4661 | Node {
4662 | "async": false,
4663 | "body": Node {
4664 | "body": Array [
4665 | Node {
4666 | "argument": Node {
4667 | "arguments": Array [],
4668 | "callee": Node {
4669 | "computed": false,
4670 | "end": 33,
4671 | "object": Node {
4672 | "end": 27,
4673 | "name": "DOM",
4674 | "start": 24,
4675 | "type": "Identifier",
4676 | },
4677 | "property": Node {
4678 | "end": 33,
4679 | "name": "input",
4680 | "start": 28,
4681 | "type": "Identifier",
4682 | },
4683 | "start": 24,
4684 | "type": "MemberExpression",
4685 | },
4686 | "end": 35,
4687 | "start": 24,
4688 | "type": "CallExpression",
4689 | },
4690 | "end": 36,
4691 | "start": 17,
4692 | "type": "ReturnStatement",
4693 | },
4694 | ],
4695 | "end": 38,
4696 | "start": 13,
4697 | "type": "BlockStatement",
4698 | },
4699 | "end": 39,
4700 | "fileAttachments": Map {},
4701 | "generator": false,
4702 | "id": Node {
4703 | "end": 10,
4704 | "id": Node {
4705 | "end": 10,
4706 | "name": "foo",
4707 | "start": 7,
4708 | "type": "Identifier",
4709 | },
4710 | "start": 0,
4711 | "type": "ViewExpression",
4712 | },
4713 | "references": Array [
4714 | Node {
4715 | "end": 27,
4716 | "name": "DOM",
4717 | "start": 24,
4718 | "type": "Identifier",
4719 | },
4720 | ],
4721 | "start": 0,
4722 | "type": "Cell",
4723 | }
4724 | `
4725 |
4726 | exports[`test/parse-test.js TAP parse viewof-expression-cell.js > must match snapshot 1`] = `
4727 | Node {
4728 | "async": false,
4729 | "body": Node {
4730 | "arguments": Array [],
4731 | "callee": Node {
4732 | "computed": false,
4733 | "end": 22,
4734 | "object": Node {
4735 | "end": 16,
4736 | "name": "DOM",
4737 | "start": 13,
4738 | "type": "Identifier",
4739 | },
4740 | "property": Node {
4741 | "end": 22,
4742 | "name": "input",
4743 | "start": 17,
4744 | "type": "Identifier",
4745 | },
4746 | "start": 13,
4747 | "type": "MemberExpression",
4748 | },
4749 | "end": 24,
4750 | "start": 13,
4751 | "type": "CallExpression",
4752 | },
4753 | "end": 25,
4754 | "fileAttachments": Map {},
4755 | "generator": false,
4756 | "id": Node {
4757 | "end": 10,
4758 | "id": Node {
4759 | "end": 10,
4760 | "name": "foo",
4761 | "start": 7,
4762 | "type": "Identifier",
4763 | },
4764 | "start": 0,
4765 | "type": "ViewExpression",
4766 | },
4767 | "references": Array [
4768 | Node {
4769 | "end": 16,
4770 | "name": "DOM",
4771 | "start": 13,
4772 | "type": "Identifier",
4773 | },
4774 | ],
4775 | "start": 0,
4776 | "type": "Cell",
4777 | }
4778 | `
4779 |
4780 | exports[`test/parse-test.js TAP parse viewof-internal-comment.js > must match snapshot 1`] = `
4781 | Node {
4782 | "async": false,
4783 | "body": Node {
4784 | "arguments": Array [],
4785 | "callee": Node {
4786 | "computed": false,
4787 | "end": 36,
4788 | "object": Node {
4789 | "end": 30,
4790 | "name": "DOM",
4791 | "start": 27,
4792 | "type": "Identifier",
4793 | },
4794 | "property": Node {
4795 | "end": 36,
4796 | "name": "range",
4797 | "start": 31,
4798 | "type": "Identifier",
4799 | },
4800 | "start": 27,
4801 | "type": "MemberExpression",
4802 | },
4803 | "end": 38,
4804 | "start": 27,
4805 | "type": "CallExpression",
4806 | },
4807 | "end": 39,
4808 | "fileAttachments": Map {},
4809 | "generator": false,
4810 | "id": Node {
4811 | "end": 24,
4812 | "id": Node {
4813 | "end": 24,
4814 | "name": "bar",
4815 | "start": 21,
4816 | "type": "Identifier",
4817 | },
4818 | "start": 0,
4819 | "type": "ViewExpression",
4820 | },
4821 | "references": Array [
4822 | Node {
4823 | "end": 30,
4824 | "name": "DOM",
4825 | "start": 27,
4826 | "type": "Identifier",
4827 | },
4828 | ],
4829 | "start": 0,
4830 | "type": "Cell",
4831 | }
4832 | `
4833 |
4834 | exports[`test/parse-test.js TAP parse viewof-let.js > must match snapshot 1`] = `
4835 | Object {
4836 | "error": Object {
4837 | "loc": Object {
4838 | "column": 6,
4839 | "line": 2,
4840 | },
4841 | "message": "Unexpected keyword 'viewof' (2:6)",
4842 | "pos": 8,
4843 | "type": "SyntaxError",
4844 | },
4845 | }
4846 | `
4847 |
4848 | exports[`test/parse-test.js TAP parse viewof-member-expression.js > must match snapshot 1`] = `
4849 | Node {
4850 | "async": false,
4851 | "body": Node {
4852 | "computed": false,
4853 | "end": 15,
4854 | "object": Node {
4855 | "end": 10,
4856 | "id": Node {
4857 | "end": 10,
4858 | "name": "foo",
4859 | "start": 7,
4860 | "type": "Identifier",
4861 | },
4862 | "start": 0,
4863 | "type": "ViewExpression",
4864 | },
4865 | "property": Node {
4866 | "end": 15,
4867 | "name": "name",
4868 | "start": 11,
4869 | "type": "Identifier",
4870 | },
4871 | "start": 0,
4872 | "type": "MemberExpression",
4873 | },
4874 | "end": 16,
4875 | "fileAttachments": Map {},
4876 | "generator": false,
4877 | "id": null,
4878 | "references": Array [
4879 | Node {
4880 | "end": 10,
4881 | "id": Node {
4882 | "end": 10,
4883 | "name": "foo",
4884 | "start": 7,
4885 | "type": "Identifier",
4886 | },
4887 | "start": 0,
4888 | "type": "ViewExpression",
4889 | },
4890 | ],
4891 | "start": 0,
4892 | "type": "Cell",
4893 | }
4894 | `
4895 |
4896 | exports[`test/parse-test.js TAP parse viewof-member.js > must match snapshot 1`] = `
4897 | Object {
4898 | "error": Object {
4899 | "loc": Object {
4900 | "column": 14,
4901 | "line": 1,
4902 | },
4903 | "message": "Unexpected token (1:14)",
4904 | "pos": 14,
4905 | "type": "SyntaxError",
4906 | },
4907 | }
4908 | `
4909 |
4910 | exports[`test/parse-test.js TAP parse viewof-orphan.js > must match snapshot 1`] = `
4911 | Object {
4912 | "error": Object {
4913 | "loc": Object {
4914 | "column": 7,
4915 | "line": 1,
4916 | },
4917 | "message": "Unexpected token (1:7)",
4918 | "pos": 7,
4919 | "type": "SyntaxError",
4920 | },
4921 | }
4922 | `
4923 |
4924 | exports[`test/parse-test.js TAP parse viewof-property.js > must match snapshot 1`] = `
4925 | Node {
4926 | "async": false,
4927 | "body": Node {
4928 | "end": 22,
4929 | "left": Node {
4930 | "computed": true,
4931 | "end": 18,
4932 | "object": Node {
4933 | "end": 6,
4934 | "name": "object",
4935 | "start": 0,
4936 | "type": "Identifier",
4937 | },
4938 | "property": Node {
4939 | "end": 17,
4940 | "id": Node {
4941 | "end": 17,
4942 | "name": "foo",
4943 | "start": 14,
4944 | "type": "Identifier",
4945 | },
4946 | "start": 7,
4947 | "type": "ViewExpression",
4948 | },
4949 | "start": 0,
4950 | "type": "MemberExpression",
4951 | },
4952 | "operator": "+",
4953 | "right": Node {
4954 | "end": 22,
4955 | "raw": "2",
4956 | "start": 21,
4957 | "type": "Literal",
4958 | "value": 2,
4959 | },
4960 | "start": 0,
4961 | "type": "BinaryExpression",
4962 | },
4963 | "end": 23,
4964 | "fileAttachments": Map {},
4965 | "generator": false,
4966 | "id": null,
4967 | "references": Array [
4968 | Node {
4969 | "end": 6,
4970 | "name": "object",
4971 | "start": 0,
4972 | "type": "Identifier",
4973 | },
4974 | Node {
4975 | "end": 17,
4976 | "id": Node {
4977 | "end": 17,
4978 | "name": "foo",
4979 | "start": 14,
4980 | "type": "Identifier",
4981 | },
4982 | "start": 7,
4983 | "type": "ViewExpression",
4984 | },
4985 | ],
4986 | "start": 0,
4987 | "type": "Cell",
4988 | }
4989 | `
4990 |
4991 | exports[`test/parse-test.js TAP parse viewof-reference-internal-comment.js > must match snapshot 1`] = `
4992 | Node {
4993 | "async": false,
4994 | "body": Node {
4995 | "end": 24,
4996 | "id": Node {
4997 | "end": 24,
4998 | "name": "bar",
4999 | "start": 21,
5000 | "type": "Identifier",
5001 | },
5002 | "start": 0,
5003 | "type": "ViewExpression",
5004 | },
5005 | "end": 25,
5006 | "fileAttachments": Map {},
5007 | "generator": false,
5008 | "id": null,
5009 | "references": Array [
5010 | Node {
5011 | "end": 24,
5012 | "id": Node {
5013 | "end": 24,
5014 | "name": "bar",
5015 | "start": 21,
5016 | "type": "Identifier",
5017 | },
5018 | "start": 0,
5019 | "type": "ViewExpression",
5020 | },
5021 | ],
5022 | "start": 0,
5023 | "type": "Cell",
5024 | }
5025 | `
5026 |
5027 | exports[`test/parse-test.js TAP parse viewof-reference.js > must match snapshot 1`] = `
5028 | Node {
5029 | "async": false,
5030 | "body": Node {
5031 | "computed": false,
5032 | "end": 20,
5033 | "object": Node {
5034 | "end": 12,
5035 | "id": Node {
5036 | "end": 12,
5037 | "name": "input",
5038 | "start": 7,
5039 | "type": "Identifier",
5040 | },
5041 | "start": 0,
5042 | "type": "ViewExpression",
5043 | },
5044 | "property": Node {
5045 | "end": 20,
5046 | "name": "tagName",
5047 | "start": 13,
5048 | "type": "Identifier",
5049 | },
5050 | "start": 0,
5051 | "type": "MemberExpression",
5052 | },
5053 | "end": 21,
5054 | "fileAttachments": Map {},
5055 | "generator": false,
5056 | "id": null,
5057 | "references": Array [
5058 | Node {
5059 | "end": 12,
5060 | "id": Node {
5061 | "end": 12,
5062 | "name": "input",
5063 | "start": 7,
5064 | "type": "Identifier",
5065 | },
5066 | "start": 0,
5067 | "type": "ViewExpression",
5068 | },
5069 | ],
5070 | "start": 0,
5071 | "type": "Cell",
5072 | }
5073 | `
5074 |
5075 | exports[`test/parse-test.js TAP parse yield-await.js > must match snapshot 1`] = `
5076 | Node {
5077 | "async": true,
5078 | "body": Node {
5079 | "body": Array [
5080 | Node {
5081 | "end": 16,
5082 | "expression": Node {
5083 | "argument": Node {
5084 | "end": 15,
5085 | "name": "value",
5086 | "start": 10,
5087 | "type": "Identifier",
5088 | },
5089 | "delegate": false,
5090 | "end": 15,
5091 | "start": 4,
5092 | "type": "YieldExpression",
5093 | },
5094 | "start": 4,
5095 | "type": "ExpressionStatement",
5096 | },
5097 | Node {
5098 | "end": 33,
5099 | "expression": Node {
5100 | "argument": Node {
5101 | "end": 32,
5102 | "name": "promise",
5103 | "start": 25,
5104 | "type": "Identifier",
5105 | },
5106 | "end": 32,
5107 | "start": 19,
5108 | "type": "AwaitExpression",
5109 | },
5110 | "start": 19,
5111 | "type": "ExpressionStatement",
5112 | },
5113 | ],
5114 | "end": 35,
5115 | "start": 0,
5116 | "type": "BlockStatement",
5117 | },
5118 | "end": 36,
5119 | "fileAttachments": Map {},
5120 | "generator": true,
5121 | "id": null,
5122 | "references": Array [
5123 | Node {
5124 | "end": 15,
5125 | "name": "value",
5126 | "start": 10,
5127 | "type": "Identifier",
5128 | },
5129 | Node {
5130 | "end": 32,
5131 | "name": "promise",
5132 | "start": 25,
5133 | "type": "Identifier",
5134 | },
5135 | ],
5136 | "start": 0,
5137 | "type": "Cell",
5138 | }
5139 | `
5140 |
5141 | exports[`test/parse-test.js TAP parse yield-block-cell.js > must match snapshot 1`] = `
5142 | Node {
5143 | "async": false,
5144 | "body": Node {
5145 | "body": Array [
5146 | Node {
5147 | "end": 16,
5148 | "expression": Node {
5149 | "argument": Node {
5150 | "end": 15,
5151 | "name": "value",
5152 | "start": 10,
5153 | "type": "Identifier",
5154 | },
5155 | "delegate": false,
5156 | "end": 15,
5157 | "start": 4,
5158 | "type": "YieldExpression",
5159 | },
5160 | "start": 4,
5161 | "type": "ExpressionStatement",
5162 | },
5163 | ],
5164 | "end": 18,
5165 | "start": 0,
5166 | "type": "BlockStatement",
5167 | },
5168 | "end": 19,
5169 | "fileAttachments": Map {},
5170 | "generator": true,
5171 | "id": null,
5172 | "references": Array [
5173 | Node {
5174 | "end": 15,
5175 | "name": "value",
5176 | "start": 10,
5177 | "type": "Identifier",
5178 | },
5179 | ],
5180 | "start": 0,
5181 | "type": "Cell",
5182 | }
5183 | `
5184 |
5185 | exports[`test/parse-test.js TAP parse yield-expression-cell.js > must match snapshot 1`] = `
5186 | Node {
5187 | "async": false,
5188 | "body": Node {
5189 | "argument": Node {
5190 | "end": 11,
5191 | "name": "value",
5192 | "start": 6,
5193 | "type": "Identifier",
5194 | },
5195 | "delegate": false,
5196 | "end": 11,
5197 | "start": 0,
5198 | "type": "YieldExpression",
5199 | },
5200 | "end": 12,
5201 | "fileAttachments": Map {},
5202 | "generator": true,
5203 | "id": null,
5204 | "references": Array [
5205 | Node {
5206 | "end": 11,
5207 | "name": "value",
5208 | "start": 6,
5209 | "type": "Identifier",
5210 | },
5211 | ],
5212 | "start": 0,
5213 | "type": "Cell",
5214 | }
5215 | `
5216 |
5217 | exports[`test/parse-test.js TAP parse yield-in-function.js > must match snapshot 1`] = `
5218 | Node {
5219 | "async": false,
5220 | "body": Node {
5221 | "body": Array [
5222 | Node {
5223 | "async": false,
5224 | "body": Node {
5225 | "body": Array [
5226 | Node {
5227 | "end": 40,
5228 | "expression": Node {
5229 | "argument": Node {
5230 | "end": 39,
5231 | "name": "value",
5232 | "start": 34,
5233 | "type": "Identifier",
5234 | },
5235 | "delegate": false,
5236 | "end": 39,
5237 | "start": 28,
5238 | "type": "YieldExpression",
5239 | },
5240 | "start": 28,
5241 | "type": "ExpressionStatement",
5242 | },
5243 | ],
5244 | "end": 44,
5245 | "start": 22,
5246 | "type": "BlockStatement",
5247 | },
5248 | "end": 44,
5249 | "expression": false,
5250 | "generator": true,
5251 | "id": Node {
5252 | "end": 19,
5253 | "name": "inner",
5254 | "start": 14,
5255 | "type": "Identifier",
5256 | },
5257 | "params": Array [],
5258 | "start": 4,
5259 | "type": "FunctionDeclaration",
5260 | },
5261 | ],
5262 | "end": 46,
5263 | "start": 0,
5264 | "type": "BlockStatement",
5265 | },
5266 | "end": 47,
5267 | "fileAttachments": Map {},
5268 | "generator": false,
5269 | "id": null,
5270 | "references": Array [
5271 | Node {
5272 | "end": 39,
5273 | "name": "value",
5274 | "start": 34,
5275 | "type": "Identifier",
5276 | },
5277 | ],
5278 | "start": 0,
5279 | "type": "Cell",
5280 | }
5281 | `
5282 |
5283 | exports[`test/parse-test.js TAP parse yield-star-expression-cell.js > must match snapshot 1`] = `
5284 | Node {
5285 | "async": false,
5286 | "body": Node {
5287 | "argument": Node {
5288 | "end": 13,
5289 | "name": "values",
5290 | "start": 7,
5291 | "type": "Identifier",
5292 | },
5293 | "delegate": true,
5294 | "end": 13,
5295 | "start": 0,
5296 | "type": "YieldExpression",
5297 | },
5298 | "end": 14,
5299 | "fileAttachments": Map {},
5300 | "generator": true,
5301 | "id": null,
5302 | "references": Array [
5303 | Node {
5304 | "end": 13,
5305 | "name": "values",
5306 | "start": 7,
5307 | "type": "Identifier",
5308 | },
5309 | ],
5310 | "start": 0,
5311 | "type": "Cell",
5312 | }
5313 | `
5314 |
5315 | exports[`test/parse-test.js TAP parseModule > must match snapshot 1`] = `
5316 | Node {
5317 | "cells": Array [
5318 | Node {
5319 | "async": false,
5320 | "body": Node {
5321 | "end": 5,
5322 | "raw": "1",
5323 | "start": 4,
5324 | "type": "Literal",
5325 | "value": 1,
5326 | },
5327 | "end": 6,
5328 | "fileAttachments": Map {},
5329 | "generator": false,
5330 | "id": Node {
5331 | "end": 1,
5332 | "name": "a",
5333 | "start": 0,
5334 | "type": "Identifier",
5335 | },
5336 | "input": "a = 1;\\n\\nb = 2;\\n\\nc = a + b",
5337 | "references": Array [],
5338 | "start": 0,
5339 | "type": "Cell",
5340 | },
5341 | Node {
5342 | "async": false,
5343 | "body": Node {
5344 | "end": 13,
5345 | "raw": "2",
5346 | "start": 12,
5347 | "type": "Literal",
5348 | "value": 2,
5349 | },
5350 | "end": 14,
5351 | "fileAttachments": Map {},
5352 | "generator": false,
5353 | "id": Node {
5354 | "end": 9,
5355 | "name": "b",
5356 | "start": 8,
5357 | "type": "Identifier",
5358 | },
5359 | "input": "a = 1;\\n\\nb = 2;\\n\\nc = a + b",
5360 | "references": Array [],
5361 | "start": 8,
5362 | "type": "Cell",
5363 | },
5364 | Node {
5365 | "async": false,
5366 | "body": Node {
5367 | "end": 25,
5368 | "left": Node {
5369 | "end": 21,
5370 | "name": "a",
5371 | "start": 20,
5372 | "type": "Identifier",
5373 | },
5374 | "operator": "+",
5375 | "right": Node {
5376 | "end": 25,
5377 | "name": "b",
5378 | "start": 24,
5379 | "type": "Identifier",
5380 | },
5381 | "start": 20,
5382 | "type": "BinaryExpression",
5383 | },
5384 | "end": 25,
5385 | "fileAttachments": Map {},
5386 | "generator": false,
5387 | "id": Node {
5388 | "end": 17,
5389 | "name": "c",
5390 | "start": 16,
5391 | "type": "Identifier",
5392 | },
5393 | "input": "a = 1;\\n\\nb = 2;\\n\\nc = a + b",
5394 | "references": Array [
5395 | Node {
5396 | "end": 21,
5397 | "name": "a",
5398 | "start": 20,
5399 | "type": "Identifier",
5400 | },
5401 | Node {
5402 | "end": 25,
5403 | "name": "b",
5404 | "start": 24,
5405 | "type": "Identifier",
5406 | },
5407 | ],
5408 | "start": 16,
5409 | "type": "Cell",
5410 | },
5411 | ],
5412 | "end": 25,
5413 | "start": 0,
5414 | "type": "Program",
5415 | }
5416 | `
5417 |
--------------------------------------------------------------------------------