Commit | Line | Data |
---|---|---|
4d1456b9 JM |
1 | if(!exists("..readline..")) source("readline.r") |
2 | if(!exists("..types..")) source("types.r") | |
3 | if(!exists("..reader..")) source("reader.r") | |
4 | if(!exists("..printer..")) source("printer.r") | |
5 | ||
6 | READ <- function(str) { | |
7 | return(read_str(str)) | |
8 | } | |
9 | ||
10 | EVAL <- function(ast, env) { | |
11 | return(ast) | |
12 | } | |
13 | ||
14 | PRINT <- function(exp) { | |
15 | return(.pr_str(exp, TRUE)) | |
16 | } | |
17 | ||
18 | rep <- function(str) { | |
19 | return(PRINT(EVAL(READ(str), ""))) | |
20 | } | |
21 | ||
22 | repeat { | |
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 | } |