mirror of
https://github.com/kanaka/mal.git
synced 2024-10-26 22:28:26 +03:00
28 lines
444 B
R
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="")
|
||
|
})
|
||
|
}
|