summaryrefslogtreecommitdiff
path: root/Userland/Libraries
diff options
context:
space:
mode:
Diffstat (limited to 'Userland/Libraries')
-rw-r--r--Userland/Libraries/LibCpp/AST.cpp9
-rw-r--r--Userland/Libraries/LibCpp/AST.h3
-rw-r--r--Userland/Libraries/LibCpp/Parser.cpp17
3 files changed, 27 insertions, 2 deletions
diff --git a/Userland/Libraries/LibCpp/AST.cpp b/Userland/Libraries/LibCpp/AST.cpp
index 601b689807..f5088dbf5d 100644
--- a/Userland/Libraries/LibCpp/AST.cpp
+++ b/Userland/Libraries/LibCpp/AST.cpp
@@ -209,6 +209,12 @@ void BinaryExpression::dump(size_t indent) const
case BinaryOp::NotEqual:
op_string = "!=";
break;
+ case BinaryOp::LogicalOr:
+ op_string = "||";
+ break;
+ case BinaryOp::LogicalAnd:
+ op_string = "&&";
+ break;
}
m_lhs->dump(indent + 1);
@@ -319,6 +325,9 @@ void UnaryExpression::dump(size_t indent) const
case UnaryOp::PlusPlus:
op_string = "++";
break;
+ case UnaryOp::Address:
+ op_string = "&";
+ break;
default:
op_string = "<invalid>";
}
diff --git a/Userland/Libraries/LibCpp/AST.h b/Userland/Libraries/LibCpp/AST.h
index a5f1ca356c..04c1247340 100644
--- a/Userland/Libraries/LibCpp/AST.h
+++ b/Userland/Libraries/LibCpp/AST.h
@@ -420,6 +420,8 @@ enum class BinaryOp {
RightShift,
EqualsEquals,
NotEqual,
+ LogicalOr,
+ LogicalAnd,
};
class BinaryExpression : public Expression {
@@ -582,6 +584,7 @@ enum class UnaryOp {
Plus,
Minus,
PlusPlus,
+ Address,
};
class UnaryExpression : public Expression {
diff --git a/Userland/Libraries/LibCpp/Parser.cpp b/Userland/Libraries/LibCpp/Parser.cpp
index 2fb02a84eb..49b2f68f80 100644
--- a/Userland/Libraries/LibCpp/Parser.cpp
+++ b/Userland/Libraries/LibCpp/Parser.cpp
@@ -421,7 +421,8 @@ bool Parser::match_secondary_expression()
|| type == Token::Type::EqualsEquals
|| type == Token::Type::AndAnd
|| type == Token::Type::PipePipe
- || type == Token::Type::ExclamationMarkEquals;
+ || type == Token::Type::ExclamationMarkEquals
+ || type == Token::Type::PipePipe;
}
NonnullRefPtr<Expression> Parser::parse_primary_expression(ASTNode& parent)
@@ -481,7 +482,8 @@ bool Parser::match_unary_expression()
|| type == Token::Type::ExclamationMark
|| type == Token::Type::Tilde
|| type == Token::Type::Plus
- || type == Token::Type::Minus;
+ || type == Token::Type::Minus
+ || type == Token::Type::And;
}
NonnullRefPtr<UnaryExpression> Parser::parse_unary_expression(ASTNode& parent)
@@ -505,6 +507,9 @@ NonnullRefPtr<UnaryExpression> Parser::parse_unary_expression(ASTNode& parent)
case Token::Type::PlusPlus:
op = UnaryOp::PlusPlus;
break;
+ case Token::Type::And:
+ op = UnaryOp::Address;
+ break;
default:
break;
}
@@ -555,6 +560,14 @@ NonnullRefPtr<Expression> Parser::parse_secondary_expression(ASTNode& parent, No
return parse_binary_expression(parent, lhs, BinaryOp::EqualsEquals);
case Token::Type::ExclamationMarkEquals:
return parse_binary_expression(parent, lhs, BinaryOp::NotEqual);
+ case Token::Type::And:
+ return parse_binary_expression(parent, lhs, BinaryOp::BitwiseAnd);
+ case Token::Type::AndAnd:
+ return parse_binary_expression(parent, lhs, BinaryOp::LogicalAnd);
+ case Token::Type::Pipe:
+ return parse_binary_expression(parent, lhs, BinaryOp::BitwiseOr);
+ case Token::Type::PipePipe:
+ return parse_binary_expression(parent, lhs, BinaryOp::LogicalOr);
case Token::Type::Equals:
return parse_assignment_expression(parent, lhs, AssignmentOp::Assignment);
case Token::Type::Dot: {