Class: Kolom::REPL
- Inherits:
-
Object
- Object
- Kolom::REPL
- Defined in:
- lib/kolom/repl.rb
Instance Method Summary collapse
-
#initialize ⇒ REPL
constructor
A new instance of REPL.
- #start ⇒ Object
Constructor Details
#initialize ⇒ REPL
Returns a new instance of REPL.
6 7 8 9 |
# File 'lib/kolom/repl.rb', line 6 def initialize @interpreter = Interpreter.new @history = [] end |
Instance Method Details
#start ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/kolom/repl.rb', line 11 def start loop do line = Readline.readline("কলম> ", true) break if line.nil? || line.strip == 'বাহির' begin result, output = @interpreter.evaluate(line) puts output unless output.empty? puts "=> #{result.inspect}" unless result.nil? rescue => e puts "Error: #{e.}" puts e.backtrace.join("\n") end @history << line Readline::HISTORY.push(line) end puts "ধন্যবাদ!" end |