Class: Lasp::Repl

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

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.runObject



7
8
9
# File 'lib/lasp/repl.rb', line 7

def self.run
  new.run
end

Instance Method Details

#runObject



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

def run
  trap("SIGINT") { puts "\n\nBye!"; exit }

  puts "((( Läsp v#{Lasp::VERSION} REPL (ctrl+c to exit) )))\n\n"
  loop do
    begin
      history = true
      input   = Readline.readline(prompt, history).to_s
      input   = autoclose_parentheses(input)
      result  = Lasp::execute(input)
      print_result(result)
    rescue => error
      print_error(error)
    end
  end
end