From 88f59d07a1a891d8dc180b9fb197b75533fe40f1 Mon Sep 17 00:00:00 2001 From: Joel Martin Date: Tue, 25 Mar 2014 15:15:32 -0700 Subject: Postscript: step0_repl.ps Run it using ghostscript: gs -q -dNODISPLAY step0_repl.ps --- ps/step0_repl.ps | 44 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) create mode 100644 ps/step0_repl.ps diff --git a/ps/step0_repl.ps b/ps/step0_repl.ps new file mode 100644 index 0000000..3aade39 --- /dev/null +++ b/ps/step0_repl.ps @@ -0,0 +1,44 @@ +% 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 +/REP { + READ (stub env) EVAL PRINT +} def + +{ % loop + (user> ) print flush + + %(%lineedit) (r) file 99 string readline + (%stdin) (r) file 99 string readline + + not { exit } if % exit if EOF + + %(\ngot line: ) print dup print (\n) print flush + REP print (\n) print +} bind loop + +(\n) print % final newline before exit for cleanliness +quit -- cgit v1.2.3