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