Sha256: f1c5ac1f270a064adbcb3ad2ce24277e8c3da74932958758b787d9c59fc494b5

Contents?: true

Size: 932 Bytes

Versions: 1

Compression:

Stored size: 932 Bytes

Contents

#!/usr/bin/env ruby

require "bundler/setup"
require "turmali"
require "readline"
require "racc/parser"
require "terminal-table"

stty_save = %x`stty -g`.chomp
trap("INT") { system "stty", stty_save; exit }

interpreter = Interpreter.new

if file = ARGV.first
  interpreter.eval File.read(file)
else
  rows = []
  rows << ['', 'turmali repl console']
  rows << ['filename(.tml)', 'run turmali file']
  table = Terminal::Table.new :title => "Turmali (#{Turmali::VERSION}) REPL, Type 'quit' or 'exit' to exit", 
          :headings => ['arg', 'description'], :rows => rows
  puts table
  begin
    while line = Readline::readline("tml >> ")
      exit if line == 'quit'
      exit if line == 'exit'
      Readline::HISTORY.push(line)
      value = interpreter.eval(line) 
      puts "=> #{value.ruby_value.inspect}"  
    end
  rescue Racc::ParseError => e
    puts e ; retry
  rescue StandardError => e
    puts e ; retry
  end  
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
turmali-0.0.7 bin/tml