PS: minimal step1_read_print
[jackhill/mal.git] / ps / step1_read_print.ps
1 (types.ps) run
2 (reader.ps) run
3
4 % read
5 /READ {
6 /str exch def
7 str read_str
8 } def
9
10
11 % eval
12 /EVAL {
13 % just "return" the "ast"
14 /env exch def
15 /ast exch def
16 ast
17 } def
18
19
20 % print
21 /PRINT {
22 /exp exch def
23 %(printing: ) print exp ==
24 exp pr_str
25 } def
26
27
28 % repl
29 /REP {
30 READ (stub env) EVAL PRINT
31 } def
32
33 /stdin (%stdin) (r) file def
34
35 { % loop
36 (user> ) print flush
37
38 %(%lineedit) (r) file 99 string readline
39 stdin 99 string readline
40
41 not { exit } if % exit if EOF
42
43 %(\ngot line: ) print dup print (\n) print flush
44 REP print (\n) print
45 } bind loop
46
47 (\n) print % final newline before exit for cleanliness
48 quit