diff options
author | Itamar <itamar8910@gmail.com> | 2021-04-02 11:15:51 +0300 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2021-04-06 21:51:58 +0200 |
commit | ec2c54ee2e1092fd8e8a26ce4044b35b69523640 (patch) | |
tree | 77068b52b808e41b5686514134fa9c641ca8f891 /Userland | |
parent | 44833f1621358c0c8ec9f82eb49d36bc70a63ae3 (diff) | |
download | serenity-ec2c54ee2e1092fd8e8a26ce4044b35b69523640.zip |
LibCpp: Parse "arrow" operator
Diffstat (limited to 'Userland')
-rw-r--r-- | Userland/Libraries/LibCpp/AST.cpp | 3 | ||||
-rw-r--r-- | Userland/Libraries/LibCpp/AST.h | 1 | ||||
-rw-r--r-- | Userland/Libraries/LibCpp/Parser.cpp | 5 |
3 files changed, 8 insertions, 1 deletions
diff --git a/Userland/Libraries/LibCpp/AST.cpp b/Userland/Libraries/LibCpp/AST.cpp index d3fe00e2fa..5dbedc52cf 100644 --- a/Userland/Libraries/LibCpp/AST.cpp +++ b/Userland/Libraries/LibCpp/AST.cpp @@ -215,6 +215,9 @@ void BinaryExpression::dump(size_t indent) const case BinaryOp::LogicalAnd: op_string = "&&"; break; + case BinaryOp::Arrow: + op_string = "->"; + break; } m_lhs->dump(indent + 1); diff --git a/Userland/Libraries/LibCpp/AST.h b/Userland/Libraries/LibCpp/AST.h index 902c9645fb..51289f0477 100644 --- a/Userland/Libraries/LibCpp/AST.h +++ b/Userland/Libraries/LibCpp/AST.h @@ -422,6 +422,7 @@ enum class BinaryOp { NotEqual, LogicalOr, LogicalAnd, + Arrow, }; class BinaryExpression : public Expression { diff --git a/Userland/Libraries/LibCpp/Parser.cpp b/Userland/Libraries/LibCpp/Parser.cpp index 443bc79c5c..e00aeb2528 100644 --- a/Userland/Libraries/LibCpp/Parser.cpp +++ b/Userland/Libraries/LibCpp/Parser.cpp @@ -425,7 +425,8 @@ bool Parser::match_secondary_expression() || type == Token::Type::AndAnd || type == Token::Type::PipePipe || type == Token::Type::ExclamationMarkEquals - || type == Token::Type::PipePipe; + || type == Token::Type::PipePipe + || type == Token::Type::Arrow; } NonnullRefPtr<Expression> Parser::parse_primary_expression(ASTNode& parent) @@ -577,6 +578,8 @@ NonnullRefPtr<Expression> Parser::parse_secondary_expression(ASTNode& parent, No return parse_binary_expression(parent, lhs, BinaryOp::BitwiseOr); case Token::Type::PipePipe: return parse_binary_expression(parent, lhs, BinaryOp::LogicalOr); + case Token::Type::Arrow: + return parse_binary_expression(parent, lhs, BinaryOp::Arrow); case Token::Type::Equals: return parse_assignment_expression(parent, lhs, AssignmentOp::Assignment); case Token::Type::Dot: { |