これは私のinterpereterのコードです:
program=list(raw_input('Program: '))
array = [0 for i in range(100)]
pointer=0
prgpointer=0
run = True
while run:
try:
command = program[prgpointer]
if command == '>':
pointer += 1
if command == '<':
pointer -= 1
if command == '+':
array[pointer]=array[pointer]+1
if command == '-':
array[pointer]=array[pointer]-1
if command == '.':
print(array[pointer])
if command == '[' and array[pointer]==0:
while program[prgpointer]!=']':
prgpointer+=1
if command == ']' and array[pointer]!=0:
while program[prgpointer]!='[':
prgpointer-=1
except:
run = False
prgpointer+=1
このプログラムを実行すると:
++++++++[>++++[>++>+++>+++>+<<<<-]>+>+>->>+[<]<-]>>.>---.+++++++..+++.>>.<-.<.+++.------.--------.>>+.>++.
私はの結果を得る
-1
-3
4
4
7
0
-2
7
10
4
-4
1
1
このプログラムは、他の bf インターペリターで機能する 'hello world' プログラムです。出力が ASCII に変換されても、「Hello World」ではありません。 私のインターペリターについて指摘できる大きな問題はありますか? コマンドは正しいですか?