Class: Esolang::Interpreters::BaseInterpreter

Inherits:
Object
  • Object
show all
Defined in:
lib/interpreters/base_interpreter.rb

Overview

The BaseInterpreter class provides a common interface and basic functionality for interpreting esoteric programming languages.

Direct Known Subclasses

Boolfuck, Brainfuck, Paintfuck, Smallfuck

Instance Method Summary collapse

Constructor Details

#initialize(code) ⇒ BaseInterpreter

Initializes a new instance of the BaseInterpreter class.

Parameters:

  • code (String)

    The code to interpret.



11
12
13
14
15
16
# File 'lib/interpreters/base_interpreter.rb', line 11

def initialize(code)
  @code = code.chars
  @code_pointer = 0
  @loop_map = create_loop_map
  @tape_pointer = 0
end

Instance Method Details

#runObject

This method is abstract.

Subclasses must implement the run method.

Executes the interpretation of the code. Subclasses must implement this method.

Raises:

  • (NotImplementedError)

    Raised if the method is not implemented by subclasses.



22
23
24
# File 'lib/interpreters/base_interpreter.rb', line 22

def run
  raise NotImplementedError, 'Subclasses must implement the run method'
end