7
私は現在、Brainfuckインタプリタを言語で書いてNimrodとお付き合いしています。現在、実装されたループせずに、私が持っている:NimrodのBrainfuckインタプリタ
import os, unsigned
const RamSize = 200
type
TRam = array[0..RamSize, int]
var
ram : TRam
ip : int = 0
dp : int = 0
proc readCode(path: string) =
var
f : TFile = open(path)
i : int = 0
while i < RamSize and not EndOfFile(f):
ram[i] = ord(readChar(f))
inc(i)
proc main(path: string) =
readCode(path)
while ip < RamSize:
case chr(ram[ip])
of '>' : inc dp
of '<' : dec dp
of '+' : inc ram[dp]
of '-' : dec ram[dp]
of '.' : write stdout, chr(ram[dp])
else : nil
inc(ip)
echo()
if paramcount() == 1: main(paramstr(1))
else: echo("usage: bfrun PATH")
をそれは正常にコンパイルが、私はそれで入力を投げる時に好き:
文字に「」それは返す「N.を印刷する必要があります>
+++++ +++++
+++++ +++++
+++++ +++++
+++++ +++++
+++++ +++++
+++++ +++++
+++++ .
'何か案は?
よろしくお願い致します。解決策は、キャリッジリターンでインクリメントする問題を回避するために別のRAM「テープ」を追加しています。 –