switch to tail -f circular pipes
[jackhill/mal.git] / julia / step1_read_print.jl
CommitLineData
a23e0cdb
JM
1#!/usr/bin/env julia
2
82484631 3push!(LOAD_PATH, pwd(), "/usr/share/julia/base")
85110962 4import readline_mod
a23e0cdb
JM
5import reader
6import printer
7
8# READ
9function READ(str)
10 reader.read_str(str)
11end
12
13# EVAL
14function EVAL(ast, env)
15 ast
16end
17
18# PRINT
19function PRINT(exp)
20 printer.pr_str(exp)
21end
22
23# REPL
24function REP(str)
82484631 25 return PRINT(EVAL(READ(str), []))
a23e0cdb
JM
26end
27
28while true
85110962
JM
29 line = readline_mod.do_readline("user> ")
30 if line === nothing break end
a23e0cdb
JM
31 try
32 println(REP(line))
33 catch e
34 if isa(e, ErrorException)
35 println("Error: $(e.msg)")
36 else
37 println("Error: $(string(e))")
38 end
39 bt = catch_backtrace()
40 Base.show_backtrace(STDERR, bt)
41 println()
42 end
43end