class BefungeInterpreter

This is the top-level class containing everything needed to interpret befunge code. Intialize with a string location of a filename and an array of flags and then call BefungeInterpreter#interpret. This will run the befunge code. TODO: Implement flags - debugging mode, animation mode.

Public Class Methods

new(file, flags) click to toggle source
# File lib/befunge_interpreter.rb, line 9
def initialize(file, flags)
  @code_map = CodeMap.new(file)
  @flags = flags
  @stack = Stack.new
  @string_mode = false
  @computing = true
  @return_string = ''
end

Public Instance Methods

interpret() click to toggle source
# File lib/befunge_interpreter.rb, line 18
def interpret
  operate_and_step while @computing
end

Private Instance Methods

operate_and_step() click to toggle source
# File lib/befunge_interpreter.rb, line 24
def operate_and_step
  operate!(@code_map.get_operation)
  @code_map.pointer.step
end
print_return_string() click to toggle source
print_stack() click to toggle source
print_status() click to toggle source
print_top_ten_stack() click to toggle source
print_whole_stack() click to toggle source