Sha256: 04e70627e73fae32cff15406bb15747620ce9843184031a749917ce7114351aa
Contents?: true
Size: 927 Bytes
Versions: 1
Compression:
Stored size: 927 Bytes
Contents
#!/usr/bin/env ruby require 'stringio' require File.expand_path(File.join(File.dirname(__FILE__), '..', 'lib', 'flea.rb')) interpreter = Flea::Interpreter.new if ARGV.length > 0 interpreter.run(ARGF.read) exit end loop do program = [] indent = 0 loop do print "> " + (" " * indent) program << gets tmp_program = program.join(" ") open_p_count = tmp_program.count("(") close_p_count = tmp_program.count(")") break if open_p_count == close_p_count indent += 1 if program.last.count("(") > program.last.count(")") indent -= 1 if program.last.count("(") < program.last.count(")") end program = program.join(" ") exit if program.strip == "quit" old_stdout = $stdout buffer = StringIO.new $stdout = buffer result = interpreter.run program $stdout = old_stdout print buffer.string print "\n" unless buffer.string.empty? puts " => #{result.inspect}" end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
flea-0.1.0 | bin/flea |