brainf*ck.io の続き

#!/usr/local/bin/io

doFile("bf.io")

>+++++++++[<++++++++>-]<.>+++++++[<++++>-]<+.+++++++..+++.[-]>++++++++
[<++++>-]<.>+++++++++++[<+++++>-]<.>++++++++[<+++>-]<.+++.------.--------.
[-]>++++++++[<++++>-]<+.[-]++++++++++.

以下 bf.io

vm := List clone
for(a, 0, 100, vm push(0))
index := 0

through := method(s, m,
  if (m,
    a := m argAt(0)
    if (a, s doMessage(a))
  )
)
setSlot(">", method(
    index = index + 1
    through(sender, thisMessage)
))
setSlot("<", method(
    index = index - 1
    through(sender, thisMessage)
))
setSlot("+", method(
    vm atPut(index, vm at(index) + 1)
    through(sender, thisMessage)
))
setSlot("-", method(
    vm atPut(index, vm at(index) - 1)
    through(sender, thisMessage)
))
setSlot(".", method(
    write(vm at(index) asCharacter)
    through(sender, thisMessage)
))
// i cannot implement ","
setSlot("'", method(
    vm atPut(index, File standardInput readBufferOfLength(1) at(0))
    through(sender, thisMessage)
))
setSlot("squareBrackets", method(
    while (vm at(index) != 0,
      sender doMessage(thisMessage argAt(0))
    )
    self
))
setSlot("..", method(
    self perform(".")
    self perform(".")
    through(sender, thisMessage)
))

setSlot("forward", method(
    thisMessage name foreach(i, v,
      self perform(v asCharacter)
    )
    through(sender, thisMessage)
))
なにかあれば下記メールアドレスへ。
shinichiro.hamaji _at_ gmail.com
shinichiro.h