2015-02-28 02:36:27 +03:00
|
|
|
require_relative "mal_readline"
|
|
|
|
require_relative "types"
|
|
|
|
require_relative "reader"
|
|
|
|
require_relative "printer"
|
2014-04-11 05:34:29 +04:00
|
|
|
|
|
|
|
# read
|
|
|
|
def READ(str)
|
|
|
|
return read_str(str)
|
|
|
|
end
|
|
|
|
|
|
|
|
# eval
|
|
|
|
def EVAL(ast, env)
|
|
|
|
return ast
|
|
|
|
end
|
|
|
|
|
|
|
|
# print
|
|
|
|
def PRINT(exp)
|
|
|
|
return _pr_str(exp, true)
|
|
|
|
end
|
|
|
|
|
|
|
|
# repl
|
|
|
|
def REP(str)
|
|
|
|
return PRINT(EVAL(READ(str), {}))
|
|
|
|
end
|
|
|
|
|
2014-04-19 22:04:09 +04:00
|
|
|
# repl loop
|
2014-04-18 07:23:07 +04:00
|
|
|
while line = _readline("user> ")
|
2014-04-11 05:34:29 +04:00
|
|
|
begin
|
|
|
|
puts REP(line)
|
|
|
|
rescue Exception => e
|
2014-04-19 22:04:09 +04:00
|
|
|
puts "Error: #{e}"
|
|
|
|
puts "\t#{e.backtrace.join("\n\t")}"
|
2014-04-11 05:34:29 +04:00
|
|
|
end
|
|
|
|
end
|