properly implement tco and add step7:quote
[jackhill/mal.git] / groovy / step0_repl.groovy
CommitLineData
a9cd6543
JM
1// READ
2READ = { str ->
3 str
4}
5
6// EVAL
7EVAL = { ast, env ->
8 ast
9}
10
11// PRINT
12PRINT = { exp ->
13 exp
14}
15
16// REPL
17REP = { str ->
18 PRINT(EVAL(READ(str), [:]))
19}
20
21while (true) {
22 line = System.console().readLine 'user> '
23 if (line == null) {
24 break
25 }
26 try {
27 println REP(line)
28 } catch(ex) {
29 println "Error: $ex"
30 ex.printStackTrace()
31 }
32}