Make error reporting more consistent
authorMichael Spang <mspang@csclub.uwaterloo.ca>
Fri, 11 Dec 2009 22:37:29 +0000 (17:37 -0500)
committerMichael Spang <mspang@csclub.uwaterloo.ca>
Tue, 22 Dec 2009 03:11:48 +0000 (22:11 -0500)
Signed-off-by: Michael Spang <mspang@csclub.uwaterloo.ca>
parser.rl

index c574fd7..f268950 100644 (file)
--- a/parser.rl
+++ b/parser.rl
@@ -147,16 +147,12 @@ void parser(const char *filename, inapt_block *top_block)
         char *p = buf + have, *pe, *eof = 0;
         int len, space = BUFSIZE - have;
 
-        if (space == 0) {
-            fprintf(stderr, "OUT OF BUFFER SPACE\n");
-            exit(1);
-        }
+        if (!space)
+            badsyntax(curfile, curline, 0, "Overlength token");
 
         len = read(fd, p, space);
-        if (len < 0) {
-            fprintf(stderr, "IO ERROR\n");
-            exit(1);
-        }
+        if (len < 0)
+            fatalpe("Unable to read spec");
         pe = p + len;
 
         if (!len) {
@@ -178,10 +174,8 @@ void parser(const char *filename, inapt_block *top_block)
         }
     }
 
-    if (cs < inapt_first_final) {
-       fprintf(stderr, "UNEXPECTED EOF\n");
-       exit(1);
-    }
+    if (cs < inapt_first_final)
+        badsyntax(curfile, curline, 0, "Unexpected EOF");
 
     if (top)
         badsyntax(curfile, curline, 0, "Unclosed block at EOF");