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

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="")
}