mirror of
https://github.com/kanaka/mal.git
synced 2024-09-11 21:57:38 +03:00
33 lines
395 B
Groovy
33 lines
395 B
Groovy
|
// READ
|
||
|
READ = { str ->
|
||
|
str
|
||
|
}
|
||
|
|
||
|
// EVAL
|
||
|
EVAL = { ast, env ->
|
||
|
ast
|
||
|
}
|
||
|
|
||
|
// PRINT
|
||
|
PRINT = { exp ->
|
||
|
exp
|
||
|
}
|
||
|
|
||
|
// REPL
|
||
|
REP = { str ->
|
||
|
PRINT(EVAL(READ(str), [:]))
|
||
|
}
|
||
|
|
||
|
while (true) {
|
||
|
line = System.console().readLine 'user> '
|
||
|
if (line == null) {
|
||
|
break
|
||
|
}
|
||
|
try {
|
||
|
println REP(line)
|
||
|
} catch(ex) {
|
||
|
println "Error: $ex"
|
||
|
ex.printStackTrace()
|
||
|
}
|
||
|
}
|