#!/usr/bin/env ruby # The Turmali language! # # usage: # ./tml example.tml # to eval a file # ./tml # to start the REPL # # on Windows run with: ruby -I. tml [options] require "bundler/setup" require "turmali" require "readline" interpreter = Interpreter.new # If a file is given we eval it. if file = ARGV.first interpreter.eval File.read(file) # Start the REPL, read-eval-print-loop, or interactive interpreter else puts "Turmali REPL, CTRL+C to quit" loop do line = Readline::readline(">> ") # 1. Read Readline::HISTORY.push(line) value = interpreter.eval(line) # 2. Eval puts "=> #{value.ruby_value.inspect}" # 3. Print end # 4. Loop end