Class: Repl

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

Class Method Summary collapse

Class Method Details

.run ⇒ Object



10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
# File 'bin/repl.rb', line 10

def self.run
  @lucio = Lucio.new
  exit = false
  puts <<lisp
# lucio interactive console
-------------------------
# type a lucio expression and press ENTER
# type .q and press ENTER to exit

lisp
  while !exit
    print 'lucio: '
    command = (gets).chomp
    exit = (command == QUIT)
    unless exit
      begin
        print '=> '
        p @lucio.eval(command)
      rescue Exception => msg
        puts "Error: #{msg}"
      end
      puts ''
    end
  end

  puts '# bye!'
end