3 if(!exists("..types..")) source("types.r")
5 .pr_list
<- function(lst
, print_readably
=TRUE, join
="") {
7 function(e
) .pr_str(e
, print_readably
)), sep
=join
)
10 .pr_str
<- function(exp
, print_readably
=TRUE) {
14 paste("(", .pr_list(exp
, pr
, " "), ")", sep
="", collapse
="")
17 paste("[", .pr_list(exp
, pr
, " "), "]", sep
="", collapse
="")
21 if (length(exp
) > 0) {
23 hlst
[[length(hlst
)+1]] <- k
24 hlst
[[length(hlst
)+1]] <- exp
[[k
]]
27 paste("{", .pr_list(hlst
, pr
, " "), "}", sep
="", collapse
="")
30 if (substring(exp
,1,1) == "\u029e") {
31 concat(":", substring(exp
,2))
32 } else if (substring(exp
,1,8) == "<U+029E>") {
33 # terrible hack, appears in 3.1.1 on Utopic
34 concat(":", substring(exp
,9))
35 } else if (print_readably
) {
38 gsub("\\\"", "\\\\\"",
39 gsub("\\\\", "\\\\\\\\", exp
))),
40 "\"", sep
="", collapse
="")
47 "logical"={ tolower(exp
) },
49 paste("(fn* ", .pr_str(exp$params
,TRUE),
50 " ", .pr_str(exp$ast
, TRUE), ")", sep
="")
52 "function"={ "<#function>" },
54 paste("(atom ", .pr_str(exp$val
,TRUE), ")", sep
="")