mirror of
https://github.com/kanaka/mal.git
synced 2024-11-10 12:47:45 +03:00
406761e769
- make sure readline has large enough string for steps2-A - fix keyword? so that it doesn't leave anything extra on the stack - fix argparse command line parsing so that that the second '--' on the command line is not dropped.
52 lines
869 B
PostScript
52 lines
869 B
PostScript
/runlibfile where { pop }{ /runlibfile { run } def } ifelse %
|
|
(types.ps) runlibfile
|
|
(reader.ps) runlibfile
|
|
(printer.ps) runlibfile
|
|
|
|
% read
|
|
/_readline { print flush (%stdin) (r) file 1024 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
|
|
|
|
% repl loop
|
|
{ %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
|