From 89335fbdc6d7b64ad83ae9e7e36fd1edc179ee54 Mon Sep 17 00:00:00 2001 From: hasslesstech Date: Wed, 14 Oct 2026 20:44:20 +0300 Subject: [PATCH] fix remove_extra_brackets undoing work of post-processing step --- inc/expression.hpp | 15 +++++++++++++++ src/syntaxer.cpp | 6 ++++++ 2 files changed, 21 insertions(+) diff --git a/inc/expression.hpp b/inc/expression.hpp index 6b90fcf..1d431ba 100644 --- a/inc/expression.hpp +++ b/inc/expression.hpp @@ -277,6 +277,21 @@ public: return "Invalid operator"; } } + + int negative_operator(void) const + { + if (t != OPERATOR) + { + return 0; + } + + return (v.o == SUB || v.o == DIV); + } + + static int is_negative(Operator o) + { + return (o == SUB || o == DIV); + } }; struct Operation diff --git a/src/syntaxer.cpp b/src/syntaxer.cpp index 6ddfd77..2cfd9ae 100644 --- a/src/syntaxer.cpp +++ b/src/syntaxer.cpp @@ -709,6 +709,12 @@ static void remove_extra_brackets(std::vector& tv) continue; } + // check specifically if the opening undoes applied fixes + if (Expression::Token::is_negative(get_prior_mop(tv, get_mop_location(tv, r.start)))) + { + continue; + } + open_brackets(tv, r); } }