Skip to content

Commit

Permalink
Parse { as expressionStatement when whiteblockOnly enabled
Browse files Browse the repository at this point in the history
  • Loading branch information
wcjohnson committed Sep 28, 2017
1 parent afd89a2 commit 160ee23
Show file tree
Hide file tree
Showing 6 changed files with 423 additions and 9 deletions.
2 changes: 2 additions & 0 deletions src/parser/statement.js
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,8 @@ pp.parseStatement = function (declaration, topLevel) {
// in lightscript, allow line-starting `{` to be parsed as obj or obj pattern
if (this.hasPlugin("lightscript") && this.isLineBreak()) {
break;
} else if (this.hasPlugin("whiteblockOnly")) {
break;
} else {
return this.parseBlock();
}
Expand Down
3 changes: 2 additions & 1 deletion test/fixtures/comments/basic/comment-within-condition/expected.json
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,8 @@
"end": {
"line": 2,
"column": 16
}
},
"identifierName": "a"
},
"name": "a",
"leadingComments": [
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,169 @@
{
"type": "File",
"start": 0,
"end": 30,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 2,
"column": 20
}
},
"program": {
"type": "Program",
"start": 0,
"end": 30,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 2,
"column": 20
}
},
"sourceType": "script",
"body": [
{
"type": "IfStatement",
"start": 10,
"end": 30,
"loc": {
"start": {
"line": 2,
"column": 0
},
"end": {
"line": 2,
"column": 20
}
},
"test": {
"type": "Identifier",
"start": 25,
"end": 26,
"loc": {
"start": {
"line": 2,
"column": 15
},
"end": {
"line": 2,
"column": 16
},
"identifierName": "a"
},
"name": "a",
"leadingComments": [
{
"type": "CommentBlock",
"value": " bar ",
"start": 14,
"end": 23,
"loc": {
"start": {
"line": 2,
"column": 4
},
"end": {
"line": 2,
"column": 13
}
}
}
],
"extra": {}
},
"consequent": {
"type": "ExpressionStatement",
"start": 28,
"end": 30,
"loc": {
"start": {
"line": 2,
"column": 18
},
"end": {
"line": 2,
"column": 20
}
},
"expression": {
"type": "ObjectExpression",
"start": 28,
"end": 30,
"loc": {
"start": {
"line": 2,
"column": 18
},
"end": {
"line": 2,
"column": 20
}
},
"properties": []
}
},
"alternate": null,
"leadingComments": [
{
"type": "CommentBlock",
"value": " foo ",
"start": 0,
"end": 9,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 1,
"column": 9
}
}
}
]
}
],
"directives": []
},
"comments": [
{
"type": "CommentBlock",
"value": " foo ",
"start": 0,
"end": 9,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 1,
"column": 9
}
}
},
{
"type": "CommentBlock",
"value": " bar ",
"start": 14,
"end": 23,
"loc": {
"start": {
"line": 2,
"column": 4
},
"end": {
"line": 2,
"column": 13
}
}
}
]
}

This file was deleted.

Loading

0 comments on commit 160ee23

Please sign in to comment.