Talk:Son of a BitCh
Jump to navigation
Jump to search
Interpreter
This interpreter needs to fix. Created by User:Cycwin.
code="<>>>>><><>>>>"
pointer=0
tape=[0]
tapepointer=0
storage="d"
output="00000000"
while pointer<len(code):
i=code[pointer]
if i==">":
if storage=="d":
if not tapepointer<len(tape)-1:
tape.append(0)
tapepointer+=1
storage="diojn"["diojn".index(storage)+1 if storage!="n" else 0]
if i=="<":
if storage=="d":
tape[tapepointer]=int(not tape[tapepointer])
if tapepointer==0:
tape.insert(0,0)
else:
tapepointer-=1
elif storage=="i":
#I do not understand this section.I just use if input in ascii is odd.
print("output:"+chr(eval("0b"+output)))
tape[tapepointer]=ord(input()[0])%2
elif storage=="o":
#I do not understand this too.
output+=str(tape[tapepointer])
if len(output)>8:
output=output[1:]
elif storage=="j":
j=len(output)-1
c=0
t=19 if code[pointer + 1 if pointer<len(code)-1 else 0]!=">" else 38
while c==t or j==0:
if code[j]=="<":
c+=1
pointer=j
elif storage=="n":
continue
pointer+=1
print(tape,pointer,tapepointer)