mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-05-02 01:08:48 +00:00
LibJS: Implement nullish coalescing operator (??)
This commit is contained in:
parent
1806592d58
commit
d14ddb6461
Notes:
sideshowbarker
2024-07-19 07:31:09 +09:00
Author: https://github.com/linusg
Commit: d14ddb6461
Pull-request: https://github.com/SerenityOS/serenity/pull/1832
Reviewed-by: https://github.com/awesomekling
4 changed files with 60 additions and 12 deletions
|
@ -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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue