Skip to content
Browse files

REPL takes compiler printing options in constructor.

  • Loading branch information...
1 parent 2fa2814 commit b360f1610c84fe7b64463664f4319b48f2e21084 @vic committed Dec 24, 2010
Showing with 8 additions and 3 deletions.
  1. +1 −1 lib/typhon/main.rb
  2. +7 −2 lib/typhon/repl.rb
View
2 lib/typhon/main.rb
@@ -57,7 +57,7 @@ def script
# Run the Typhon REPL unless we were given an script
def repl
require 'typhon/repl'
- ReadEvalPrintLoop.new.main(@print)
+ ReadEvalPrintLoop.new(@print).main
end
# Parse command line options
View
9 lib/typhon/repl.rb
@@ -2,6 +2,11 @@
module Typhon
class ReadEvalPrintLoop
+ def initialize(compiler_print = Compiler::Print.new, show_lineno = false)
+ @compiler_print = compiler_print
+ @show_lineno = show_lineno
+ end
+
def prompt(lineno = 1, level = 1, print_line = false)
line = ("%03i " % [line] if print_line).to_s
prompt = if level > 1; "..."; else ">>>"; end
@@ -25,11 +30,11 @@ def bnd.bnd; binding; end
lineno = 1
level = 1
header
- while line = Readline.readline(prompt(lineno, level),true)
+ while line = Readline.readline(prompt(lineno, level), @show_lineno)
Readline::HISTORY.pop() if double_or_empty?(line)
begin
- p CodeLoader.execute_code line, bnd, mod, print
+ p CodeLoader.execute_code line, bnd, mod, @compiler_print
rescue => e
puts e.message
end

0 comments on commit b360f16

Please sign in to comment.
Something went wrong with that request. Please try again.