Skip to content

Commit

Permalink
fix(z3): catch edge case with regex with nested XORs
Browse files Browse the repository at this point in the history
  • Loading branch information
bliutech committed Jul 19, 2024
1 parent 030c08d commit da4e1e5
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions solver/passes/z3_pass.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,12 @@ def run_pass(ast: Expr) -> Expr:
# this is a hack to fix that

# Pattern to match "Xor(A, B)"
pattern = r"Xor\((\w+), (\w+)\)"
pattern = r"Xor\(([A-Z \|&\^\(\)]+), ([A-Z \|&\^\(\)]+)\)"
# Replacement string using backreferences to capture groups
replacement = r"\1 ^ \2"
# Performing the replacement
simplifiedStr = re.sub(pattern, replacement, simplifiedStr)
# Performing the replacement. Loop to catch nested Xor calls
while re.match(pattern, simplifiedStr):
simplifiedStr = re.sub(pattern, replacement, simplifiedStr)

l: Lexer = Lexer()
l.lex(simplifiedStr)
Expand Down

0 comments on commit da4e1e5

Please sign in to comment.