blob: 9dbf1072cc1297b0a0ec77685e0802f8b5d3bb5b (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
|
% read
/READ {
% just "return" the input string
/str exch def
str
} def
% eval
/EVAL {
% just "return" the "ast"
/env exch def
/ast exch def
ast
} def
% print
/PRINT {
% just "return" the expression
/exp exch def
exp
} def
% repl
/REP { READ (stub env) EVAL PRINT } def
/stdin (%stdin) (r) file def
{ % loop
(user> ) print flush
stdin 99 string readline
not { exit } if % exit if EOF
%(\ngot line: ) print dup print (\n) print flush
REP print (\n) print
} bind loop
(\n) print % final newline before exit for cleanliness
quit
|