Parse async do expressions (#13043)
* parse async do expressions * add test cases * update test fixtures * chore: add syntax-async-do-expressions * generater support * fix: do not transform async do expressions * chore: add asyncDoExpressions to missing plugin helpers * update ast types * add more test cases * throw when asyncDoExpressions is enabled but not doExpressions * avoid add parentheses for async do expressions * address review comments * chore: update parser typings
This commit is contained in:
parent
f30c99aa24
commit
28d7442aae
@ -1,4 +1,10 @@
|
|||||||
const pluginNameMap = {
|
const pluginNameMap = {
|
||||||
|
asyncDoExpressions: {
|
||||||
|
syntax: {
|
||||||
|
name: "@babel/plugin-syntax-async-do-expressions",
|
||||||
|
url: "https://git.io/JYer8",
|
||||||
|
},
|
||||||
|
},
|
||||||
classProperties: {
|
classProperties: {
|
||||||
syntax: {
|
syntax: {
|
||||||
name: "@babel/plugin-syntax-class-properties",
|
name: "@babel/plugin-syntax-class-properties",
|
||||||
|
|||||||
@ -20,6 +20,10 @@ export function UnaryExpression(this: Printer, node: t.UnaryExpression) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export function DoExpression(this: Printer, node: t.DoExpression) {
|
export function DoExpression(this: Printer, node: t.DoExpression) {
|
||||||
|
if (node.async) {
|
||||||
|
this.word("async");
|
||||||
|
this.space();
|
||||||
|
}
|
||||||
this.word("do");
|
this.word("do");
|
||||||
this.space();
|
this.space();
|
||||||
this.print(node.body, node);
|
this.print(node.body, node);
|
||||||
|
|||||||
@ -82,7 +82,8 @@ export function DoExpression(
|
|||||||
parent: any,
|
parent: any,
|
||||||
printStack: Array<any>,
|
printStack: Array<any>,
|
||||||
): boolean {
|
): boolean {
|
||||||
return isFirstInStatement(printStack);
|
// `async do` can start an expression statement
|
||||||
|
return !node.async && isFirstInStatement(printStack);
|
||||||
}
|
}
|
||||||
|
|
||||||
export function Binary(node: any, parent: any): boolean {
|
export function Binary(node: any, parent: any): boolean {
|
||||||
|
|||||||
5
packages/babel-generator/test/fixtures/async-do-expressions/basic/input.js
vendored
Normal file
5
packages/babel-generator/test/fixtures/async-do-expressions/basic/input.js
vendored
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
async do {
|
||||||
|
1;
|
||||||
|
};
|
||||||
|
|
||||||
|
(async do {});
|
||||||
4
packages/babel-generator/test/fixtures/async-do-expressions/basic/output.js
vendored
Normal file
4
packages/babel-generator/test/fixtures/async-do-expressions/basic/output.js
vendored
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
async do {
|
||||||
|
1;
|
||||||
|
};
|
||||||
|
async do {};
|
||||||
3
packages/babel-generator/test/fixtures/async-do-expressions/options.json
vendored
Normal file
3
packages/babel-generator/test/fixtures/async-do-expressions/options.json
vendored
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
{
|
||||||
|
"plugins": ["asyncDoExpressions", "doExpressions"]
|
||||||
|
}
|
||||||
3
packages/babel-generator/test/fixtures/async-do-expressions/retain-lines/input.js
vendored
Normal file
3
packages/babel-generator/test/fixtures/async-do-expressions/retain-lines/input.js
vendored
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
/* leading comments
|
||||||
|
*/async do
|
||||||
|
{ 1 } + 0;
|
||||||
3
packages/babel-generator/test/fixtures/async-do-expressions/retain-lines/options.json
vendored
Normal file
3
packages/babel-generator/test/fixtures/async-do-expressions/retain-lines/options.json
vendored
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
{
|
||||||
|
"retainLines": true
|
||||||
|
}
|
||||||
3
packages/babel-generator/test/fixtures/async-do-expressions/retain-lines/output.js
vendored
Normal file
3
packages/babel-generator/test/fixtures/async-do-expressions/retain-lines/output.js
vendored
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
/* leading comments
|
||||||
|
*/async do
|
||||||
|
{1;} + 0;
|
||||||
@ -1084,6 +1084,7 @@ An expression wrapped by parentheses. By default `@babel/parser` does not create
|
|||||||
interface DoExpression <: Expression {
|
interface DoExpression <: Expression {
|
||||||
type: "DoExpression";
|
type: "DoExpression";
|
||||||
body: BlockStatement;
|
body: BlockStatement;
|
||||||
|
async: boolean;
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|||||||
@ -1033,6 +1033,8 @@ export default class ExpressionParser extends LValParser {
|
|||||||
);
|
);
|
||||||
} else if (this.match(tt.name)) {
|
} else if (this.match(tt.name)) {
|
||||||
return this.parseAsyncArrowUnaryFunction(id);
|
return this.parseAsyncArrowUnaryFunction(id);
|
||||||
|
} else if (this.match(tt._do)) {
|
||||||
|
return this.parseDo(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1049,7 +1051,7 @@ export default class ExpressionParser extends LValParser {
|
|||||||
}
|
}
|
||||||
|
|
||||||
case tt._do: {
|
case tt._do: {
|
||||||
return this.parseDo();
|
return this.parseDo(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
case tt.regexp: {
|
case tt.regexp: {
|
||||||
@ -1231,13 +1233,27 @@ export default class ExpressionParser extends LValParser {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// https://github.com/tc39/proposal-do-expressions
|
// https://github.com/tc39/proposal-do-expressions
|
||||||
parseDo(): N.DoExpression {
|
// https://github.com/tc39/proposal-async-do-expressions
|
||||||
|
parseDo(isAsync: boolean): N.DoExpression {
|
||||||
this.expectPlugin("doExpressions");
|
this.expectPlugin("doExpressions");
|
||||||
|
if (isAsync) {
|
||||||
|
this.expectPlugin("asyncDoExpressions");
|
||||||
|
}
|
||||||
const node = this.startNode();
|
const node = this.startNode();
|
||||||
|
node.async = isAsync;
|
||||||
this.next(); // eat `do`
|
this.next(); // eat `do`
|
||||||
const oldLabels = this.state.labels;
|
const oldLabels = this.state.labels;
|
||||||
this.state.labels = [];
|
this.state.labels = [];
|
||||||
node.body = this.parseBlock();
|
if (isAsync) {
|
||||||
|
// AsyncDoExpression :
|
||||||
|
// async [no LineTerminator here] do Block[~Yield, +Await, ~Return]
|
||||||
|
this.prodParam.enter(PARAM_AWAIT);
|
||||||
|
node.body = this.parseBlock();
|
||||||
|
this.prodParam.exit();
|
||||||
|
} else {
|
||||||
|
node.body = this.parseBlock();
|
||||||
|
}
|
||||||
|
|
||||||
this.state.labels = oldLabels;
|
this.state.labels = oldLabels;
|
||||||
return this.finishNode(node, "DoExpression");
|
return this.finishNode(node, "DoExpression");
|
||||||
}
|
}
|
||||||
|
|||||||
@ -117,6 +117,18 @@ export function validatePlugins(plugins: PluginList) {
|
|||||||
RECORD_AND_TUPLE_SYNTAX_TYPES.map(p => `'${p}'`).join(", "),
|
RECORD_AND_TUPLE_SYNTAX_TYPES.map(p => `'${p}'`).join(", "),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (
|
||||||
|
hasPlugin(plugins, "asyncDoExpressions") &&
|
||||||
|
!hasPlugin(plugins, "doExpressions")
|
||||||
|
) {
|
||||||
|
const error = new Error(
|
||||||
|
"'asyncDoExpressions' requires 'doExpressions', please add 'doExpressions' to parser plugins.",
|
||||||
|
);
|
||||||
|
// $FlowIgnore
|
||||||
|
error.missingPlugins = "doExpressions"; // so @babel/core can provide better error message
|
||||||
|
throw error;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// These plugins are defined using a mixin which extends the parser class.
|
// These plugins are defined using a mixin which extends the parser class.
|
||||||
|
|||||||
@ -402,6 +402,7 @@ export type ArrayExpression = NodeBase & {
|
|||||||
export type DoExpression = NodeBase & {
|
export type DoExpression = NodeBase & {
|
||||||
type: "DoExpression",
|
type: "DoExpression",
|
||||||
body: ?BlockStatement,
|
body: ?BlockStatement,
|
||||||
|
async: boolean,
|
||||||
};
|
};
|
||||||
|
|
||||||
export type TupleExpression = NodeBase & {
|
export type TupleExpression = NodeBase & {
|
||||||
|
|||||||
@ -0,0 +1 @@
|
|||||||
|
(async do {x})
|
||||||
@ -0,0 +1,6 @@
|
|||||||
|
{
|
||||||
|
"throws": "This experimental syntax requires enabling the parser plugin: 'asyncDoExpressions' (1:7)",
|
||||||
|
"plugins": [
|
||||||
|
"doExpressions"
|
||||||
|
]
|
||||||
|
}
|
||||||
1
packages/babel-parser/test/fixtures/experimental/_no-plugin/async-do-expressions/input.js
vendored
Normal file
1
packages/babel-parser/test/fixtures/experimental/_no-plugin/async-do-expressions/input.js
vendored
Normal file
@ -0,0 +1 @@
|
|||||||
|
(async do {x})
|
||||||
@ -0,0 +1,4 @@
|
|||||||
|
{
|
||||||
|
"throws": "This experimental syntax requires enabling the parser plugin: 'doExpressions' (1:7)",
|
||||||
|
"plugins": []
|
||||||
|
}
|
||||||
@ -0,0 +1,5 @@
|
|||||||
|
async
|
||||||
|
do {
|
||||||
|
42
|
||||||
|
}
|
||||||
|
while (false);
|
||||||
@ -0,0 +1,51 @@
|
|||||||
|
{
|
||||||
|
"type": "File",
|
||||||
|
"start":0,"end":32,"loc":{"start":{"line":1,"column":0},"end":{"line":5,"column":14}},
|
||||||
|
"program": {
|
||||||
|
"type": "Program",
|
||||||
|
"start":0,"end":32,"loc":{"start":{"line":1,"column":0},"end":{"line":5,"column":14}},
|
||||||
|
"sourceType": "script",
|
||||||
|
"interpreter": null,
|
||||||
|
"body": [
|
||||||
|
{
|
||||||
|
"type": "ExpressionStatement",
|
||||||
|
"start":0,"end":5,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":5}},
|
||||||
|
"expression": {
|
||||||
|
"type": "Identifier",
|
||||||
|
"start":0,"end":5,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":5},"identifierName":"async"},
|
||||||
|
"name": "async"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "DoWhileStatement",
|
||||||
|
"start":6,"end":32,"loc":{"start":{"line":2,"column":0},"end":{"line":5,"column":14}},
|
||||||
|
"body": {
|
||||||
|
"type": "BlockStatement",
|
||||||
|
"start":9,"end":17,"loc":{"start":{"line":2,"column":3},"end":{"line":4,"column":1}},
|
||||||
|
"body": [
|
||||||
|
{
|
||||||
|
"type": "ExpressionStatement",
|
||||||
|
"start":13,"end":15,"loc":{"start":{"line":3,"column":2},"end":{"line":3,"column":4}},
|
||||||
|
"expression": {
|
||||||
|
"type": "NumericLiteral",
|
||||||
|
"start":13,"end":15,"loc":{"start":{"line":3,"column":2},"end":{"line":3,"column":4}},
|
||||||
|
"extra": {
|
||||||
|
"rawValue": 42,
|
||||||
|
"raw": "42"
|
||||||
|
},
|
||||||
|
"value": 42
|
||||||
|
}
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"directives": []
|
||||||
|
},
|
||||||
|
"test": {
|
||||||
|
"type": "BooleanLiteral",
|
||||||
|
"start":25,"end":30,"loc":{"start":{"line":5,"column":7},"end":{"line":5,"column":12}},
|
||||||
|
"value": false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"directives": []
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,4 @@
|
|||||||
|
async do {
|
||||||
|
42
|
||||||
|
}
|
||||||
|
while (false);
|
||||||
@ -0,0 +1,55 @@
|
|||||||
|
{
|
||||||
|
"type": "File",
|
||||||
|
"start":0,"end":32,"loc":{"start":{"line":1,"column":0},"end":{"line":4,"column":14}},
|
||||||
|
"program": {
|
||||||
|
"type": "Program",
|
||||||
|
"start":0,"end":32,"loc":{"start":{"line":1,"column":0},"end":{"line":4,"column":14}},
|
||||||
|
"sourceType": "script",
|
||||||
|
"interpreter": null,
|
||||||
|
"body": [
|
||||||
|
{
|
||||||
|
"type": "ExpressionStatement",
|
||||||
|
"start":0,"end":17,"loc":{"start":{"line":1,"column":0},"end":{"line":3,"column":1}},
|
||||||
|
"expression": {
|
||||||
|
"type": "DoExpression",
|
||||||
|
"start":6,"end":17,"loc":{"start":{"line":1,"column":6},"end":{"line":3,"column":1}},
|
||||||
|
"async": true,
|
||||||
|
"body": {
|
||||||
|
"type": "BlockStatement",
|
||||||
|
"start":9,"end":17,"loc":{"start":{"line":1,"column":9},"end":{"line":3,"column":1}},
|
||||||
|
"body": [
|
||||||
|
{
|
||||||
|
"type": "ExpressionStatement",
|
||||||
|
"start":13,"end":15,"loc":{"start":{"line":2,"column":2},"end":{"line":2,"column":4}},
|
||||||
|
"expression": {
|
||||||
|
"type": "NumericLiteral",
|
||||||
|
"start":13,"end":15,"loc":{"start":{"line":2,"column":2},"end":{"line":2,"column":4}},
|
||||||
|
"extra": {
|
||||||
|
"rawValue": 42,
|
||||||
|
"raw": "42"
|
||||||
|
},
|
||||||
|
"value": 42
|
||||||
|
}
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"directives": []
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "WhileStatement",
|
||||||
|
"start":18,"end":32,"loc":{"start":{"line":4,"column":0},"end":{"line":4,"column":14}},
|
||||||
|
"test": {
|
||||||
|
"type": "BooleanLiteral",
|
||||||
|
"start":25,"end":30,"loc":{"start":{"line":4,"column":7},"end":{"line":4,"column":12}},
|
||||||
|
"value": false
|
||||||
|
},
|
||||||
|
"body": {
|
||||||
|
"type": "EmptyStatement",
|
||||||
|
"start":31,"end":32,"loc":{"start":{"line":4,"column":13},"end":{"line":4,"column":14}}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"directives": []
|
||||||
|
}
|
||||||
|
}
|
||||||
4
packages/babel-parser/test/fixtures/experimental/async-do-expressions/asi/input.js
vendored
Normal file
4
packages/babel-parser/test/fixtures/experimental/async-do-expressions/asi/input.js
vendored
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
async
|
||||||
|
do {
|
||||||
|
42
|
||||||
|
}
|
||||||
3
packages/babel-parser/test/fixtures/experimental/async-do-expressions/asi/options.json
vendored
Normal file
3
packages/babel-parser/test/fixtures/experimental/async-do-expressions/asi/options.json
vendored
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
{
|
||||||
|
"throws": "Unexpected token, expected \"while\" (4:1)"
|
||||||
|
}
|
||||||
@ -0,0 +1,5 @@
|
|||||||
|
let x = async do {
|
||||||
|
if (foo()) { f() }
|
||||||
|
else if (bar()) { g() }
|
||||||
|
else { h() }
|
||||||
|
};
|
||||||
@ -0,0 +1,132 @@
|
|||||||
|
{
|
||||||
|
"type": "File",
|
||||||
|
"start":0,"end":83,"loc":{"start":{"line":1,"column":0},"end":{"line":5,"column":2}},
|
||||||
|
"program": {
|
||||||
|
"type": "Program",
|
||||||
|
"start":0,"end":83,"loc":{"start":{"line":1,"column":0},"end":{"line":5,"column":2}},
|
||||||
|
"sourceType": "script",
|
||||||
|
"interpreter": null,
|
||||||
|
"body": [
|
||||||
|
{
|
||||||
|
"type": "VariableDeclaration",
|
||||||
|
"start":0,"end":83,"loc":{"start":{"line":1,"column":0},"end":{"line":5,"column":2}},
|
||||||
|
"declarations": [
|
||||||
|
{
|
||||||
|
"type": "VariableDeclarator",
|
||||||
|
"start":4,"end":82,"loc":{"start":{"line":1,"column":4},"end":{"line":5,"column":1}},
|
||||||
|
"id": {
|
||||||
|
"type": "Identifier",
|
||||||
|
"start":4,"end":5,"loc":{"start":{"line":1,"column":4},"end":{"line":1,"column":5},"identifierName":"x"},
|
||||||
|
"name": "x"
|
||||||
|
},
|
||||||
|
"init": {
|
||||||
|
"type": "DoExpression",
|
||||||
|
"start":14,"end":82,"loc":{"start":{"line":1,"column":14},"end":{"line":5,"column":1}},
|
||||||
|
"async": true,
|
||||||
|
"body": {
|
||||||
|
"type": "BlockStatement",
|
||||||
|
"start":17,"end":82,"loc":{"start":{"line":1,"column":17},"end":{"line":5,"column":1}},
|
||||||
|
"body": [
|
||||||
|
{
|
||||||
|
"type": "IfStatement",
|
||||||
|
"start":21,"end":80,"loc":{"start":{"line":2,"column":2},"end":{"line":4,"column":14}},
|
||||||
|
"test": {
|
||||||
|
"type": "CallExpression",
|
||||||
|
"start":25,"end":30,"loc":{"start":{"line":2,"column":6},"end":{"line":2,"column":11}},
|
||||||
|
"callee": {
|
||||||
|
"type": "Identifier",
|
||||||
|
"start":25,"end":28,"loc":{"start":{"line":2,"column":6},"end":{"line":2,"column":9},"identifierName":"foo"},
|
||||||
|
"name": "foo"
|
||||||
|
},
|
||||||
|
"arguments": []
|
||||||
|
},
|
||||||
|
"consequent": {
|
||||||
|
"type": "BlockStatement",
|
||||||
|
"start":32,"end":39,"loc":{"start":{"line":2,"column":13},"end":{"line":2,"column":20}},
|
||||||
|
"body": [
|
||||||
|
{
|
||||||
|
"type": "ExpressionStatement",
|
||||||
|
"start":34,"end":37,"loc":{"start":{"line":2,"column":15},"end":{"line":2,"column":18}},
|
||||||
|
"expression": {
|
||||||
|
"type": "CallExpression",
|
||||||
|
"start":34,"end":37,"loc":{"start":{"line":2,"column":15},"end":{"line":2,"column":18}},
|
||||||
|
"callee": {
|
||||||
|
"type": "Identifier",
|
||||||
|
"start":34,"end":35,"loc":{"start":{"line":2,"column":15},"end":{"line":2,"column":16},"identifierName":"f"},
|
||||||
|
"name": "f"
|
||||||
|
},
|
||||||
|
"arguments": []
|
||||||
|
}
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"directives": []
|
||||||
|
},
|
||||||
|
"alternate": {
|
||||||
|
"type": "IfStatement",
|
||||||
|
"start":47,"end":80,"loc":{"start":{"line":3,"column":7},"end":{"line":4,"column":14}},
|
||||||
|
"test": {
|
||||||
|
"type": "CallExpression",
|
||||||
|
"start":51,"end":56,"loc":{"start":{"line":3,"column":11},"end":{"line":3,"column":16}},
|
||||||
|
"callee": {
|
||||||
|
"type": "Identifier",
|
||||||
|
"start":51,"end":54,"loc":{"start":{"line":3,"column":11},"end":{"line":3,"column":14},"identifierName":"bar"},
|
||||||
|
"name": "bar"
|
||||||
|
},
|
||||||
|
"arguments": []
|
||||||
|
},
|
||||||
|
"consequent": {
|
||||||
|
"type": "BlockStatement",
|
||||||
|
"start":58,"end":65,"loc":{"start":{"line":3,"column":18},"end":{"line":3,"column":25}},
|
||||||
|
"body": [
|
||||||
|
{
|
||||||
|
"type": "ExpressionStatement",
|
||||||
|
"start":60,"end":63,"loc":{"start":{"line":3,"column":20},"end":{"line":3,"column":23}},
|
||||||
|
"expression": {
|
||||||
|
"type": "CallExpression",
|
||||||
|
"start":60,"end":63,"loc":{"start":{"line":3,"column":20},"end":{"line":3,"column":23}},
|
||||||
|
"callee": {
|
||||||
|
"type": "Identifier",
|
||||||
|
"start":60,"end":61,"loc":{"start":{"line":3,"column":20},"end":{"line":3,"column":21},"identifierName":"g"},
|
||||||
|
"name": "g"
|
||||||
|
},
|
||||||
|
"arguments": []
|
||||||
|
}
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"directives": []
|
||||||
|
},
|
||||||
|
"alternate": {
|
||||||
|
"type": "BlockStatement",
|
||||||
|
"start":73,"end":80,"loc":{"start":{"line":4,"column":7},"end":{"line":4,"column":14}},
|
||||||
|
"body": [
|
||||||
|
{
|
||||||
|
"type": "ExpressionStatement",
|
||||||
|
"start":75,"end":78,"loc":{"start":{"line":4,"column":9},"end":{"line":4,"column":12}},
|
||||||
|
"expression": {
|
||||||
|
"type": "CallExpression",
|
||||||
|
"start":75,"end":78,"loc":{"start":{"line":4,"column":9},"end":{"line":4,"column":12}},
|
||||||
|
"callee": {
|
||||||
|
"type": "Identifier",
|
||||||
|
"start":75,"end":76,"loc":{"start":{"line":4,"column":9},"end":{"line":4,"column":10},"identifierName":"h"},
|
||||||
|
"name": "h"
|
||||||
|
},
|
||||||
|
"arguments": []
|
||||||
|
}
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"directives": []
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"directives": []
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"kind": "let"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"directives": []
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,3 @@
|
|||||||
|
async do {
|
||||||
|
await 42
|
||||||
|
}
|
||||||
@ -0,0 +1,46 @@
|
|||||||
|
{
|
||||||
|
"type": "File",
|
||||||
|
"start":0,"end":23,"loc":{"start":{"line":1,"column":0},"end":{"line":3,"column":1}},
|
||||||
|
"program": {
|
||||||
|
"type": "Program",
|
||||||
|
"start":0,"end":23,"loc":{"start":{"line":1,"column":0},"end":{"line":3,"column":1}},
|
||||||
|
"sourceType": "script",
|
||||||
|
"interpreter": null,
|
||||||
|
"body": [
|
||||||
|
{
|
||||||
|
"type": "ExpressionStatement",
|
||||||
|
"start":0,"end":23,"loc":{"start":{"line":1,"column":0},"end":{"line":3,"column":1}},
|
||||||
|
"expression": {
|
||||||
|
"type": "DoExpression",
|
||||||
|
"start":6,"end":23,"loc":{"start":{"line":1,"column":6},"end":{"line":3,"column":1}},
|
||||||
|
"async": true,
|
||||||
|
"body": {
|
||||||
|
"type": "BlockStatement",
|
||||||
|
"start":9,"end":23,"loc":{"start":{"line":1,"column":9},"end":{"line":3,"column":1}},
|
||||||
|
"body": [
|
||||||
|
{
|
||||||
|
"type": "ExpressionStatement",
|
||||||
|
"start":13,"end":21,"loc":{"start":{"line":2,"column":2},"end":{"line":2,"column":10}},
|
||||||
|
"expression": {
|
||||||
|
"type": "AwaitExpression",
|
||||||
|
"start":13,"end":21,"loc":{"start":{"line":2,"column":2},"end":{"line":2,"column":10}},
|
||||||
|
"argument": {
|
||||||
|
"type": "NumericLiteral",
|
||||||
|
"start":19,"end":21,"loc":{"start":{"line":2,"column":8},"end":{"line":2,"column":10}},
|
||||||
|
"extra": {
|
||||||
|
"rawValue": 42,
|
||||||
|
"raw": "42"
|
||||||
|
},
|
||||||
|
"value": 42
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"directives": []
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"directives": []
|
||||||
|
}
|
||||||
|
}
|
||||||
8
packages/babel-parser/test/fixtures/experimental/async-do-expressions/invalid-break/input.js
vendored
Normal file
8
packages/babel-parser/test/fixtures/experimental/async-do-expressions/invalid-break/input.js
vendored
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
function iter() {
|
||||||
|
switch(1) {
|
||||||
|
default:
|
||||||
|
var x = async do {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
94
packages/babel-parser/test/fixtures/experimental/async-do-expressions/invalid-break/output.json
vendored
Normal file
94
packages/babel-parser/test/fixtures/experimental/async-do-expressions/invalid-break/output.json
vendored
Normal file
@ -0,0 +1,94 @@
|
|||||||
|
{
|
||||||
|
"type": "File",
|
||||||
|
"start":0,"end":99,"loc":{"start":{"line":1,"column":0},"end":{"line":8,"column":2}},
|
||||||
|
"errors": [
|
||||||
|
"SyntaxError: Unsyntactic break (5:8)"
|
||||||
|
],
|
||||||
|
"program": {
|
||||||
|
"type": "Program",
|
||||||
|
"start":0,"end":99,"loc":{"start":{"line":1,"column":0},"end":{"line":8,"column":2}},
|
||||||
|
"sourceType": "script",
|
||||||
|
"interpreter": null,
|
||||||
|
"body": [
|
||||||
|
{
|
||||||
|
"type": "FunctionDeclaration",
|
||||||
|
"start":0,"end":98,"loc":{"start":{"line":1,"column":0},"end":{"line":8,"column":1}},
|
||||||
|
"id": {
|
||||||
|
"type": "Identifier",
|
||||||
|
"start":9,"end":13,"loc":{"start":{"line":1,"column":9},"end":{"line":1,"column":13},"identifierName":"iter"},
|
||||||
|
"name": "iter"
|
||||||
|
},
|
||||||
|
"generator": false,
|
||||||
|
"async": false,
|
||||||
|
"params": [],
|
||||||
|
"body": {
|
||||||
|
"type": "BlockStatement",
|
||||||
|
"start":16,"end":98,"loc":{"start":{"line":1,"column":16},"end":{"line":8,"column":1}},
|
||||||
|
"body": [
|
||||||
|
{
|
||||||
|
"type": "SwitchStatement",
|
||||||
|
"start":20,"end":96,"loc":{"start":{"line":2,"column":2},"end":{"line":7,"column":3}},
|
||||||
|
"discriminant": {
|
||||||
|
"type": "NumericLiteral",
|
||||||
|
"start":27,"end":28,"loc":{"start":{"line":2,"column":9},"end":{"line":2,"column":10}},
|
||||||
|
"extra": {
|
||||||
|
"rawValue": 1,
|
||||||
|
"raw": "1"
|
||||||
|
},
|
||||||
|
"value": 1
|
||||||
|
},
|
||||||
|
"cases": [
|
||||||
|
{
|
||||||
|
"type": "SwitchCase",
|
||||||
|
"start":36,"end":92,"loc":{"start":{"line":3,"column":4},"end":{"line":6,"column":7}},
|
||||||
|
"consequent": [
|
||||||
|
{
|
||||||
|
"type": "VariableDeclaration",
|
||||||
|
"start":51,"end":92,"loc":{"start":{"line":4,"column":6},"end":{"line":6,"column":7}},
|
||||||
|
"declarations": [
|
||||||
|
{
|
||||||
|
"type": "VariableDeclarator",
|
||||||
|
"start":55,"end":92,"loc":{"start":{"line":4,"column":10},"end":{"line":6,"column":7}},
|
||||||
|
"id": {
|
||||||
|
"type": "Identifier",
|
||||||
|
"start":55,"end":56,"loc":{"start":{"line":4,"column":10},"end":{"line":4,"column":11},"identifierName":"x"},
|
||||||
|
"name": "x"
|
||||||
|
},
|
||||||
|
"init": {
|
||||||
|
"type": "DoExpression",
|
||||||
|
"start":65,"end":92,"loc":{"start":{"line":4,"column":20},"end":{"line":6,"column":7}},
|
||||||
|
"async": true,
|
||||||
|
"body": {
|
||||||
|
"type": "BlockStatement",
|
||||||
|
"start":68,"end":92,"loc":{"start":{"line":4,"column":23},"end":{"line":6,"column":7}},
|
||||||
|
"body": [
|
||||||
|
{
|
||||||
|
"type": "BreakStatement",
|
||||||
|
"start":78,"end":84,"loc":{"start":{"line":5,"column":8},"end":{"line":5,"column":14}},
|
||||||
|
"label": null
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"directives": []
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"kind": "var"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"test": null
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"directives": []
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "EmptyStatement",
|
||||||
|
"start":98,"end":99,"loc":{"start":{"line":8,"column":1},"end":{"line":8,"column":2}}
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"directives": []
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,5 @@
|
|||||||
|
async function *iter() {
|
||||||
|
await async do {
|
||||||
|
yield 1;
|
||||||
|
}
|
||||||
|
};
|
||||||
@ -0,0 +1,81 @@
|
|||||||
|
{
|
||||||
|
"type": "File",
|
||||||
|
"start":0,"end":63,"loc":{"start":{"line":1,"column":0},"end":{"line":5,"column":2}},
|
||||||
|
"errors": [
|
||||||
|
"SyntaxError: Missing semicolon (3:9)"
|
||||||
|
],
|
||||||
|
"program": {
|
||||||
|
"type": "Program",
|
||||||
|
"start":0,"end":63,"loc":{"start":{"line":1,"column":0},"end":{"line":5,"column":2}},
|
||||||
|
"sourceType": "script",
|
||||||
|
"interpreter": null,
|
||||||
|
"body": [
|
||||||
|
{
|
||||||
|
"type": "FunctionDeclaration",
|
||||||
|
"start":0,"end":62,"loc":{"start":{"line":1,"column":0},"end":{"line":5,"column":1}},
|
||||||
|
"id": {
|
||||||
|
"type": "Identifier",
|
||||||
|
"start":16,"end":20,"loc":{"start":{"line":1,"column":16},"end":{"line":1,"column":20},"identifierName":"iter"},
|
||||||
|
"name": "iter"
|
||||||
|
},
|
||||||
|
"generator": true,
|
||||||
|
"async": true,
|
||||||
|
"params": [],
|
||||||
|
"body": {
|
||||||
|
"type": "BlockStatement",
|
||||||
|
"start":23,"end":62,"loc":{"start":{"line":1,"column":23},"end":{"line":5,"column":1}},
|
||||||
|
"body": [
|
||||||
|
{
|
||||||
|
"type": "ExpressionStatement",
|
||||||
|
"start":27,"end":60,"loc":{"start":{"line":2,"column":2},"end":{"line":4,"column":3}},
|
||||||
|
"expression": {
|
||||||
|
"type": "AwaitExpression",
|
||||||
|
"start":27,"end":60,"loc":{"start":{"line":2,"column":2},"end":{"line":4,"column":3}},
|
||||||
|
"argument": {
|
||||||
|
"type": "DoExpression",
|
||||||
|
"start":39,"end":60,"loc":{"start":{"line":2,"column":14},"end":{"line":4,"column":3}},
|
||||||
|
"async": true,
|
||||||
|
"body": {
|
||||||
|
"type": "BlockStatement",
|
||||||
|
"start":42,"end":60,"loc":{"start":{"line":2,"column":17},"end":{"line":4,"column":3}},
|
||||||
|
"body": [
|
||||||
|
{
|
||||||
|
"type": "ExpressionStatement",
|
||||||
|
"start":48,"end":53,"loc":{"start":{"line":3,"column":4},"end":{"line":3,"column":9}},
|
||||||
|
"expression": {
|
||||||
|
"type": "Identifier",
|
||||||
|
"start":48,"end":53,"loc":{"start":{"line":3,"column":4},"end":{"line":3,"column":9},"identifierName":"yield"},
|
||||||
|
"name": "yield"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "ExpressionStatement",
|
||||||
|
"start":54,"end":56,"loc":{"start":{"line":3,"column":10},"end":{"line":3,"column":12}},
|
||||||
|
"expression": {
|
||||||
|
"type": "NumericLiteral",
|
||||||
|
"start":54,"end":55,"loc":{"start":{"line":3,"column":10},"end":{"line":3,"column":11}},
|
||||||
|
"extra": {
|
||||||
|
"rawValue": 1,
|
||||||
|
"raw": "1"
|
||||||
|
},
|
||||||
|
"value": 1
|
||||||
|
}
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"directives": []
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"directives": []
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "EmptyStatement",
|
||||||
|
"start":62,"end":63,"loc":{"start":{"line":5,"column":1},"end":{"line":5,"column":2}}
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"directives": []
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,5 @@
|
|||||||
|
function iter() {
|
||||||
|
return async do {
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
};
|
||||||
68
packages/babel-parser/test/fixtures/experimental/async-do-expressions/invalid-return/output.json
vendored
Normal file
68
packages/babel-parser/test/fixtures/experimental/async-do-expressions/invalid-return/output.json
vendored
Normal file
@ -0,0 +1,68 @@
|
|||||||
|
{
|
||||||
|
"type": "File",
|
||||||
|
"start":0,"end":58,"loc":{"start":{"line":1,"column":0},"end":{"line":5,"column":2}},
|
||||||
|
"errors": [
|
||||||
|
"SyntaxError: 'return' outside of function (3:4)"
|
||||||
|
],
|
||||||
|
"program": {
|
||||||
|
"type": "Program",
|
||||||
|
"start":0,"end":58,"loc":{"start":{"line":1,"column":0},"end":{"line":5,"column":2}},
|
||||||
|
"sourceType": "script",
|
||||||
|
"interpreter": null,
|
||||||
|
"body": [
|
||||||
|
{
|
||||||
|
"type": "FunctionDeclaration",
|
||||||
|
"start":0,"end":57,"loc":{"start":{"line":1,"column":0},"end":{"line":5,"column":1}},
|
||||||
|
"id": {
|
||||||
|
"type": "Identifier",
|
||||||
|
"start":9,"end":13,"loc":{"start":{"line":1,"column":9},"end":{"line":1,"column":13},"identifierName":"iter"},
|
||||||
|
"name": "iter"
|
||||||
|
},
|
||||||
|
"generator": false,
|
||||||
|
"async": false,
|
||||||
|
"params": [],
|
||||||
|
"body": {
|
||||||
|
"type": "BlockStatement",
|
||||||
|
"start":16,"end":57,"loc":{"start":{"line":1,"column":16},"end":{"line":5,"column":1}},
|
||||||
|
"body": [
|
||||||
|
{
|
||||||
|
"type": "ReturnStatement",
|
||||||
|
"start":20,"end":55,"loc":{"start":{"line":2,"column":2},"end":{"line":4,"column":3}},
|
||||||
|
"argument": {
|
||||||
|
"type": "DoExpression",
|
||||||
|
"start":33,"end":55,"loc":{"start":{"line":2,"column":15},"end":{"line":4,"column":3}},
|
||||||
|
"async": true,
|
||||||
|
"body": {
|
||||||
|
"type": "BlockStatement",
|
||||||
|
"start":36,"end":55,"loc":{"start":{"line":2,"column":18},"end":{"line":4,"column":3}},
|
||||||
|
"body": [
|
||||||
|
{
|
||||||
|
"type": "ReturnStatement",
|
||||||
|
"start":42,"end":51,"loc":{"start":{"line":3,"column":4},"end":{"line":3,"column":13}},
|
||||||
|
"argument": {
|
||||||
|
"type": "NumericLiteral",
|
||||||
|
"start":49,"end":50,"loc":{"start":{"line":3,"column":11},"end":{"line":3,"column":12}},
|
||||||
|
"extra": {
|
||||||
|
"rawValue": 1,
|
||||||
|
"raw": "1"
|
||||||
|
},
|
||||||
|
"value": 1
|
||||||
|
}
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"directives": []
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"directives": []
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "EmptyStatement",
|
||||||
|
"start":57,"end":58,"loc":{"start":{"line":5,"column":1},"end":{"line":5,"column":2}}
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"directives": []
|
||||||
|
}
|
||||||
|
}
|
||||||
3
packages/babel-parser/test/fixtures/experimental/async-do-expressions/options.json
vendored
Normal file
3
packages/babel-parser/test/fixtures/experimental/async-do-expressions/options.json
vendored
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
{
|
||||||
|
"plugins": ["doExpressions", "asyncDoExpressions"]
|
||||||
|
}
|
||||||
@ -0,0 +1,4 @@
|
|||||||
|
let x = async do {
|
||||||
|
let tmp = f();
|
||||||
|
tmp * tmp + 1
|
||||||
|
};
|
||||||
100
packages/babel-parser/test/fixtures/experimental/async-do-expressions/scoping-variable/output.json
vendored
Normal file
100
packages/babel-parser/test/fixtures/experimental/async-do-expressions/scoping-variable/output.json
vendored
Normal file
@ -0,0 +1,100 @@
|
|||||||
|
{
|
||||||
|
"type": "File",
|
||||||
|
"start":0,"end":54,"loc":{"start":{"line":1,"column":0},"end":{"line":4,"column":2}},
|
||||||
|
"program": {
|
||||||
|
"type": "Program",
|
||||||
|
"start":0,"end":54,"loc":{"start":{"line":1,"column":0},"end":{"line":4,"column":2}},
|
||||||
|
"sourceType": "script",
|
||||||
|
"interpreter": null,
|
||||||
|
"body": [
|
||||||
|
{
|
||||||
|
"type": "VariableDeclaration",
|
||||||
|
"start":0,"end":54,"loc":{"start":{"line":1,"column":0},"end":{"line":4,"column":2}},
|
||||||
|
"declarations": [
|
||||||
|
{
|
||||||
|
"type": "VariableDeclarator",
|
||||||
|
"start":4,"end":53,"loc":{"start":{"line":1,"column":4},"end":{"line":4,"column":1}},
|
||||||
|
"id": {
|
||||||
|
"type": "Identifier",
|
||||||
|
"start":4,"end":5,"loc":{"start":{"line":1,"column":4},"end":{"line":1,"column":5},"identifierName":"x"},
|
||||||
|
"name": "x"
|
||||||
|
},
|
||||||
|
"init": {
|
||||||
|
"type": "DoExpression",
|
||||||
|
"start":14,"end":53,"loc":{"start":{"line":1,"column":14},"end":{"line":4,"column":1}},
|
||||||
|
"async": true,
|
||||||
|
"body": {
|
||||||
|
"type": "BlockStatement",
|
||||||
|
"start":17,"end":53,"loc":{"start":{"line":1,"column":17},"end":{"line":4,"column":1}},
|
||||||
|
"body": [
|
||||||
|
{
|
||||||
|
"type": "VariableDeclaration",
|
||||||
|
"start":21,"end":35,"loc":{"start":{"line":2,"column":2},"end":{"line":2,"column":16}},
|
||||||
|
"declarations": [
|
||||||
|
{
|
||||||
|
"type": "VariableDeclarator",
|
||||||
|
"start":25,"end":34,"loc":{"start":{"line":2,"column":6},"end":{"line":2,"column":15}},
|
||||||
|
"id": {
|
||||||
|
"type": "Identifier",
|
||||||
|
"start":25,"end":28,"loc":{"start":{"line":2,"column":6},"end":{"line":2,"column":9},"identifierName":"tmp"},
|
||||||
|
"name": "tmp"
|
||||||
|
},
|
||||||
|
"init": {
|
||||||
|
"type": "CallExpression",
|
||||||
|
"start":31,"end":34,"loc":{"start":{"line":2,"column":12},"end":{"line":2,"column":15}},
|
||||||
|
"callee": {
|
||||||
|
"type": "Identifier",
|
||||||
|
"start":31,"end":32,"loc":{"start":{"line":2,"column":12},"end":{"line":2,"column":13},"identifierName":"f"},
|
||||||
|
"name": "f"
|
||||||
|
},
|
||||||
|
"arguments": []
|
||||||
|
}
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"kind": "let"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "ExpressionStatement",
|
||||||
|
"start":38,"end":51,"loc":{"start":{"line":3,"column":2},"end":{"line":3,"column":15}},
|
||||||
|
"expression": {
|
||||||
|
"type": "BinaryExpression",
|
||||||
|
"start":38,"end":51,"loc":{"start":{"line":3,"column":2},"end":{"line":3,"column":15}},
|
||||||
|
"left": {
|
||||||
|
"type": "BinaryExpression",
|
||||||
|
"start":38,"end":47,"loc":{"start":{"line":3,"column":2},"end":{"line":3,"column":11}},
|
||||||
|
"left": {
|
||||||
|
"type": "Identifier",
|
||||||
|
"start":38,"end":41,"loc":{"start":{"line":3,"column":2},"end":{"line":3,"column":5},"identifierName":"tmp"},
|
||||||
|
"name": "tmp"
|
||||||
|
},
|
||||||
|
"operator": "*",
|
||||||
|
"right": {
|
||||||
|
"type": "Identifier",
|
||||||
|
"start":44,"end":47,"loc":{"start":{"line":3,"column":8},"end":{"line":3,"column":11},"identifierName":"tmp"},
|
||||||
|
"name": "tmp"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"operator": "+",
|
||||||
|
"right": {
|
||||||
|
"type": "NumericLiteral",
|
||||||
|
"start":50,"end":51,"loc":{"start":{"line":3,"column":14},"end":{"line":3,"column":15}},
|
||||||
|
"extra": {
|
||||||
|
"rawValue": 1,
|
||||||
|
"raw": "1"
|
||||||
|
},
|
||||||
|
"value": 1
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"directives": []
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"kind": "let"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"directives": []
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -22,6 +22,7 @@
|
|||||||
"init": {
|
"init": {
|
||||||
"type": "DoExpression",
|
"type": "DoExpression",
|
||||||
"start":8,"end":76,"loc":{"start":{"line":1,"column":8},"end":{"line":5,"column":1}},
|
"start":8,"end":76,"loc":{"start":{"line":1,"column":8},"end":{"line":5,"column":1}},
|
||||||
|
"async": false,
|
||||||
"body": {
|
"body": {
|
||||||
"type": "BlockStatement",
|
"type": "BlockStatement",
|
||||||
"start":11,"end":76,"loc":{"start":{"line":1,"column":11},"end":{"line":5,"column":1}},
|
"start":11,"end":76,"loc":{"start":{"line":1,"column":11},"end":{"line":5,"column":1}},
|
||||||
|
|||||||
@ -22,6 +22,7 @@
|
|||||||
"init": {
|
"init": {
|
||||||
"type": "DoExpression",
|
"type": "DoExpression",
|
||||||
"start":8,"end":47,"loc":{"start":{"line":1,"column":8},"end":{"line":4,"column":1}},
|
"start":8,"end":47,"loc":{"start":{"line":1,"column":8},"end":{"line":4,"column":1}},
|
||||||
|
"async": false,
|
||||||
"body": {
|
"body": {
|
||||||
"type": "BlockStatement",
|
"type": "BlockStatement",
|
||||||
"start":11,"end":47,"loc":{"start":{"line":1,"column":11},"end":{"line":4,"column":1}},
|
"start":11,"end":47,"loc":{"start":{"line":1,"column":11},"end":{"line":4,"column":1}},
|
||||||
|
|||||||
@ -28,6 +28,10 @@
|
|||||||
"argument": {
|
"argument": {
|
||||||
"type": "JSXElement",
|
"type": "JSXElement",
|
||||||
"start":32,"end":216,"loc":{"start":{"line":3,"column":4},"end":{"line":14,"column":10}},
|
"start":32,"end":216,"loc":{"start":{"line":3,"column":4},"end":{"line":14,"column":10}},
|
||||||
|
"extra": {
|
||||||
|
"parenthesized": true,
|
||||||
|
"parenStart": 26
|
||||||
|
},
|
||||||
"openingElement": {
|
"openingElement": {
|
||||||
"type": "JSXOpeningElement",
|
"type": "JSXOpeningElement",
|
||||||
"start":32,"end":37,"loc":{"start":{"line":3,"column":4},"end":{"line":3,"column":9}},
|
"start":32,"end":37,"loc":{"start":{"line":3,"column":4},"end":{"line":3,"column":9}},
|
||||||
@ -90,6 +94,7 @@
|
|||||||
"expression": {
|
"expression": {
|
||||||
"type": "DoExpression",
|
"type": "DoExpression",
|
||||||
"start":69,"end":197,"loc":{"start":{"line":6,"column":8},"end":{"line":12,"column":9}},
|
"start":69,"end":197,"loc":{"start":{"line":6,"column":8},"end":{"line":12,"column":9}},
|
||||||
|
"async": false,
|
||||||
"body": {
|
"body": {
|
||||||
"type": "BlockStatement",
|
"type": "BlockStatement",
|
||||||
"start":72,"end":197,"loc":{"start":{"line":6,"column":11},"end":{"line":12,"column":9}},
|
"start":72,"end":197,"loc":{"start":{"line":6,"column":11},"end":{"line":12,"column":9}},
|
||||||
@ -173,11 +178,7 @@
|
|||||||
},
|
},
|
||||||
"value": "\n "
|
"value": "\n "
|
||||||
}
|
}
|
||||||
],
|
]
|
||||||
"extra": {
|
|
||||||
"parenthesized": true,
|
|
||||||
"parenStart": 26
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
|
|||||||
@ -29,6 +29,7 @@
|
|||||||
"expression": {
|
"expression": {
|
||||||
"type": "DoExpression",
|
"type": "DoExpression",
|
||||||
"start":9,"end":42,"loc":{"start":{"line":1,"column":9},"end":{"line":1,"column":42}},
|
"start":9,"end":42,"loc":{"start":{"line":1,"column":9},"end":{"line":1,"column":42}},
|
||||||
|
"async": false,
|
||||||
"body": {
|
"body": {
|
||||||
"type": "BlockStatement",
|
"type": "BlockStatement",
|
||||||
"start":12,"end":42,"loc":{"start":{"line":1,"column":12},"end":{"line":1,"column":42}},
|
"start":12,"end":42,"loc":{"start":{"line":1,"column":12},"end":{"line":1,"column":42}},
|
||||||
|
|||||||
@ -44,6 +44,7 @@
|
|||||||
"expression": {
|
"expression": {
|
||||||
"type": "DoExpression",
|
"type": "DoExpression",
|
||||||
"start":34,"end":75,"loc":{"start":{"line":2,"column":11},"end":{"line":2,"column":52}},
|
"start":34,"end":75,"loc":{"start":{"line":2,"column":11},"end":{"line":2,"column":52}},
|
||||||
|
"async": false,
|
||||||
"body": {
|
"body": {
|
||||||
"type": "BlockStatement",
|
"type": "BlockStatement",
|
||||||
"start":37,"end":75,"loc":{"start":{"line":2,"column":14},"end":{"line":2,"column":52}},
|
"start":37,"end":75,"loc":{"start":{"line":2,"column":14},"end":{"line":2,"column":52}},
|
||||||
|
|||||||
@ -29,6 +29,7 @@
|
|||||||
"expression": {
|
"expression": {
|
||||||
"type": "DoExpression",
|
"type": "DoExpression",
|
||||||
"start":9,"end":49,"loc":{"start":{"line":1,"column":9},"end":{"line":1,"column":49}},
|
"start":9,"end":49,"loc":{"start":{"line":1,"column":9},"end":{"line":1,"column":49}},
|
||||||
|
"async": false,
|
||||||
"body": {
|
"body": {
|
||||||
"type": "BlockStatement",
|
"type": "BlockStatement",
|
||||||
"start":12,"end":49,"loc":{"start":{"line":1,"column":12},"end":{"line":1,"column":49}},
|
"start":12,"end":49,"loc":{"start":{"line":1,"column":12},"end":{"line":1,"column":49}},
|
||||||
|
|||||||
@ -29,6 +29,7 @@
|
|||||||
"expression": {
|
"expression": {
|
||||||
"type": "DoExpression",
|
"type": "DoExpression",
|
||||||
"start":9,"end":36,"loc":{"start":{"line":1,"column":9},"end":{"line":1,"column":36}},
|
"start":9,"end":36,"loc":{"start":{"line":1,"column":9},"end":{"line":1,"column":36}},
|
||||||
|
"async": false,
|
||||||
"body": {
|
"body": {
|
||||||
"type": "BlockStatement",
|
"type": "BlockStatement",
|
||||||
"start":12,"end":36,"loc":{"start":{"line":1,"column":12},"end":{"line":1,"column":36}},
|
"start":12,"end":36,"loc":{"start":{"line":1,"column":12},"end":{"line":1,"column":36}},
|
||||||
|
|||||||
@ -29,6 +29,7 @@
|
|||||||
"expression": {
|
"expression": {
|
||||||
"type": "DoExpression",
|
"type": "DoExpression",
|
||||||
"start":9,"end":38,"loc":{"start":{"line":1,"column":9},"end":{"line":1,"column":38}},
|
"start":9,"end":38,"loc":{"start":{"line":1,"column":9},"end":{"line":1,"column":38}},
|
||||||
|
"async": false,
|
||||||
"body": {
|
"body": {
|
||||||
"type": "BlockStatement",
|
"type": "BlockStatement",
|
||||||
"start":12,"end":38,"loc":{"start":{"line":1,"column":12},"end":{"line":1,"column":38}},
|
"start":12,"end":38,"loc":{"start":{"line":1,"column":12},"end":{"line":1,"column":38}},
|
||||||
|
|||||||
@ -28,6 +28,7 @@
|
|||||||
"expression": {
|
"expression": {
|
||||||
"type": "DoExpression",
|
"type": "DoExpression",
|
||||||
"start":9,"end":78,"loc":{"start":{"line":1,"column":9},"end":{"line":4,"column":1}},
|
"start":9,"end":78,"loc":{"start":{"line":1,"column":9},"end":{"line":4,"column":1}},
|
||||||
|
"async": false,
|
||||||
"body": {
|
"body": {
|
||||||
"type": "BlockStatement",
|
"type": "BlockStatement",
|
||||||
"start":12,"end":78,"loc":{"start":{"line":1,"column":12},"end":{"line":4,"column":1}},
|
"start":12,"end":78,"loc":{"start":{"line":1,"column":12},"end":{"line":4,"column":1}},
|
||||||
|
|||||||
@ -29,6 +29,7 @@
|
|||||||
"expression": {
|
"expression": {
|
||||||
"type": "DoExpression",
|
"type": "DoExpression",
|
||||||
"start":9,"end":38,"loc":{"start":{"line":1,"column":9},"end":{"line":1,"column":38}},
|
"start":9,"end":38,"loc":{"start":{"line":1,"column":9},"end":{"line":1,"column":38}},
|
||||||
|
"async": false,
|
||||||
"body": {
|
"body": {
|
||||||
"type": "BlockStatement",
|
"type": "BlockStatement",
|
||||||
"start":12,"end":38,"loc":{"start":{"line":1,"column":12},"end":{"line":1,"column":38}},
|
"start":12,"end":38,"loc":{"start":{"line":1,"column":12},"end":{"line":1,"column":38}},
|
||||||
|
|||||||
@ -29,6 +29,7 @@
|
|||||||
"expression": {
|
"expression": {
|
||||||
"type": "DoExpression",
|
"type": "DoExpression",
|
||||||
"start":9,"end":28,"loc":{"start":{"line":1,"column":9},"end":{"line":1,"column":28}},
|
"start":9,"end":28,"loc":{"start":{"line":1,"column":9},"end":{"line":1,"column":28}},
|
||||||
|
"async": false,
|
||||||
"body": {
|
"body": {
|
||||||
"type": "BlockStatement",
|
"type": "BlockStatement",
|
||||||
"start":12,"end":28,"loc":{"start":{"line":1,"column":12},"end":{"line":1,"column":28}},
|
"start":12,"end":28,"loc":{"start":{"line":1,"column":12},"end":{"line":1,"column":28}},
|
||||||
|
|||||||
@ -25,6 +25,7 @@
|
|||||||
"expression": {
|
"expression": {
|
||||||
"type": "DoExpression",
|
"type": "DoExpression",
|
||||||
"start":9,"end":41,"loc":{"start":{"line":1,"column":9},"end":{"line":1,"column":41}},
|
"start":9,"end":41,"loc":{"start":{"line":1,"column":9},"end":{"line":1,"column":41}},
|
||||||
|
"async": false,
|
||||||
"body": {
|
"body": {
|
||||||
"type": "BlockStatement",
|
"type": "BlockStatement",
|
||||||
"start":12,"end":41,"loc":{"start":{"line":1,"column":12},"end":{"line":1,"column":41}},
|
"start":12,"end":41,"loc":{"start":{"line":1,"column":12},"end":{"line":1,"column":41}},
|
||||||
|
|||||||
@ -40,6 +40,7 @@
|
|||||||
"expression": {
|
"expression": {
|
||||||
"type": "DoExpression",
|
"type": "DoExpression",
|
||||||
"start":34,"end":68,"loc":{"start":{"line":2,"column":11},"end":{"line":2,"column":45}},
|
"start":34,"end":68,"loc":{"start":{"line":2,"column":11},"end":{"line":2,"column":45}},
|
||||||
|
"async": false,
|
||||||
"body": {
|
"body": {
|
||||||
"type": "BlockStatement",
|
"type": "BlockStatement",
|
||||||
"start":37,"end":68,"loc":{"start":{"line":2,"column":14},"end":{"line":2,"column":45}},
|
"start":37,"end":68,"loc":{"start":{"line":2,"column":14},"end":{"line":2,"column":45}},
|
||||||
|
|||||||
@ -25,6 +25,7 @@
|
|||||||
"expression": {
|
"expression": {
|
||||||
"type": "DoExpression",
|
"type": "DoExpression",
|
||||||
"start":9,"end":59,"loc":{"start":{"line":1,"column":9},"end":{"line":1,"column":59}},
|
"start":9,"end":59,"loc":{"start":{"line":1,"column":9},"end":{"line":1,"column":59}},
|
||||||
|
"async": false,
|
||||||
"body": {
|
"body": {
|
||||||
"type": "BlockStatement",
|
"type": "BlockStatement",
|
||||||
"start":12,"end":59,"loc":{"start":{"line":1,"column":12},"end":{"line":1,"column":59}},
|
"start":12,"end":59,"loc":{"start":{"line":1,"column":12},"end":{"line":1,"column":59}},
|
||||||
|
|||||||
@ -25,6 +25,7 @@
|
|||||||
"expression": {
|
"expression": {
|
||||||
"type": "DoExpression",
|
"type": "DoExpression",
|
||||||
"start":9,"end":31,"loc":{"start":{"line":1,"column":9},"end":{"line":1,"column":31}},
|
"start":9,"end":31,"loc":{"start":{"line":1,"column":9},"end":{"line":1,"column":31}},
|
||||||
|
"async": false,
|
||||||
"body": {
|
"body": {
|
||||||
"type": "BlockStatement",
|
"type": "BlockStatement",
|
||||||
"start":12,"end":31,"loc":{"start":{"line":1,"column":12},"end":{"line":1,"column":31}},
|
"start":12,"end":31,"loc":{"start":{"line":1,"column":12},"end":{"line":1,"column":31}},
|
||||||
|
|||||||
@ -25,6 +25,7 @@
|
|||||||
"expression": {
|
"expression": {
|
||||||
"type": "DoExpression",
|
"type": "DoExpression",
|
||||||
"start":9,"end":31,"loc":{"start":{"line":1,"column":9},"end":{"line":1,"column":31}},
|
"start":9,"end":31,"loc":{"start":{"line":1,"column":9},"end":{"line":1,"column":31}},
|
||||||
|
"async": false,
|
||||||
"body": {
|
"body": {
|
||||||
"type": "BlockStatement",
|
"type": "BlockStatement",
|
||||||
"start":12,"end":31,"loc":{"start":{"line":1,"column":12},"end":{"line":1,"column":31}},
|
"start":12,"end":31,"loc":{"start":{"line":1,"column":12},"end":{"line":1,"column":31}},
|
||||||
|
|||||||
@ -25,6 +25,7 @@
|
|||||||
"expression": {
|
"expression": {
|
||||||
"type": "DoExpression",
|
"type": "DoExpression",
|
||||||
"start":9,"end":18,"loc":{"start":{"line":1,"column":9},"end":{"line":1,"column":18}},
|
"start":9,"end":18,"loc":{"start":{"line":1,"column":9},"end":{"line":1,"column":18}},
|
||||||
|
"async": false,
|
||||||
"body": {
|
"body": {
|
||||||
"type": "BlockStatement",
|
"type": "BlockStatement",
|
||||||
"start":12,"end":18,"loc":{"start":{"line":1,"column":12},"end":{"line":1,"column":18}},
|
"start":12,"end":18,"loc":{"start":{"line":1,"column":12},"end":{"line":1,"column":18}},
|
||||||
|
|||||||
@ -25,6 +25,7 @@
|
|||||||
"expression": {
|
"expression": {
|
||||||
"type": "DoExpression",
|
"type": "DoExpression",
|
||||||
"start":9,"end":46,"loc":{"start":{"line":1,"column":9},"end":{"line":1,"column":46}},
|
"start":9,"end":46,"loc":{"start":{"line":1,"column":9},"end":{"line":1,"column":46}},
|
||||||
|
"async": false,
|
||||||
"body": {
|
"body": {
|
||||||
"type": "BlockStatement",
|
"type": "BlockStatement",
|
||||||
"start":12,"end":46,"loc":{"start":{"line":1,"column":12},"end":{"line":1,"column":46}},
|
"start":12,"end":46,"loc":{"start":{"line":1,"column":12},"end":{"line":1,"column":46}},
|
||||||
|
|||||||
@ -25,6 +25,7 @@
|
|||||||
"expression": {
|
"expression": {
|
||||||
"type": "DoExpression",
|
"type": "DoExpression",
|
||||||
"start":9,"end":38,"loc":{"start":{"line":1,"column":9},"end":{"line":1,"column":38}},
|
"start":9,"end":38,"loc":{"start":{"line":1,"column":9},"end":{"line":1,"column":38}},
|
||||||
|
"async": false,
|
||||||
"body": {
|
"body": {
|
||||||
"type": "BlockStatement",
|
"type": "BlockStatement",
|
||||||
"start":12,"end":38,"loc":{"start":{"line":1,"column":12},"end":{"line":1,"column":38}},
|
"start":12,"end":38,"loc":{"start":{"line":1,"column":12},"end":{"line":1,"column":38}},
|
||||||
|
|||||||
@ -25,6 +25,7 @@
|
|||||||
"expression": {
|
"expression": {
|
||||||
"type": "DoExpression",
|
"type": "DoExpression",
|
||||||
"start":9,"end":27,"loc":{"start":{"line":1,"column":9},"end":{"line":1,"column":27}},
|
"start":9,"end":27,"loc":{"start":{"line":1,"column":9},"end":{"line":1,"column":27}},
|
||||||
|
"async": false,
|
||||||
"body": {
|
"body": {
|
||||||
"type": "BlockStatement",
|
"type": "BlockStatement",
|
||||||
"start":12,"end":27,"loc":{"start":{"line":1,"column":12},"end":{"line":1,"column":27}},
|
"start":12,"end":27,"loc":{"start":{"line":1,"column":12},"end":{"line":1,"column":27}},
|
||||||
|
|||||||
@ -25,6 +25,7 @@
|
|||||||
"expression": {
|
"expression": {
|
||||||
"type": "DoExpression",
|
"type": "DoExpression",
|
||||||
"start":9,"end":33,"loc":{"start":{"line":1,"column":9},"end":{"line":1,"column":33}},
|
"start":9,"end":33,"loc":{"start":{"line":1,"column":9},"end":{"line":1,"column":33}},
|
||||||
|
"async": false,
|
||||||
"body": {
|
"body": {
|
||||||
"type": "BlockStatement",
|
"type": "BlockStatement",
|
||||||
"start":12,"end":33,"loc":{"start":{"line":1,"column":12},"end":{"line":1,"column":33}},
|
"start":12,"end":33,"loc":{"start":{"line":1,"column":12},"end":{"line":1,"column":33}},
|
||||||
|
|||||||
@ -25,6 +25,7 @@
|
|||||||
"expression": {
|
"expression": {
|
||||||
"type": "DoExpression",
|
"type": "DoExpression",
|
||||||
"start":9,"end":94,"loc":{"start":{"line":1,"column":9},"end":{"line":7,"column":1}},
|
"start":9,"end":94,"loc":{"start":{"line":1,"column":9},"end":{"line":7,"column":1}},
|
||||||
|
"async": false,
|
||||||
"body": {
|
"body": {
|
||||||
"type": "BlockStatement",
|
"type": "BlockStatement",
|
||||||
"start":12,"end":94,"loc":{"start":{"line":1,"column":12},"end":{"line":7,"column":1}},
|
"start":12,"end":94,"loc":{"start":{"line":1,"column":12},"end":{"line":7,"column":1}},
|
||||||
|
|||||||
@ -25,6 +25,7 @@
|
|||||||
"expression": {
|
"expression": {
|
||||||
"type": "DoExpression",
|
"type": "DoExpression",
|
||||||
"start":9,"end":83,"loc":{"start":{"line":1,"column":9},"end":{"line":7,"column":1}},
|
"start":9,"end":83,"loc":{"start":{"line":1,"column":9},"end":{"line":7,"column":1}},
|
||||||
|
"async": false,
|
||||||
"body": {
|
"body": {
|
||||||
"type": "BlockStatement",
|
"type": "BlockStatement",
|
||||||
"start":12,"end":83,"loc":{"start":{"line":1,"column":12},"end":{"line":7,"column":1}},
|
"start":12,"end":83,"loc":{"start":{"line":1,"column":12},"end":{"line":7,"column":1}},
|
||||||
|
|||||||
@ -25,6 +25,7 @@
|
|||||||
"expression": {
|
"expression": {
|
||||||
"type": "DoExpression",
|
"type": "DoExpression",
|
||||||
"start":9,"end":117,"loc":{"start":{"line":1,"column":9},"end":{"line":5,"column":1}},
|
"start":9,"end":117,"loc":{"start":{"line":1,"column":9},"end":{"line":5,"column":1}},
|
||||||
|
"async": false,
|
||||||
"body": {
|
"body": {
|
||||||
"type": "BlockStatement",
|
"type": "BlockStatement",
|
||||||
"start":12,"end":117,"loc":{"start":{"line":1,"column":12},"end":{"line":5,"column":1}},
|
"start":12,"end":117,"loc":{"start":{"line":1,"column":12},"end":{"line":5,"column":1}},
|
||||||
@ -50,12 +51,12 @@
|
|||||||
"start":22,"end":26,"loc":{"start":{"line":2,"column":8},"end":{"line":2,"column":12},"identifierName":"JSON"},
|
"start":22,"end":26,"loc":{"start":{"line":2,"column":8},"end":{"line":2,"column":12},"identifierName":"JSON"},
|
||||||
"name": "JSON"
|
"name": "JSON"
|
||||||
},
|
},
|
||||||
|
"computed": false,
|
||||||
"property": {
|
"property": {
|
||||||
"type": "Identifier",
|
"type": "Identifier",
|
||||||
"start":27,"end":32,"loc":{"start":{"line":2,"column":13},"end":{"line":2,"column":18},"identifierName":"parse"},
|
"start":27,"end":32,"loc":{"start":{"line":2,"column":13},"end":{"line":2,"column":18},"identifierName":"parse"},
|
||||||
"name": "parse"
|
"name": "parse"
|
||||||
},
|
}
|
||||||
"computed": false
|
|
||||||
},
|
},
|
||||||
"arguments": [
|
"arguments": [
|
||||||
{
|
{
|
||||||
@ -95,12 +96,12 @@
|
|||||||
"start":64,"end":71,"loc":{"start":{"line":3,"column":18},"end":{"line":3,"column":25},"identifierName":"console"},
|
"start":64,"end":71,"loc":{"start":{"line":3,"column":18},"end":{"line":3,"column":25},"identifierName":"console"},
|
||||||
"name": "console"
|
"name": "console"
|
||||||
},
|
},
|
||||||
|
"computed": false,
|
||||||
"property": {
|
"property": {
|
||||||
"type": "Identifier",
|
"type": "Identifier",
|
||||||
"start":72,"end":77,"loc":{"start":{"line":3,"column":26},"end":{"line":3,"column":31},"identifierName":"error"},
|
"start":72,"end":77,"loc":{"start":{"line":3,"column":26},"end":{"line":3,"column":31},"identifierName":"error"},
|
||||||
"name": "error"
|
"name": "error"
|
||||||
},
|
}
|
||||||
"computed": false
|
|
||||||
},
|
},
|
||||||
"arguments": [
|
"arguments": [
|
||||||
{
|
{
|
||||||
|
|||||||
@ -25,6 +25,7 @@
|
|||||||
"expression": {
|
"expression": {
|
||||||
"type": "DoExpression",
|
"type": "DoExpression",
|
||||||
"start":9,"end":109,"loc":{"start":{"line":1,"column":9},"end":{"line":5,"column":1}},
|
"start":9,"end":109,"loc":{"start":{"line":1,"column":9},"end":{"line":5,"column":1}},
|
||||||
|
"async": false,
|
||||||
"body": {
|
"body": {
|
||||||
"type": "BlockStatement",
|
"type": "BlockStatement",
|
||||||
"start":12,"end":109,"loc":{"start":{"line":1,"column":12},"end":{"line":5,"column":1}},
|
"start":12,"end":109,"loc":{"start":{"line":1,"column":12},"end":{"line":5,"column":1}},
|
||||||
@ -50,12 +51,12 @@
|
|||||||
"start":22,"end":26,"loc":{"start":{"line":2,"column":8},"end":{"line":2,"column":12},"identifierName":"JSON"},
|
"start":22,"end":26,"loc":{"start":{"line":2,"column":8},"end":{"line":2,"column":12},"identifierName":"JSON"},
|
||||||
"name": "JSON"
|
"name": "JSON"
|
||||||
},
|
},
|
||||||
|
"computed": false,
|
||||||
"property": {
|
"property": {
|
||||||
"type": "Identifier",
|
"type": "Identifier",
|
||||||
"start":27,"end":32,"loc":{"start":{"line":2,"column":13},"end":{"line":2,"column":18},"identifierName":"parse"},
|
"start":27,"end":32,"loc":{"start":{"line":2,"column":13},"end":{"line":2,"column":18},"identifierName":"parse"},
|
||||||
"name": "parse"
|
"name": "parse"
|
||||||
},
|
}
|
||||||
"computed": false
|
|
||||||
},
|
},
|
||||||
"arguments": [
|
"arguments": [
|
||||||
{
|
{
|
||||||
@ -94,12 +95,12 @@
|
|||||||
"start":57,"end":64,"loc":{"start":{"line":3,"column":18},"end":{"line":3,"column":25},"identifierName":"console"},
|
"start":57,"end":64,"loc":{"start":{"line":3,"column":18},"end":{"line":3,"column":25},"identifierName":"console"},
|
||||||
"name": "console"
|
"name": "console"
|
||||||
},
|
},
|
||||||
|
"computed": false,
|
||||||
"property": {
|
"property": {
|
||||||
"type": "Identifier",
|
"type": "Identifier",
|
||||||
"start":65,"end":70,"loc":{"start":{"line":3,"column":26},"end":{"line":3,"column":31},"identifierName":"error"},
|
"start":65,"end":70,"loc":{"start":{"line":3,"column":26},"end":{"line":3,"column":31},"identifierName":"error"},
|
||||||
"name": "error"
|
"name": "error"
|
||||||
},
|
}
|
||||||
"computed": false
|
|
||||||
},
|
},
|
||||||
"arguments": [
|
"arguments": [
|
||||||
{
|
{
|
||||||
|
|||||||
@ -25,6 +25,7 @@
|
|||||||
"expression": {
|
"expression": {
|
||||||
"type": "DoExpression",
|
"type": "DoExpression",
|
||||||
"start":9,"end":82,"loc":{"start":{"line":1,"column":9},"end":{"line":4,"column":1}},
|
"start":9,"end":82,"loc":{"start":{"line":1,"column":9},"end":{"line":4,"column":1}},
|
||||||
|
"async": false,
|
||||||
"body": {
|
"body": {
|
||||||
"type": "BlockStatement",
|
"type": "BlockStatement",
|
||||||
"start":12,"end":82,"loc":{"start":{"line":1,"column":12},"end":{"line":4,"column":1}},
|
"start":12,"end":82,"loc":{"start":{"line":1,"column":12},"end":{"line":4,"column":1}},
|
||||||
@ -50,12 +51,12 @@
|
|||||||
"start":22,"end":26,"loc":{"start":{"line":2,"column":8},"end":{"line":2,"column":12},"identifierName":"JSON"},
|
"start":22,"end":26,"loc":{"start":{"line":2,"column":8},"end":{"line":2,"column":12},"identifierName":"JSON"},
|
||||||
"name": "JSON"
|
"name": "JSON"
|
||||||
},
|
},
|
||||||
|
"computed": false,
|
||||||
"property": {
|
"property": {
|
||||||
"type": "Identifier",
|
"type": "Identifier",
|
||||||
"start":27,"end":32,"loc":{"start":{"line":2,"column":13},"end":{"line":2,"column":18},"identifierName":"parse"},
|
"start":27,"end":32,"loc":{"start":{"line":2,"column":13},"end":{"line":2,"column":18},"identifierName":"parse"},
|
||||||
"name": "parse"
|
"name": "parse"
|
||||||
},
|
}
|
||||||
"computed": false
|
|
||||||
},
|
},
|
||||||
"arguments": [
|
"arguments": [
|
||||||
{
|
{
|
||||||
@ -94,12 +95,12 @@
|
|||||||
"start":57,"end":64,"loc":{"start":{"line":3,"column":18},"end":{"line":3,"column":25},"identifierName":"console"},
|
"start":57,"end":64,"loc":{"start":{"line":3,"column":18},"end":{"line":3,"column":25},"identifierName":"console"},
|
||||||
"name": "console"
|
"name": "console"
|
||||||
},
|
},
|
||||||
|
"computed": false,
|
||||||
"property": {
|
"property": {
|
||||||
"type": "Identifier",
|
"type": "Identifier",
|
||||||
"start":65,"end":70,"loc":{"start":{"line":3,"column":26},"end":{"line":3,"column":31},"identifierName":"error"},
|
"start":65,"end":70,"loc":{"start":{"line":3,"column":26},"end":{"line":3,"column":31},"identifierName":"error"},
|
||||||
"name": "error"
|
"name": "error"
|
||||||
},
|
}
|
||||||
"computed": false
|
|
||||||
},
|
},
|
||||||
"arguments": [
|
"arguments": [
|
||||||
{
|
{
|
||||||
|
|||||||
@ -25,6 +25,7 @@
|
|||||||
"expression": {
|
"expression": {
|
||||||
"type": "DoExpression",
|
"type": "DoExpression",
|
||||||
"start":9,"end":37,"loc":{"start":{"line":1,"column":9},"end":{"line":1,"column":37}},
|
"start":9,"end":37,"loc":{"start":{"line":1,"column":9},"end":{"line":1,"column":37}},
|
||||||
|
"async": false,
|
||||||
"body": {
|
"body": {
|
||||||
"type": "BlockStatement",
|
"type": "BlockStatement",
|
||||||
"start":12,"end":37,"loc":{"start":{"line":1,"column":12},"end":{"line":1,"column":37}},
|
"start":12,"end":37,"loc":{"start":{"line":1,"column":12},"end":{"line":1,"column":37}},
|
||||||
|
|||||||
@ -108,6 +108,7 @@ export interface ParserOptions {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export type ParserPlugin =
|
export type ParserPlugin =
|
||||||
|
| "asyncDoExpressions"
|
||||||
| "asyncGenerators"
|
| "asyncGenerators"
|
||||||
| "bigInt"
|
| "bigInt"
|
||||||
| "classPrivateMethods"
|
| "classPrivateMethods"
|
||||||
|
|||||||
@ -11,7 +11,12 @@ export default declare(api => {
|
|||||||
visitor: {
|
visitor: {
|
||||||
DoExpression: {
|
DoExpression: {
|
||||||
exit(path) {
|
exit(path) {
|
||||||
const body = path.node.body.body;
|
const { node } = path;
|
||||||
|
if (node.async) {
|
||||||
|
// Async do expressions are not yet supported
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
const body = node.body.body;
|
||||||
if (body.length) {
|
if (body.length) {
|
||||||
path.replaceExpressionWithStatements(body);
|
path.replaceExpressionWithStatements(body);
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@ -0,0 +1 @@
|
|||||||
|
(async do {});
|
||||||
@ -0,0 +1 @@
|
|||||||
|
async do {};
|
||||||
@ -0,0 +1,3 @@
|
|||||||
|
{
|
||||||
|
"plugins": ["syntax-async-do-expressions", "proposal-do-expressions"]
|
||||||
|
}
|
||||||
@ -0,0 +1,3 @@
|
|||||||
|
src
|
||||||
|
test
|
||||||
|
*.log
|
||||||
19
packages/babel-plugin-syntax-async-do-expressions/README.md
Normal file
19
packages/babel-plugin-syntax-async-do-expressions/README.md
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
# @babel/plugin-syntax-async-do-expressions
|
||||||
|
|
||||||
|
> Allow parsing of async do expressions
|
||||||
|
|
||||||
|
See our website [@babel/plugin-syntax-async-do-expressions](https://babel.dev/docs/en/babel-plugin-syntax-async-do-expressions) for more information.
|
||||||
|
|
||||||
|
## Install
|
||||||
|
|
||||||
|
Using npm:
|
||||||
|
|
||||||
|
```sh
|
||||||
|
npm install --save-dev @babel/plugin-syntax-async-do-expressions
|
||||||
|
```
|
||||||
|
|
||||||
|
or using yarn:
|
||||||
|
|
||||||
|
```sh
|
||||||
|
yarn add @babel/plugin-syntax-async-do-expressions --dev
|
||||||
|
```
|
||||||
@ -0,0 +1,31 @@
|
|||||||
|
{
|
||||||
|
"name": "@babel/plugin-syntax-async-do-expressions",
|
||||||
|
"version": "7.13.0",
|
||||||
|
"description": "Allow parsing of async do expressions",
|
||||||
|
"repository": {
|
||||||
|
"type": "git",
|
||||||
|
"url": "https://github.com/babel/babel.git",
|
||||||
|
"directory": "packages/babel-plugin-syntax-async-do-expressions"
|
||||||
|
},
|
||||||
|
"license": "MIT",
|
||||||
|
"publishConfig": {
|
||||||
|
"access": "public"
|
||||||
|
},
|
||||||
|
"main": "./lib/index.js",
|
||||||
|
"exports": {
|
||||||
|
".": "./lib/index.js"
|
||||||
|
},
|
||||||
|
"keywords": [
|
||||||
|
"babel-plugin"
|
||||||
|
],
|
||||||
|
"dependencies": {
|
||||||
|
"@babel/helper-plugin-utils": "workspace:^7.12.13"
|
||||||
|
},
|
||||||
|
"peerDependencies": {
|
||||||
|
"@babel/core": "^7.0.0-0"
|
||||||
|
},
|
||||||
|
"devDependencies": {
|
||||||
|
"@babel/core": "workspace:*"
|
||||||
|
},
|
||||||
|
"homepage": "https://babel.dev/docs/en/next/babel-plugin-syntax-async-do-expressions"
|
||||||
|
}
|
||||||
@ -0,0 +1,13 @@
|
|||||||
|
import { declare } from "@babel/helper-plugin-utils";
|
||||||
|
|
||||||
|
export default declare(api => {
|
||||||
|
api.assertVersion(7);
|
||||||
|
|
||||||
|
return {
|
||||||
|
name: "syntax-async-do-expressions",
|
||||||
|
|
||||||
|
manipulateOptions(opts, parserOpts) {
|
||||||
|
parserOpts.plugins.push("asyncDoExpressions", "doExpressions");
|
||||||
|
},
|
||||||
|
};
|
||||||
|
});
|
||||||
@ -1609,6 +1609,7 @@ export interface Decorator extends BaseNode {
|
|||||||
export interface DoExpression extends BaseNode {
|
export interface DoExpression extends BaseNode {
|
||||||
type: "DoExpression";
|
type: "DoExpression";
|
||||||
body: BlockStatement;
|
body: BlockStatement;
|
||||||
|
async: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface ExportDefaultSpecifier extends BaseNode {
|
export interface ExportDefaultSpecifier extends BaseNode {
|
||||||
|
|||||||
@ -1051,7 +1051,10 @@ export function importAttribute(
|
|||||||
export function decorator(expression: t.Expression): t.Decorator {
|
export function decorator(expression: t.Expression): t.Decorator {
|
||||||
return builder("Decorator", ...arguments);
|
return builder("Decorator", ...arguments);
|
||||||
}
|
}
|
||||||
export function doExpression(body: t.BlockStatement): t.DoExpression {
|
export function doExpression(
|
||||||
|
body: t.BlockStatement,
|
||||||
|
async?: boolean,
|
||||||
|
): t.DoExpression {
|
||||||
return builder("DoExpression", ...arguments);
|
return builder("DoExpression", ...arguments);
|
||||||
}
|
}
|
||||||
export function exportDefaultSpecifier(
|
export function exportDefaultSpecifier(
|
||||||
|
|||||||
@ -188,11 +188,16 @@ defineType("Decorator", {
|
|||||||
|
|
||||||
defineType("DoExpression", {
|
defineType("DoExpression", {
|
||||||
visitor: ["body"],
|
visitor: ["body"],
|
||||||
|
builder: ["body", "async"],
|
||||||
aliases: ["Expression"],
|
aliases: ["Expression"],
|
||||||
fields: {
|
fields: {
|
||||||
body: {
|
body: {
|
||||||
validate: assertNodeType("BlockStatement"),
|
validate: assertNodeType("BlockStatement"),
|
||||||
},
|
},
|
||||||
|
async: {
|
||||||
|
validate: assertValueType("boolean"),
|
||||||
|
default: false,
|
||||||
|
},
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
11
yarn.lock
11
yarn.lock
@ -1512,6 +1512,17 @@ __metadata:
|
|||||||
languageName: unknown
|
languageName: unknown
|
||||||
linkType: soft
|
linkType: soft
|
||||||
|
|
||||||
|
"@babel/plugin-syntax-async-do-expressions@workspace:packages/babel-plugin-syntax-async-do-expressions":
|
||||||
|
version: 0.0.0-use.local
|
||||||
|
resolution: "@babel/plugin-syntax-async-do-expressions@workspace:packages/babel-plugin-syntax-async-do-expressions"
|
||||||
|
dependencies:
|
||||||
|
"@babel/core": "workspace:*"
|
||||||
|
"@babel/helper-plugin-utils": "workspace:^7.12.13"
|
||||||
|
peerDependencies:
|
||||||
|
"@babel/core": ^7.0.0-0
|
||||||
|
languageName: unknown
|
||||||
|
linkType: soft
|
||||||
|
|
||||||
"@babel/plugin-syntax-async-generators@npm:^7.8.4":
|
"@babel/plugin-syntax-async-generators@npm:^7.8.4":
|
||||||
version: 7.8.4
|
version: 7.8.4
|
||||||
resolution: "@babel/plugin-syntax-async-generators@npm:7.8.4"
|
resolution: "@babel/plugin-syntax-async-generators@npm:7.8.4"
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user