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/reader.ps | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) (limited to 'ps/reader.ps') diff --git a/ps/reader.ps b/ps/reader.ps index 0fa4c02..8575d64 100644 --- a/ps/reader.ps +++ b/ps/reader.ps @@ -63,8 +63,8 @@ /cnt 0 def { % loop idx str length ge { %if EOF - (Error: unexpected EOF reading string\n) print - error + (unexpected EOF reading string) + throw } if /ch str idx get def % current character /idx idx 1 add def @@ -119,8 +119,8 @@ { % loop str idx read_spaces /idx exch def pop str length idx le { %if EOF - (Error: unexpected EOF reading list\n) print - error + (unexpected EOF reading list) + throw } if /ch str idx get def % current character ch 41 eq { exit } if % ')' is end of list @@ -159,9 +159,13 @@ /ch str idx get def % current character ch 40 eq { %if ( str idx read_list + }{ ch 91 eq { %elseif [ + (unexpected '[') throw + }{ ch 93 eq { %elseif ] + (unexpected ']') throw }{ % else str idx read_atom - } ifelse + } ifelse } ifelse } ifelse %(stack vvv\n) print %pstack -- cgit v1.2.3