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