properly implement tco and add step7:quote
[jackhill/mal.git] / groovy / step0_repl.groovy
1 // READ
2 READ = { str ->
3 str
4 }
5
6 // EVAL
7 EVAL = { ast, env ->
8 ast
9 }
10
11 // PRINT
12 PRINT = { exp ->
13 exp
14 }
15
16 // REPL
17 REP = { str ->
18 PRINT(EVAL(READ(str), [:]))
19 }
20
21 while (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 }