elixir, erlang, lua, php, r, vimscript: Fix (first nil) and (rest nil)
[jackhill/mal.git] / r / step1_read_print.r
CommitLineData
4d1456b9
JM
1if(!exists("..readline..")) source("readline.r")
2if(!exists("..types..")) source("types.r")
3if(!exists("..reader..")) source("reader.r")
4if(!exists("..printer..")) source("printer.r")
5
6READ <- function(str) {
7 return(read_str(str))
8}
9
10EVAL <- function(ast, env) {
11 return(ast)
12}
13
14PRINT <- function(exp) {
15 return(.pr_str(exp, TRUE))
16}
17
18rep <- function(str) {
19 return(PRINT(EVAL(READ(str), "")))
20}
21
22repeat {
23 line <- readline("user> ")
24 if (is.null(line)) { cat("\n"); break }
25 tryCatch({
26 cat(rep(line),"\n", sep="")
27 }, error=function(err) {
28 cat("Error: ", get_error(err),"\n", sep="")
29 })
30 # R debug/fatal with tracebacks:
31 #cat(rep(line),"\n", sep="")
32}