struct Interpreter
- Interpreter
- Struct
- Value
- Object
Overview
This is the library for handling brainfuck code.
The struct Interpreter
can be instantiated like so...
Interpreter.new("+++++++++[>++++++++++<-]>.")
Where the arguments to the initializer is a string containing the brainfuck code.
Defined in:
interpreter.crConstructors
Instance Method Summary
-
#bracket_map : Hash(Int32, Int32)
Stores the start and end positions of loops in a hash
-
#code : String
The code string that is passed to the program by the user with
-d
and--data
flags -
#consume
consumes a single char at a time
- #create_bracket_map(str : String)
-
#interpret
Iterates through the code string and compares each character against a case statement for that character raises a custom
BrainFuckError
when a unknown BF command is given -
#mem : Array(UInt8)
A 30k length array of memory as specified in the BF spec.
-
#pc : Int32
The Program Counter keeps track of how far along we are in the code And is set to the start or end of the loop when it hits
[
or]
-
#sp : Int32
Stack Pointer indexes into the area in memory that is modified by the
+
and-
instructions
Constructor Detail
Instance Method Detail
The code string that is passed to the program by the user with -d
and --data
flags
Iterates through the code string and compares each character
against a case statement for that character
raises a custom BrainFuckError
when a unknown BF command is given
A 30k length array of memory as specified in the BF spec. It starts initialize to 0
The Program Counter keeps track of how far along we are in the code
And is set to the start or end of the loop when it hits [
or ]
Stack Pointer indexes into the area in memory that is modified by the
+
and -
instructions