mirror of
https://github.com/fergalmoran/ladybird.git
synced 2025-12-25 10:48:41 +00:00
LibJS: Implement nullish coalescing operator (??)
This commit is contained in:
committed by
Andreas Kling
parent
1806592d58
commit
d14ddb6461
@@ -601,6 +601,9 @@ NonnullRefPtr<Expression> Parser::parse_secondary_expression(NonnullRefPtr<Expre
|
||||
case TokenType::DoublePipe:
|
||||
consume();
|
||||
return create_ast_node<LogicalExpression>(LogicalOp::Or, move(lhs), parse_expression(min_precedence, associativity));
|
||||
case TokenType::DoubleQuestionMark:
|
||||
consume();
|
||||
return create_ast_node<LogicalExpression>(LogicalOp::NullishCoalescing, move(lhs), parse_expression(min_precedence, associativity));
|
||||
case TokenType::QuestionMark:
|
||||
return parse_conditional_expression(move(lhs));
|
||||
default:
|
||||
@@ -1039,7 +1042,8 @@ bool Parser::match_secondary_expression() const
|
||||
|| type == TokenType::Pipe
|
||||
|| type == TokenType::Caret
|
||||
|| type == TokenType::DoubleAmpersand
|
||||
|| type == TokenType::DoublePipe;
|
||||
|| type == TokenType::DoublePipe
|
||||
|| type == TokenType::DoubleQuestionMark;
|
||||
}
|
||||
|
||||
bool Parser::match_statement() const
|
||||
|
||||
Reference in New Issue
Block a user