Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 24b06d1

Browse files
committed
Add throw, co_await & co_yield
1 parent 2ea90b8 commit 24b06d1

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

src/parser/expressions/expr.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -994,6 +994,15 @@ impl<'a, L: TLexer> ExpressionParser<'a, L> {
994994
self.operands.push(ExprNode::This(Box::new(This {})));
995995
self.last = LastKind::Operand;
996996
}
997+
Token::Throw => {
998+
self.push_operator(Operator::Throw);
999+
}
1000+
Token::CoAwait => {
1001+
self.push_operator(Operator::CoAwait);
1002+
}
1003+
Token::CoYield => {
1004+
self.push_operator(Operator::CoYield);
1005+
}
9971006
Token::True => {
9981007
self.operands
9991008
.push(ExprNode::Bool(Box::new(Bool { value: true })));

src/parser/expressions/operator.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,8 @@ impl Operator {
7777
use Operator::*;
7878

7979
match self {
80-
Plus | Minus | Not | BitNeg | Sizeof | PreInc | PreDec | Indirection | AddressOf => {
80+
Plus | Minus | Not | BitNeg | Sizeof | PreInc | PreDec | Indirection | AddressOf
81+
| Throw | CoAwait | CoYield => {
8182
let arg = stack.pop().unwrap();
8283
stack.push(ExprNode::UnaryOp(Box::new(UnaryOp { op: self, arg })));
8384
}

0 commit comments

Comments
 (0)