mirror of
https://github.com/fergalmoran/ladybird.git
synced 2026-01-06 08:36:15 +00:00
LibJS: Implement update expressions
Note that currently only the non-prefixed variant is supported (i.e i++ not ++i), this variant returns the value of the argument before the update.
This commit is contained in:
committed by
Andreas Kling
parent
dc9a702aa8
commit
8557bc56f7
@@ -174,6 +174,12 @@ NonnullOwnPtr<Expression> Parser::parse_secondary_expression(NonnullOwnPtr<Expre
|
||||
case TokenType::Period:
|
||||
consume();
|
||||
return make<MemberExpression>(move(lhs), parse_expression());
|
||||
case TokenType::PlusPlus:
|
||||
consume();
|
||||
return make<UpdateExpression>(UpdateOp::Increment, move(lhs));
|
||||
case TokenType::MinusMinus:
|
||||
consume();
|
||||
return make<UpdateExpression>(UpdateOp::Decrement, move(lhs));
|
||||
default:
|
||||
m_has_errors = true;
|
||||
expected("secondary expression (missing switch case)");
|
||||
@@ -352,7 +358,9 @@ bool Parser::match_secondary_expression() const
|
||||
|| type == TokenType::LessThan
|
||||
|| type == TokenType::LessThanEquals
|
||||
|| type == TokenType::ParenOpen
|
||||
|| type == TokenType::Period;
|
||||
|| type == TokenType::Period
|
||||
|| type == TokenType::PlusPlus
|
||||
|| type == TokenType::MinusMinus;
|
||||
}
|
||||
|
||||
bool Parser::match_statement() const
|
||||
|
||||
Reference in New Issue
Block a user