Talk:Quiney
Jump to navigation
Jump to search
Working on an interpreter.
Should be ready by the evening, there's some bugginess with loops. 50.161.94.113 17:08, 23 January 2016 (UTC)
- ...Do not ever trust my time estimates. Here you go:
#Quiney interpreter By this person program=list(input("Quiney program:")+" ") instructions=[" ","[","+",".","}","{",",","-","]","*"] pc=-1;dp=0 while pc+1<len(program): pc+=1 if False: #debug print("\nDebug") print("".join(program)) print((" "*pc)+"^") print((" "*dp)+"^") print("Output") if program[pc]=="[": if program[dp]==" ": nest=0 while not (nest==0 and program[pc]!="["): if program[pc]=="[": nest+=1 if program[pc]=="]": nest-=1 pc+=1 if pc>len(program): pc=100000000 print("end") break pc-=1 continue if program[pc]=="]": if not program[dp]==" ": nest=0 while not (nest==0 and program[pc]!="]"): if program[pc]=="[": nest+=1 if program[pc]=="]": nest-=1 pc-=1 if pc<-1: pc=100000000 #bad way of saying "shut up and terminate" print("end") break pc+=1 continue if program[pc]=="+": program[dp]=instructions[(instructions.index(program[dp])+1)%10] continue if program[pc]=="-": program[dp]=instructions[(instructions.index(program[dp])-1)%10] continue if program[pc]==".": print(program[dp],end="") if program[pc]==",": program[dp]=input("") if program[pc]=="{": dp-=1 if program[pc]=="}": dp+=1 if dp==-1: program.insert(0," ") dp+=1 pc+=1 if dp==len(program): program.append(" ") if program[pc]=="*": program[dp]=instructions[10-instructions.index(program[dp])%10]
Run in python 3, then ...um 50.161.94.113 17:08, 23 January 2016 (UTC)