2014-03-26 02:15:32 +04:00
|
|
|
% read
|
2015-03-18 21:08:08 +03:00
|
|
|
/_readline { print flush (%stdin) (r) file 1024 string readline } def
|
2014-04-02 06:50:24 +04:00
|
|
|
|
2014-03-26 02:15:32 +04:00
|
|
|
/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
|
2014-03-30 02:26:07 +04:00
|
|
|
/REP { READ (stub env) EVAL PRINT } def
|
2014-03-26 02:15:32 +04:00
|
|
|
|
2014-04-19 22:04:09 +04:00
|
|
|
% repl loop
|
|
|
|
{ %loop
|
2014-04-02 06:50:24 +04:00
|
|
|
(user> ) _readline
|
2014-03-26 02:15:32 +04:00
|
|
|
not { exit } if % exit if EOF
|
|
|
|
|
|
|
|
REP print (\n) print
|
|
|
|
} bind loop
|
|
|
|
|
|
|
|
(\n) print % final newline before exit for cleanliness
|
|
|
|
quit
|