1
1
mirror of https://github.com/kanaka/mal.git synced 2024-11-11 00:52:44 +03:00
mal/r/step1_read_print.r

33 lines
705 B
R
Raw Normal View History

2014-11-01 23:54:48 +03:00
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="")
}