Commit | Line | Data |
---|---|---|
88f59d07 | 1 | % read |
950e3c76 JM |
2 | /_readline { print flush (%stdin) (r) file 99 string readline } def |
3 | ||
88f59d07 JM |
4 | /READ { |
5 | % just "return" the input string | |
6 | /str exch def | |
7 | 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 | ||
21 | /PRINT { | |
22 | % just "return" the expression | |
23 | /exp exch def | |
24 | exp | |
25 | } def | |
26 | ||
27 | ||
28 | % repl | |
04517bc8 | 29 | /REP { READ (stub env) EVAL PRINT } def |
88f59d07 JM |
30 | |
31 | { % loop | |
950e3c76 | 32 | (user> ) _readline |
88f59d07 JM |
33 | not { exit } if % exit if EOF |
34 | ||
88f59d07 JM |
35 | REP print (\n) print |
36 | } bind loop | |
37 | ||
38 | (\n) print % final newline before exit for cleanliness | |
39 | quit |