From: Nick Downing Date: Mon, 21 Jul 2025 08:26:50 +0000 (+1000) Subject: Fix a bug in /scripts/circuits.py where it could use symbol again during search X-Git-Url: https://git.ndcode.org/public/gitweb.cgi?a=commitdiff_plain;h=6f9fe2078bbe6b80858a053bb1c075690d16ca10;p=multi_sim.git Fix a bug in /scripts/circuits.py where it could use symbol again during search --- diff --git a/scripts/circuits.py b/scripts/circuits.py index 6371a71..287c13b 100755 --- a/scripts/circuits.py +++ b/scripts/circuits.py @@ -383,8 +383,10 @@ for circuit_find, circuit_replace, circuit_internal in CIRCUITS: if tt == at and len(t) == len(a): #print('trying symbol', i, j) circuit_symbols[i] = j + symbol_actual[0] = -1 # delete symbol during search match(1, (0, t, a, stack)) #print('failed symbol', i, j) + symbol_actual[0] = at # reinstate symbol on backtrack circuit_symbols[i] = -1 # not really necessary return @@ -469,18 +471,16 @@ for circuit_find, circuit_replace, circuit_internal in CIRCUITS: if tt == at and len(t) == len(a): #print('trying symbol', 0, i) circuit_symbols[0] = i + symbol_actual[0] = -1 # delete symbol during search try: match(1, (0, t, a, stack)) #print('failed symbol', 0, i) + symbol_actual[0] = at # reinstate symbol on backtrack circuit_symbols[0] = -1 # not really necessary except Match: # block is taken from last template symbol (often the output) block = symbols[circuit_symbols[-1]][1] - # delete old symbols - for j in circuit_symbols: - symbols[j][0] = -1 - # add new symbols for symbol_type, template in circuit_replace: symbols.append((symbol_type, block, substitute(template)))