From f9ba350e1c433f71f73a851f2da2bd220e9af468 Mon Sep 17 00:00:00 2001 From: Paul Romano Date: Fri, 25 Mar 2022 11:44:01 -0500 Subject: [PATCH] Add fix for Region.from_expression case with )( --- openmc/region.py | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/openmc/region.py b/openmc/region.py index b252ff4a72..8efee7c4ec 100644 --- a/openmc/region.py +++ b/openmc/region.py @@ -116,14 +116,20 @@ class Region(ABC): # For everything other than intersection, add the operator # to the list of tokens tokens.append(expression[i]) + + # If two parentheses appear immediately adjacent to one + # another, we need an intersection between them + if expression[i:i+2] == ')(': + tokens.append(' ') else: # Find next non-space character while expression[i+1] == ' ': i += 1 - # If previous token is a halfspace or right parenthesis and next token - # is not a left parenthese or union operator, that implies that the - # whitespace is to be interpreted as an intersection operator + # If previous token is a halfspace or right parenthesis and + # next token is not a left parenthesis or union operator, + # that implies that the whitespace is to be interpreted as + # an intersection operator if (i_start >= 0 or tokens[-1] == ')') and \ expression[i+1] not in ')|': tokens.append(' ')