LibJS/Parser: Parse logical expressions

This commit is contained in:
0xtechnobabble 2020-03-15 23:35:22 +02:00 committed by Andreas Kling
parent 94088640f1
commit 419d57e492
Notes: sideshowbarker 2024-07-19 08:16:52 +09:00

View file

@ -348,6 +348,12 @@ NonnullOwnPtr<Expression> Parser::parse_secondary_expression(NonnullOwnPtr<Expre
case TokenType::MinusMinus:
consume();
return make<UpdateExpression>(UpdateOp::Decrement, move(lhs));
case TokenType::DoubleAmpersand:
consume();
return make<LogicalExpression>(LogicalOp::And, move(lhs), parse_expression(min_precedence, associativity));
case TokenType::DoublePipe:
consume();
return make<LogicalExpression>(LogicalOp::Or, move(lhs), parse_expression(min_precedence, associativity));
default:
m_has_errors = true;
expected("secondary expression (missing switch case)");