aboutsummaryrefslogtreecommitdiff
path: root/ps/step3_env.ps
diff options
context:
space:
mode:
authorJoel Martin <github@martintribe.org>2014-03-29 17:35:53 -0500
committerJoel Martin <github@martintribe.org>2014-03-29 17:35:53 -0500
commitaef93ea3969feee92e68358395d5750ebe83f57d (patch)
tree9e38fae1432ac26f2c4915f3f38d8ae6ccfe54f8 /ps/step3_env.ps
parent04517bc8265b6930e96735dd5d12b7aac7d86217 (diff)
downloadmal-aef93ea3969feee92e68358395d5750ebe83f57d.tar.gz
mal-aef93ea3969feee92e68358395d5750ebe83f57d.zip
PS: error handling, throw, print excpetions without dying.
Diffstat (limited to 'ps/step3_env.ps')
-rw-r--r--ps/step3_env.ps16
1 files changed, 10 insertions, 6 deletions
diff --git a/ps/step3_env.ps b/ps/step3_env.ps
index c2e65cb..908ff43 100644
--- a/ps/step3_env.ps
+++ b/ps/step3_env.ps
@@ -41,7 +41,7 @@ end } def
}{ /let* a0 eq { %if let*
/a1 ast 1 get def
/a2 ast 2 get def
- /let_env env env_new def
+ /let_env env [ ] [ ] env_new def
0 2 a1 length 1 sub { %for each pair
/idx exch def
let_env
@@ -63,14 +63,12 @@ end } def
% print
/PRINT {
- /exp exch def
- %(printing: ) print exp ==
- exp pr_str
+ pr_str
} def
% repl
-/repl_env null env_new def
+/repl_env null [ ] [ ] env_new def
/REP { READ repl_env EVAL PRINT } def
/_ref { repl_env 3 1 roll env_set pop } def
@@ -91,7 +89,13 @@ end } def
not { exit } if % exit if EOF
%(\ngot line: ) print dup print (\n) print flush
- REP print (\n) print
+ { %try
+ REP print (\n) print
+ } stopped {
+ (Error: ) print
+ get_error_data pr_str print (\n) print
+ clear
+ } if
} bind loop
(\n) print % final newline before exit for cleanliness