patterns: Fix boolean operations and cast syntax

This commit is contained in:
WerWolv
2021-09-24 12:15:50 +02:00
parent 93c1fbd65e
commit 71be77c54b
2 changed files with 14 additions and 17 deletions

View File

@@ -170,14 +170,11 @@ namespace hex::pl {
if (builtinType == nullptr)
throwParseError("invalid type used for pointer size", -1);
if (!MATCHES(sequence(SEPARATOR_ROUNDBRACKETOPEN)))
if (!peek(SEPARATOR_ROUNDBRACKETOPEN))
throwParseError("expected '(' before cast expression", -1);
auto node = parseFactor();
if (!MATCHES(sequence(SEPARATOR_ROUNDBRACKETCLOSE)))
throwParseError("expected ')' after cast expression", -1);
return new ASTNodeCast(node, type);
} else return parseFactor();
}
@@ -327,7 +324,7 @@ namespace hex::pl {
auto nodeCleanup = SCOPE_GUARD { delete node; };
while (MATCHES(sequence(OPERATOR_BOOLAND))) {
node = create(new ASTNodeMathematicalExpression(node, this->parseBinaryOrExpression(), Token::Operator::BitOr));
node = create(new ASTNodeMathematicalExpression(node, this->parseBinaryOrExpression(), Token::Operator::BoolAnd));
}
nodeCleanup.release();
@@ -342,7 +339,7 @@ namespace hex::pl {
auto nodeCleanup = SCOPE_GUARD { delete node; };
while (MATCHES(sequence(OPERATOR_BOOLXOR))) {
node = create(new ASTNodeMathematicalExpression(node, this->parseBooleanAnd(), Token::Operator::BitOr));
node = create(new ASTNodeMathematicalExpression(node, this->parseBooleanAnd(), Token::Operator::BoolXor));
}
nodeCleanup.release();
@@ -357,7 +354,7 @@ namespace hex::pl {
auto nodeCleanup = SCOPE_GUARD { delete node; };
while (MATCHES(sequence(OPERATOR_BOOLOR))) {
node = create(new ASTNodeMathematicalExpression(node, this->parseBooleanXor(), Token::Operator::BitOr));
node = create(new ASTNodeMathematicalExpression(node, this->parseBooleanXor(), Token::Operator::BoolOr));
}
nodeCleanup.release();