blob: b4c62753ef06b1db549c1113593353092b2217a2 (
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
45
46
47
48
49
|
(types.ps) run
(reader.ps) run
(printer.ps) run
% read
/_readline { print flush (%stdin) (r) file 99 string readline } def
/READ {
/str exch def
str read_str
} def
% eval
/EVAL { 2 dict begin
% just "return" the "ast"
/env exch def
/ast exch def
ast
end } def
% print
/PRINT {
true _pr_str
} def
% repl
/REP { READ (stub env) EVAL PRINT } def
{ % loop
(user> ) _readline
not { exit } if % exit if EOF
{ %try
REP print (\n) print
} stopped {
(Error: ) print
get_error_data false _pr_str print (\n) print
$error /newerror false put
$error /errorinfo null put
clear
cleardictstack
} if
} bind loop
(\n) print % final newline before exit for cleanliness
quit
|