This repository has been archived by the owner on May 19, 2018. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 258
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implement nullish coalescing operator in parser (#761)
* Implement nullish coalescing operator in parser * Add ?? to AST
- Loading branch information
Showing
10 changed files
with
121 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -791,6 +791,7 @@ enum BinaryOperator { | |
| "|" | "^" | "&" | "in" | ||
| "instanceof" | ||
| "|>" | ||
| "??" | ||
} | ||
``` | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1 change: 1 addition & 0 deletions
1
test/fixtures/experimental/nullish-coalescing-operator/expression/actual.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
foo ?? 1; |
102 changes: 102 additions & 0 deletions
102
test/fixtures/experimental/nullish-coalescing-operator/expression/expected.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,102 @@ | ||
{ | ||
"type": "File", | ||
"start": 0, | ||
"end": 9, | ||
"loc": { | ||
"start": { | ||
"line": 1, | ||
"column": 0 | ||
}, | ||
"end": { | ||
"line": 1, | ||
"column": 9 | ||
} | ||
}, | ||
"program": { | ||
"type": "Program", | ||
"start": 0, | ||
"end": 9, | ||
"loc": { | ||
"start": { | ||
"line": 1, | ||
"column": 0 | ||
}, | ||
"end": { | ||
"line": 1, | ||
"column": 9 | ||
} | ||
}, | ||
"sourceType": "script", | ||
"body": [ | ||
{ | ||
"type": "ExpressionStatement", | ||
"start": 0, | ||
"end": 9, | ||
"loc": { | ||
"start": { | ||
"line": 1, | ||
"column": 0 | ||
}, | ||
"end": { | ||
"line": 1, | ||
"column": 9 | ||
} | ||
}, | ||
"expression": { | ||
"type": "BinaryExpression", | ||
"start": 0, | ||
"end": 8, | ||
"loc": { | ||
"start": { | ||
"line": 1, | ||
"column": 0 | ||
}, | ||
"end": { | ||
"line": 1, | ||
"column": 8 | ||
} | ||
}, | ||
"left": { | ||
"type": "Identifier", | ||
"start": 0, | ||
"end": 3, | ||
"loc": { | ||
"start": { | ||
"line": 1, | ||
"column": 0 | ||
}, | ||
"end": { | ||
"line": 1, | ||
"column": 3 | ||
}, | ||
"identifierName": "foo" | ||
}, | ||
"name": "foo" | ||
}, | ||
"operator": "??", | ||
"right": { | ||
"type": "NumericLiteral", | ||
"start": 7, | ||
"end": 8, | ||
"loc": { | ||
"start": { | ||
"line": 1, | ||
"column": 7 | ||
}, | ||
"end": { | ||
"line": 1, | ||
"column": 8 | ||
} | ||
}, | ||
"extra": { | ||
"rawValue": 1, | ||
"raw": "1" | ||
}, | ||
"value": 1 | ||
} | ||
} | ||
} | ||
], | ||
"directives": [] | ||
} | ||
} |
3 changes: 3 additions & 0 deletions
3
test/fixtures/experimental/nullish-coalescing-operator/expression/options.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
{ | ||
"plugins": ["nullishCoalescingOperator"] | ||
} |
1 change: 1 addition & 0 deletions
1
test/fixtures/experimental/nullish-coalescing-operator/no-plugin-error/actual.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
foo ?? 1; |
3 changes: 3 additions & 0 deletions
3
test/fixtures/experimental/nullish-coalescing-operator/no-plugin-error/options.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
{ | ||
"throws": "This experimental syntax requires enabling the parser plugin: 'nullishCoalescingOperator' (1:7)" | ||
} |