Class: Crisp::Shell

Inherits:
Object
  • Object
show all
Defined in:
lib/crisp/shell.rb

Overview

The Crisp interactive shell

Create a new instance and call run for having a interactive Crisp shell.

Instance Method Summary collapse

Instance Method Details

#runObject

start the shell



9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/crisp/shell.rb', line 9

def run
  runtime = Runtime.new
  buffer = ''

  while (line = Readline.readline(buffer.empty? ? ">> " : "?> ", true))
    begin
      buffer << line
      ast = Parser.new.parse(buffer)
      puts "=> " + runtime.run(ast).to_s
      buffer = ''
    rescue Crisp::SyntaxError => e
      # noop
    end
  end
end