Skip to content

Commit

Permalink
Fixes #85
Browse files Browse the repository at this point in the history
  • Loading branch information
wheatwizard committed Dec 18, 2017
1 parent 075a569 commit 37acc72
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
11 changes: 10 additions & 1 deletion ClassicInterpreter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,11 @@

class ClassicInterpreter < Interpreter

def initialize(source, left_in, right_in, debug, max_cycles, ascii_mode)
super(source, left_in, right_in, debug, max_cycles)
@ascii_mode = ascii_mode
end

# Nilads ~~~~~~~~~~~~~~~~~~~~~

def round_nilad()
Expand Down Expand Up @@ -60,7 +65,11 @@ def close_round()

def close_square()
data = main_stack.pop()
puts @current_value
if @ascii_mode
print (@current_value % 2 ** 32).chr(Encoding::UTF_8)
else
puts @current_value
end
@current_value += data[1]
end

Expand Down
2 changes: 1 addition & 1 deletion brain_flak.rb
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@
when "brainflak"
interpreter = BrainFlakInterpreter.new(source, numbers, [], debug, max_cycles)
when "classic"
interpreter = ClassicInterpreter.new(source, numbers, [], debug, max_cycles)
interpreter = ClassicInterpreter.new(source, numbers, [], debug, max_cycles, ascii_out)
when "miniflak", "mini"
source = source.gsub(/#.*(\n|$)/,"").gsub(/[^\[\]{}()]/,"") # Parsing is done here so that we can strip `[]` properly
while source =~ /\[\]/
Expand Down

0 comments on commit 37acc72

Please sign in to comment.