Class: Lisp::REPL
- Inherits:
-
Object
- Object
- Lisp::REPL
- Defined in:
- lib/lisp/repl.rb
Instance Attribute Summary collapse
-
#input ⇒ Object
readonly
Returns the value of attribute input.
-
#io ⇒ Object
readonly
Returns the value of attribute io.
Instance Method Summary collapse
-
#initialize ⇒ REPL
constructor
A new instance of REPL.
- #run ⇒ Object
Constructor Details
#initialize ⇒ REPL
Returns a new instance of REPL.
8 9 10 11 12 13 14 15 16 |
# File 'lib/lisp/repl.rb', line 8 def initialize @io = Coolline.new do |config| config.transform_proc = proc do CodeRay.scan(config.line, :clojure).term end end reset_input! end |
Instance Attribute Details
#input ⇒ Object (readonly)
Returns the value of attribute input.
6 7 8 |
# File 'lib/lisp/repl.rb', line 6 def input @input end |
#io ⇒ Object (readonly)
Returns the value of attribute io.
6 7 8 |
# File 'lib/lisp/repl.rb', line 6 def io @io end |
Instance Method Details
#run ⇒ Object
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/lisp/repl.rb', line 18 def run trap("SIGINT") { throw :exit } puts "ctrl-c to exit" catch(:exit) do loop do begin @input += io.readline prompt if open_count == close_count puts Lisp.eval input reset_input! end rescue Exception => e puts e. reset_input! end end end end |