diff options
| author | Joel Martin <github@martintribe.org> | 2014-03-25 15:15:32 -0700 |
|---|---|---|
| committer | Joel Martin <github@martintribe.org> | 2014-03-25 15:20:17 -0700 |
| commit | 88f59d07a1a891d8dc180b9fb197b75533fe40f1 (patch) | |
| tree | 0df2e84c277eccf821a42b253bf8288cd4df6bed | |
| parent | 489effa585b4da2888112940218178ee21d02ff6 (diff) | |
| download | mal-88f59d07a1a891d8dc180b9fb197b75533fe40f1.tar.gz mal-88f59d07a1a891d8dc180b9fb197b75533fe40f1.zip | |
Postscript: step0_repl.ps
Run it using ghostscript:
gs -q -dNODISPLAY step0_repl.ps
| -rw-r--r-- | ps/step0_repl.ps | 44 |
1 files changed, 44 insertions, 0 deletions
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 |
