Add missing clean targets in 5 impls.
[jackhill/mal.git] / ps / step1_read_print.ps
1 /runlibfile where { pop }{ /runlibfile { run } def } ifelse %
2 (types.ps) runlibfile
3 (reader.ps) runlibfile
4 (printer.ps) runlibfile
5
6 % read
7 /_readline { print flush (%stdin) (r) file 1024 string readline } def
8
9 /READ {
10 /str exch def
11 str read_str
12 } def
13
14
15 % eval
16 /EVAL { 2 dict begin
17 % just "return" the "ast"
18 /env exch def
19 /ast exch def
20 ast
21 end } def
22
23
24 % print
25 /PRINT {
26 true _pr_str
27 } def
28
29
30 % repl
31 /REP { READ (stub env) EVAL PRINT } def
32
33 % repl loop
34 { %loop
35 (user> ) _readline
36 not { exit } if % exit if EOF
37
38 { %try
39 REP print (\n) print
40 } stopped {
41 (Error: ) print
42 get_error_data false _pr_str print (\n) print
43 $error /newerror false put
44 $error /errorinfo null put
45 clear
46 cleardictstack
47 } if
48 } bind loop
49
50 (\n) print % final newline before exit for cleanliness
51 quit