From a3c15fb07fcf51fec6fdeaa7faa665960b53c796 Mon Sep 17 00:00:00 2001 From: myerspat Date: Fri, 5 Aug 2022 17:01:09 -0400 Subject: [PATCH] Proper parenthesis handling for De Morgans --- src/cell.cpp | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/cell.cpp b/src/cell.cpp index c89e437acd..12fb9f6740 100644 --- a/src/cell.cpp +++ b/src/cell.cpp @@ -773,7 +773,17 @@ void CSGCell::remove_complement_ops(vector& infix) // Define stop given left parenthesis or not auto stop = it; if (*it == OP_LEFT_PAREN) { - stop = std::find(it, infix.end(), OP_RIGHT_PAREN); + int depth = 1; + do { + stop++; + if (*stop > OP_COMPLEMENT) { + if (*stop == OP_RIGHT_PAREN) { + depth--; + } else { + depth++; + } + } + } while (depth > 0); it++; }