mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 07:48:11 +00:00
LibJS: Parse binary bitwise operators
The Lexer and AST already have all the functionality required in place, so this is just updating Parser::match_secondary_expression() and Parser::parse_expression() to handle TokenType::{Ampersand,Pipe,Caret}, as well as adding some tests.
This commit is contained in:
parent
0622181d1f
commit
a58640ce6b
2 changed files with 76 additions and 1 deletions
|
@ -490,6 +490,15 @@ NonnullRefPtr<Expression> Parser::parse_secondary_expression(NonnullRefPtr<Expre
|
|||
case TokenType::Instanceof:
|
||||
consume();
|
||||
return create_ast_node<BinaryExpression>(BinaryOp::InstanceOf, move(lhs), parse_expression(min_precedence, associativity));
|
||||
case TokenType::Ampersand:
|
||||
consume();
|
||||
return create_ast_node<BinaryExpression>(BinaryOp::BitwiseAnd, move(lhs), parse_expression(min_precedence, associativity));
|
||||
case TokenType::Pipe:
|
||||
consume();
|
||||
return create_ast_node<BinaryExpression>(BinaryOp::BitwiseOr, move(lhs), parse_expression(min_precedence, associativity));
|
||||
case TokenType::Caret:
|
||||
consume();
|
||||
return create_ast_node<BinaryExpression>(BinaryOp::BitwiseXor, move(lhs), parse_expression(min_precedence, associativity));
|
||||
case TokenType::ParenOpen:
|
||||
return parse_call_expression(move(lhs));
|
||||
case TokenType::Equals:
|
||||
|
@ -877,7 +886,10 @@ bool Parser::match_secondary_expression() const
|
|||
|| type == TokenType::PlusPlus
|
||||
|| type == TokenType::MinusMinus
|
||||
|| type == TokenType::Instanceof
|
||||
|| type == TokenType::QuestionMark;
|
||||
|| type == TokenType::QuestionMark
|
||||
|| type == TokenType::Ampersand
|
||||
|| type == TokenType::Pipe
|
||||
|| type == TokenType::Caret;
|
||||
}
|
||||
|
||||
bool Parser::match_statement() const
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue