1 /runlibfile where
{ pop }{ /runlibfile
{ run
} def
} ifelse %
4 (printer.ps
) runlibfile
7 /_readline
{ print flush
(%stdin) (r) file 1024 string readline } def
16 /eval_ast
{ 2 dict begin
19 %(eval_ast: ) print ast ==
20 ast _symbol?
{ %if symbol
24 (') ast false _pr_str (' not found
)
25 concatenate concatenate _throw
27 }{ ast _sequential?
{ %elseif list or vector
29 ast
/data get
{ %forall items
32 ] ast _list?
{ _list_from_array
}{ _vector_from_array
} ifelse
33 }{ ast _hash_map?
{ %elseif list or vector
35 ast
/data get
{ %forall entries
38 >> _hash_map_from_dict
41 } ifelse } ifelse } ifelse
48 %(EVAL: ) print ast true _pr_str print (\n) print
49 ast _list? not
{ %if not a list
51 }{ %else apply the list
52 /el ast env eval_ast def
53 el _rest el _first
% stack: ast function
54 exec % apply function to args
67 (+) { dup 0 _nth
exch 1 _nth add
}
68 (-) { dup 0 _nth
exch 1 _nth
sub }
69 (*) { dup 0 _nth
exch 1 _nth
mul }
70 (/) { dup 0 _nth
exch 1 _nth
idiv }
73 /REP
{ READ repl_env EVAL PRINT
} def
78 not
{ exit } if % exit if EOF
84 get_error_data
false _pr_str print
(\n) print
85 $error
/newerror
false put
86 $error
/errorinfo null put
92 (\n) print
% final newline before exit for cleanliness