diff --git a/Interpreter.rb b/Interpreter.rb index d5b8255..aa6506a 100644 --- a/Interpreter.rb +++ b/Interpreter.rb @@ -80,7 +80,7 @@ def do_debug_flag(index) when "av" then STDERR.puts (@current_value%256).chr(Encoding::UTF_8) when "uv" then STDERR.puts (@current_value%2**32).chr(Encoding::UTF_8) when "dc","ac" then - print @active_stack == @left ? "(left) " : "(right) " + STDERR.print @active_stack == @left ? "(left) " : "(right) " case flag.to_s when "dc" then STDERR.puts @active_stack.inspect_array @@ -146,7 +146,7 @@ def do_debug_flag(index) @current_value = sub_interpreter.current_value when "dh" then STDERR.puts @active_stack.height when "lt" then - print "\n" + STDERR.print "\n" @current_value += flag.get_data when "pu" then #Take input @@ -247,11 +247,11 @@ def inspect index = @index offset = 0 @debug_flags.each_pair do |k,v| - v.each do |sym| - source.insert(k + offset, "#%s" % sym.id2name); - offset += sym.id2name.length + 1 + v.each do |flag| + source.insert(k + offset, "@%s" % flag.to_s); + offset += flag.to_s.length + 1 if k <= index then - index += sym.id2name.length + 1 + index += flag.to_s.length + 1 end end end diff --git a/README.md b/README.md index a22f0f2..71fde56 100644 --- a/README.md +++ b/README.md @@ -4,7 +4,7 @@ Brain-Flak is an "Turing-tarpit", e.g. a language which can, *in theory* compute To get started with Brain-Flak, download the project from here, and run `ruby brain_flak.rb inputs`. Additionally, you can [try it online](http://brain-flak.tryitonline.net/)! (Online intrepreter provided thanks to [@DennisMitchell](https://github.com/DennisMitchell)) -#Tutorial +# Tutorial Brain-Flak has two stacks, known as 'left' and 'right'. The active stack starts at left. If an empty stack is popped, it will return 0. That's it. No other variables. When the program starts, each command line argument is pushed on to the active stack. @@ -48,7 +48,7 @@ When the program is done executing, each value left on the active stack is print That's it. That's the whole language. -#Sample code +# Sample code Here are some full programs that do interesting things. diff --git a/brain_flak.rb b/brain_flak.rb index 9089313..8841361 100644 --- a/brain_flak.rb +++ b/brain_flak.rb @@ -1,7 +1,7 @@ require_relative './stack.rb' require_relative './Interpreter.rb' -VERSION_STRING = "Brain-Flak Ruby Interpreter v1.3.0" +VERSION_STRING = "Brain-Flak Ruby Interpreter v1.3.1" require 'optparse' @@ -30,11 +30,13 @@ ["ar","Prints the right stack as ASCII characters"], ["cy","Prints the number of elapsed cycles"], ["dc","Prints the current stack in decimal"], + ["dh","Prints the height of the current stack in decimal"], ["dl","Prints the left stack in decimal"], ["dv","Prints the current value of the scope in decimal"], ["dr","Prints the right stack in decimal"], ["ex","Terminates the program"], ["ij","Pauses program and prompts user for Brain-Flak code to be run in place of the flag"], + ["lt","Passed with a number after the @lt (e.g. @lt6). Evaluates to the number passed with it"], ["pu","Pauses the program until the user hits the return key"], ] flag_desc.each do | flag | @@ -43,7 +45,6 @@ end opts.on("-f", "--file=FILE", "Reads input for the brain-flak program from FILE, rather than from the command line.") do |file| - puts file arg_path = file end