From aef93ea3969feee92e68358395d5750ebe83f57d Mon Sep 17 00:00:00 2001 From: Joel Martin Date: Sat, 29 Mar 2014 17:35:53 -0500 Subject: PS: error handling, throw, print excpetions without dying. --- ps/step2_eval.ps | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) (limited to 'ps/step2_eval.ps') diff --git a/ps/step2_eval.ps b/ps/step2_eval.ps index 72a91fa..dec403c 100644 --- a/ps/step2_eval.ps +++ b/ps/step2_eval.ps @@ -14,7 +14,12 @@ /ast exch def %(eval_ast: ) print ast == /nametype ast type eq { %if symbol - env ast get + env ast known { + env ast get + }{ + (') ast pr_str (' not found) + concatenate concatenate throw + } ifelse }{ /arraytype ast type eq { %elseif list [ ast { @@ -44,9 +49,7 @@ end } def % print /PRINT { - /exp exch def - %(printing: ) print exp == - exp pr_str + pr_str } def @@ -71,7 +74,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 -- cgit v1.2.3