1
1
mirror of https://github.com/kanaka/mal.git synced 2024-09-20 10:07:45 +03:00
mal/r/step0_repl.r
2015-01-09 16:15:49 -06:00

28 lines
444 B
R

source("readline.r")
READ <- function(str) {
return(str)
}
EVAL <- function(ast, env) {
return(ast)
}
PRINT <- function(exp) {
return(exp)
}
rep <- function(str) {
return(PRINT(EVAL(READ(str), "")))
}
repeat {
line <- readline("user> ")
if (is.null(line)) { cat("\n"); break }
tryCatch({
cat(rep(line),"\n", sep="")
}, error=function(err) {
cat("Error: ", err$message,"\n", sep="")
})
}