1
1
mirror of https://github.com/kanaka/mal.git synced 2024-09-20 10:07:45 +03:00
mal/crystal/step1_read_print.cr
2015-06-04 01:59:10 +09:00

37 lines
484 B
Crystal
Executable File

#! /usr/bin/env crystal run
require "./readline"
require "./reader"
require "./printer"
# Note:
# Employed downcase names because Crystal prohibits uppercase names for methods
module Mal
extend self
def read(str)
read_str str
end
def eval(x)
x
end
def print(result)
pr_str(result, true)
end
def rep(str)
print(eval(read(str)))
end
end
while line = my_readline("user> ")
begin
puts Mal.rep(line)
rescue e
STDERR.puts e
end
end