2014-03-26 02:15:32 +04:00
|
|
|
% 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
|
2014-03-30 02:26:07 +04:00
|
|
|
/REP { READ (stub env) EVAL PRINT } def
|
2014-03-26 02:15:32 +04:00
|
|
|
|
2014-03-30 00:17:00 +04:00
|
|
|
/stdin (%stdin) (r) file def
|
|
|
|
|
2014-03-26 02:15:32 +04:00
|
|
|
{ % loop
|
|
|
|
(user> ) print flush
|
|
|
|
|
2014-03-30 00:17:00 +04:00
|
|
|
stdin 99 string readline
|
2014-03-26 02:15:32 +04:00
|
|
|
|
|
|
|
not { exit } if % exit if EOF
|
|
|
|
|
|
|
|
%(\ngot line: ) print dup print (\n) print flush
|
2014-03-30 03:35:22 +04:00
|
|
|
|
2014-03-26 02:15:32 +04:00
|
|
|
REP print (\n) print
|
|
|
|
} bind loop
|
|
|
|
|
|
|
|
(\n) print % final newline before exit for cleanliness
|
|
|
|
quit
|