1
1
mirror of https://github.com/kanaka/mal.git synced 2024-09-20 18:18:51 +03:00
mal/groovy/step0_repl.groovy
Joel Martin a9cd654347 Add groovy implementation.
I'm away from my main workstation for a week and unfortunately, I only
copied the code but not the branch with full history so this is just
the implementation. However, the history isn't all that interesting
(mostly just the steps one at a time) and I wanted to get this out
there.
2015-05-18 19:54:18 -07:00

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()
}
}