Class: Kolom::REPL

Inherits:
Object
  • Object
show all
Defined in:
lib/kolom/repl.rb

Instance Method Summary collapse

Constructor Details

#initializeREPL

Returns a new instance of REPL.



6
7
8
# File 'lib/kolom/repl.rb', line 6

def initialize
  @interpreter = Interpreter.new
end

Instance Method Details

#startObject



10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/kolom/repl.rb', line 10

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.message}"
      puts e.backtrace.join("\n")
    end
  end
  puts "ধন্যবাদ!"
end