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); } }