Class: BefungeInterpreter
- Inherits:
-
Object
- Object
- BefungeInterpreter
- Includes:
- Operations
- Defined in:
- lib/befunge_interpreter.rb
Overview
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.
Direct Known Subclasses
Constant Summary
Constants included from Operations
Operations::DIRECTIONS, Operations::DIRECTIONS_MAP, Operations::DIRECTION_OPS, Operations::MATH_OPS, Operations::OPERATORS, Operations::OPERATORS_MAP
Instance Method Summary collapse
-
#initialize(file, flags) ⇒ BefungeInterpreter
constructor
A new instance of BefungeInterpreter.
- #interpret ⇒ Object
Methods included from Operations
#change_dir, #duplicate_stack_top, #end_program, #get_call, #get_user_input_char, #get_user_input_int, #greater_than, #left_right, #logical_not, #operate!, #pop_and_discard, #pop_and_display_char, #pop_and_display_int, #push_ascii_value, #push_num, #put_call, #rand_direction, #string_mode, #swap_stack_top, #trampoline, #up_down
Constructor Details
#initialize(file, flags) ⇒ BefungeInterpreter
Returns a new instance of BefungeInterpreter.
9 10 11 12 13 14 15 16 |
# 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 |
Instance Method Details
#interpret ⇒ Object
18 19 20 |
# File 'lib/befunge_interpreter.rb', line 18 def interpret operate_and_step while @computing end |