diff --git a/plugins/libimhex/include/hex/pattern_language/ast_node.hpp b/plugins/libimhex/include/hex/pattern_language/ast_node.hpp index e1b997cc8..9afc55ac6 100644 --- a/plugins/libimhex/include/hex/pattern_language/ast_node.hpp +++ b/plugins/libimhex/include/hex/pattern_language/ast_node.hpp @@ -203,25 +203,25 @@ namespace hex::pl { case Token::Operator::BitNot: return new ASTNodeLiteral(bitNot(left, right)); case Token::Operator::BoolEquals: - return new ASTNodeLiteral(left == right); + return new ASTNodeLiteral(bool(left == right)); case Token::Operator::BoolNotEquals: - return new ASTNodeLiteral(left != right); + return new ASTNodeLiteral(bool(left != right)); case Token::Operator::BoolGreaterThan: - return new ASTNodeLiteral(left > right); + return new ASTNodeLiteral(bool(left > right)); case Token::Operator::BoolLessThan: - return new ASTNodeLiteral(left < right); + return new ASTNodeLiteral(bool(left < right)); case Token::Operator::BoolGreaterThanOrEquals: - return new ASTNodeLiteral(left >= right); + return new ASTNodeLiteral(bool(left >= right)); case Token::Operator::BoolLessThanOrEquals: - return new ASTNodeLiteral(left <= right); + return new ASTNodeLiteral(bool(left <= right)); case Token::Operator::BoolAnd: - return new ASTNodeLiteral(left && right); + return new ASTNodeLiteral(bool(left && right)); case Token::Operator::BoolXor: - return new ASTNodeLiteral(left && !right || !left && right); + return new ASTNodeLiteral(bool(left && !right || !left && right)); case Token::Operator::BoolOr: - return new ASTNodeLiteral(left || right); + return new ASTNodeLiteral(bool(left || right)); case Token::Operator::BoolNot: - return new ASTNodeLiteral(!right); + return new ASTNodeLiteral(bool(!right)); default: LogConsole::abortEvaluation("invalid operand used in mathematical expression", this); } diff --git a/plugins/libimhex/source/pattern_language/parser.cpp b/plugins/libimhex/source/pattern_language/parser.cpp index 2d6448448..223675136 100644 --- a/plugins/libimhex/source/pattern_language/parser.cpp +++ b/plugins/libimhex/source/pattern_language/parser.cpp @@ -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();