Skip to content

Commit

Permalink
Add startsExpr to <-
Browse files Browse the repository at this point in the history
  • Loading branch information
wcjohnson committed Oct 22, 2017
1 parent e4e4202 commit ec0d413
Show file tree
Hide file tree
Showing 5 changed files with 250 additions and 111 deletions.
2 changes: 1 addition & 1 deletion src/tokenizer/types.js
Expand Up @@ -56,7 +56,7 @@ export class BinopTokenType extends TokenType {
export const types = {
// LightScript
tilde: new TokenType("~"),
awaitArrow: new TokenType("<-", { beforeExpr, isAssign }),
awaitArrow: new TokenType("<-", { startsExpr, beforeExpr, isAssign }),
elvis: new TokenType("?."),

num: new TokenType("num", { startsExpr }),
Expand Down
2 changes: 2 additions & 0 deletions test/fixtures/lightscript/await-arrow/after-bang/actual.js
@@ -0,0 +1,2 @@
f() -/>
console.log! <- x
209 changes: 209 additions & 0 deletions test/fixtures/lightscript/await-arrow/after-bang/expected.json
@@ -0,0 +1,209 @@
{
"type": "File",
"start": 0,
"end": 27,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 2,
"column": 19
}
},
"program": {
"type": "Program",
"start": 0,
"end": 27,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 2,
"column": 19
}
},
"sourceType": "script",
"body": [
{
"type": "NamedArrowDeclaration",
"start": 0,
"end": 27,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 2,
"column": 19
}
},
"id": {
"type": "Identifier",
"start": 0,
"end": 1,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 1,
"column": 1
},
"identifierName": "f"
},
"name": "f"
},
"generator": false,
"expression": false,
"async": true,
"params": [],
"skinny": true,
"body": {
"type": "BlockStatement",
"start": 4,
"end": 27,
"loc": {
"start": {
"line": 1,
"column": 4
},
"end": {
"line": 2,
"column": 19
}
},
"body": [
{
"type": "ExpressionStatement",
"start": 10,
"end": 27,
"loc": {
"start": {
"line": 2,
"column": 2
},
"end": {
"line": 2,
"column": 19
}
},
"expression": {
"type": "CallExpression",
"start": 10,
"end": 27,
"loc": {
"start": {
"line": 2,
"column": 2
},
"end": {
"line": 2,
"column": 19
}
},
"callee": {
"type": "MemberExpression",
"start": 10,
"end": 21,
"loc": {
"start": {
"line": 2,
"column": 2
},
"end": {
"line": 2,
"column": 13
}
},
"object": {
"type": "Identifier",
"start": 10,
"end": 17,
"loc": {
"start": {
"line": 2,
"column": 2
},
"end": {
"line": 2,
"column": 9
},
"identifierName": "console"
},
"name": "console"
},
"property": {
"type": "Identifier",
"start": 18,
"end": 21,
"loc": {
"start": {
"line": 2,
"column": 10
},
"end": {
"line": 2,
"column": 13
},
"identifierName": "log"
},
"name": "log"
},
"computed": false
},
"arguments": [
{
"type": "AwaitExpression",
"start": 23,
"end": 27,
"loc": {
"start": {
"line": 2,
"column": 15
},
"end": {
"line": 2,
"column": 19
}
},
"argument": {
"type": "Identifier",
"start": 26,
"end": 27,
"loc": {
"start": {
"line": 2,
"column": 18
},
"end": {
"line": 2,
"column": 19
},
"identifierName": "x"
},
"name": "x"
}
}
],
"extra": {
"bang": true
}
}
}
],
"directives": [],
"extra": {
"curly": false
}
}
}
],
"directives": []
}
}
Expand Up @@ -60,76 +60,40 @@
"name": "f"
},
"generator": false,
"expression": false,
"expression": true,
"async": true,
"params": [],
"skinny": true,
"body": {
"type": "BlockStatement",
"start": 4,
"type": "AwaitExpression",
"start": 8,
"end": 12,
"loc": {
"start": {
"line": 1,
"column": 4
"column": 8
},
"end": {
"line": 1,
"column": 12
}
},
"body": [
{
"type": "ExpressionStatement",
"start": 8,
"end": 12,
"loc": {
"start": {
"line": 1,
"column": 8
},
"end": {
"line": 1,
"column": 12
}
"argument": {
"type": "Identifier",
"start": 11,
"end": 12,
"loc": {
"start": {
"line": 1,
"column": 11
},
"expression": {
"type": "AwaitExpression",
"start": 8,
"end": 12,
"loc": {
"start": {
"line": 1,
"column": 8
},
"end": {
"line": 1,
"column": 12
}
},
"argument": {
"type": "Identifier",
"start": 11,
"end": 12,
"loc": {
"start": {
"line": 1,
"column": 11
},
"end": {
"line": 1,
"column": 12
},
"identifierName": "x"
},
"name": "x"
}
}
}
],
"directives": [],
"extra": {
"curly": false
"end": {
"line": 1,
"column": 12
},
"identifierName": "x"
},
"name": "x"
}
}
}
Expand Down

0 comments on commit ec0d413

Please sign in to comment.