Handle end-of-file error properly in the parser
authorMichael Spang <mspang@csclub.uwaterloo.ca>
Thu, 19 Nov 2009 07:28:23 +0000 (02:28 -0500)
committerMichael Spang <mspang@csclub.uwaterloo.ca>
Tue, 22 Dec 2009 03:09:49 +0000 (22:09 -0500)
Signed-off-by: Michael Spang <mspang@csclub.uwaterloo.ca>
awesome.rl

index 7130744..508fa00 100644 (file)
@@ -43,7 +43,7 @@ using namespace std;
     main := (cmd_install | cmd_remove | space)*;
 }%%
 
-%% write data nofinal;
+%% write data;
 
 #define BUFSIZE 128
 
@@ -79,7 +79,7 @@ void scanner(vector<char *> &add_list, vector<char *> &del_list)
 
         if (cs == inapt_error) {
             fprintf(stderr, "PARSE ERROR\n");
-            break;
+           exit(1);
         }
 
         have = 0;
@@ -91,6 +91,11 @@ void scanner(vector<char *> &add_list, vector<char *> &del_list)
             ts = buf;
         }
     }
+
+    if (cs < inapt_first_final) {
+       fprintf(stderr, "UNEXPECTED EOF\n");
+       exit(1);
+    }
 }
 
 /*