Common Lisp: Add documentation
[jackhill/mal.git] / tcl / step1_read_print.tcl
1 source mal_readline.tcl
2 source types.tcl
3 source reader.tcl
4 source printer.tcl
5
6 proc READ str {
7 read_str $str
8 }
9
10 proc EVAL {ast env} {
11 return $ast
12 }
13
14 proc PRINT exp {
15 pr_str $exp 1
16 }
17
18 proc REP str {
19 PRINT [EVAL [READ $str] {}]
20 }
21
22 fconfigure stdout -translation binary
23
24 # repl loop
25 while {true} {
26 set res [_readline "user> "]
27 if {[lindex $res 0] == "EOF"} {
28 break
29 }
30 set line [lindex $res 1]
31 if {$line == ""} {
32 continue
33 }
34 if { [catch { puts [REP $line] } exception] } {
35 puts "Error: $exception"
36 }
37 }
38 puts ""