On Wed, Nov 26, 2008 at 4:41 PM, Robert Dober <robert.dober / gmail.com> wrote:
> For those who want to play around I have extended Matthew's code with
> some enhancements to allow
> 2) dump memory and stack -->nstruction ?d
> 3) show the stack --> ?s
> 5) Enabled comment mode with ?=  thus = this is ignored = to make
> programs (even LOL) more readable

Cool, I took a quick run at adding these couple of extensions to my
previous submission:

class Befunge93Extended < Befunge93
  define_method :"=" do
    move
    move until @memory[@position] == "="
  end

  define_method :"d" do
    puts
    25.times do |a|
      80.times do |b|
        print @memory[[b,a]].to_s
      end
      puts
    end
    s
  end

  define_method :"s" do
    puts
    puts "[#{@stack.join(":")}]"
  end
end

bf = Befunge93Extended.new

bf.memory = {
  [0,0] => "d", [1,0] => "v", [2,0] => " ", [3,0] => " ", [4,0] => " ",
  [0,1] => " ", [1,1] => "1", [2,1] => " ", [3,1] => " ", [4,1] => " ",
  [0,2] => " ", [1,2] => "2", [2,2] => " ", [3,2] => " ", [4,2] => " ",
  [0,3] => " ", [1,3] => "3", [2,3] => " ", [3,3] => " ", [4,3] => " ",
  [0,4] => " ", [1,4] => "s", [2,4] => " ", [3,4] => " ", [4,4] => " ",
  [0,5] => " ", [1,5] => "=", [2,5] => " ", [3,5] => " ", [4,5] => " ",
  [0,6] => ">", [1,6] => "@", [2,6] => "#", [3,6] => "<", [4,6] => " ",
  [0,7] => " ", [1,7] => "=", [2,7] => " ", [3,7] => ".", [4,7] => " ",
  [0,8] => " ", [1,8] => ">", [2,8] => ">", [3,8] => "^", [4,8] => " ",
}
bf.run #=> "program"\n[]\n\n[1:2:3]\n3