aboutsummaryrefslogtreecommitdiff
path: root/ps/reader.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/reader.ps
parent04517bc8265b6930e96735dd5d12b7aac7d86217 (diff)
downloadmal-aef93ea3969feee92e68358395d5750ebe83f57d.tar.gz
mal-aef93ea3969feee92e68358395d5750ebe83f57d.zip
PS: error handling, throw, print excpetions without dying.
Diffstat (limited to 'ps/reader.ps')
-rw-r--r--ps/reader.ps14
1 files changed, 9 insertions, 5 deletions
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