16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
|
# File 'lib/repl.rb', line 16
def run
puts @runtime.info
Readline.completion_append_character = nil
Readline.completion_proc = @runtime.top_level.method(:longest_prefix)
loop do
begin
input = Readline.readline(prompt)
exit if input.nil?
push(input)
tree = Heist.parse(@buffer * "\n")
next if tree.nil?
reset!
result = @scope.eval(tree)
unless result.nil?
puts "; => #{ Heist.stringify(result) }\n\n"
@results << result
@scope['^'] = result
end
rescue Exception => ex
return if SystemExit === ex
if Interrupt === ex
reset! and puts "\n\n"
else
puts "; [error] #{ ex.message }\n\n"
end
end
end
end
|