mirror of
https://github.com/kanaka/mal.git
synced 2024-11-11 00:52:44 +03:00
33 lines
705 B
R
33 lines
705 B
R
|
if(!exists("..readline..")) source("readline.r")
|
||
|
if(!exists("..types..")) source("types.r")
|
||
|
if(!exists("..reader..")) source("reader.r")
|
||
|
if(!exists("..printer..")) source("printer.r")
|
||
|
|
||
|
READ <- function(str) {
|
||
|
return(read_str(str))
|
||
|
}
|
||
|
|
||
|
EVAL <- function(ast, env) {
|
||
|
return(ast)
|
||
|
}
|
||
|
|
||
|
PRINT <- function(exp) {
|
||
|
return(.pr_str(exp, TRUE))
|
||
|
}
|
||
|
|
||
|
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: ", get_error(err),"\n", sep="")
|
||
|
})
|
||
|
# R debug/fatal with tracebacks:
|
||
|
#cat(rep(line),"\n", sep="")
|
||
|
}
|