correct bug in brainfuck.py (in function 'interpret') and add full debug support
This commit is contained in:
parent
c97caeee7e
commit
61b4c2cc9c
11
brainfuck.py
11
brainfuck.py
|
@ -61,7 +61,18 @@ def interpret(prog):
|
||||||
if ar[ptr]:
|
if ar[ptr]:
|
||||||
index = blocks.pop()
|
index = blocks.pop()
|
||||||
continue
|
continue
|
||||||
|
else:
|
||||||
|
blocks.pop()
|
||||||
elif instr == '#':
|
elif instr == '#':
|
||||||
|
try:
|
||||||
|
if prog[index+1] == '(':
|
||||||
|
index = index+2
|
||||||
|
while prog[index] != ')':
|
||||||
|
print(prog[index],end='',flush=True)
|
||||||
|
index += 1
|
||||||
|
print(' ',end='')
|
||||||
|
except IndexError:
|
||||||
|
pass
|
||||||
print(ar, ptr, ar[ptr])
|
print(ar, ptr, ar[ptr])
|
||||||
|
|
||||||
index += 1
|
index += 1
|
||||||
|
|
Loading…
Reference in New Issue