report error message when something fails
authorBrian <brian@yutani.localnet.net>
Fri, 19 Jan 2007 19:02:31 +0000 (12:02 -0700)
committerBrian <brian@yutani.localnet.net>
Fri, 19 Jan 2007 19:02:31 +0000 (12:02 -0700)
src/mesa/shader/grammar/grammar.c

index 7f2ee42..989e954 100644 (file)
     first).
 */
 
+#include <stdio.h>
+
 static void mem_free (void **);
 
 /*
@@ -2797,10 +2799,16 @@ static void grammar_load_state_destroy (grammar_load_state **gr)
     }
 }
 
+
+static void error_msg(int line, const char *msg)
+{
+   fprintf(stderr, "Error in grammar_load_from_text() at line %d: %s\n", line, msg);
+}
+
+
 /*
     the API
 */
-
 grammar grammar_load_from_text (const byte *text)
 {
     grammar_load_state *g = NULL;
@@ -2809,13 +2817,16 @@ grammar grammar_load_from_text (const byte *text)
     clear_last_error ();
 
     grammar_load_state_create (&g);
-    if (g == NULL)
+    if (g == NULL) {
+        error_msg(__LINE__, "");
         return 0;
+    }
 
     dict_create (&g->di);
     if (g->di == NULL)
     {
         grammar_load_state_destroy (&g);
+        error_msg(__LINE__, "");
         return 0;
     }
 
@@ -2829,6 +2840,7 @@ grammar grammar_load_from_text (const byte *text)
     if (get_identifier (&text, &g->syntax_symbol))
     {
         grammar_load_state_destroy (&g);
+        error_msg(__LINE__, "");
         return 0;
     }
     eat_spaces (&text);
@@ -2848,6 +2860,7 @@ grammar grammar_load_from_text (const byte *text)
         if (get_identifier (&text, &symbol))
         {
             grammar_load_state_destroy (&g);
+            error_msg(__LINE__, "");
             return 0;
         }
         eat_spaces (&text);
@@ -2862,6 +2875,7 @@ grammar grammar_load_from_text (const byte *text)
             if (get_emtcode (&text, &ma))
             {
                 grammar_load_state_destroy (&g);
+                error_msg(__LINE__, "");
                 return 0;
             }
 
@@ -2877,6 +2891,7 @@ grammar grammar_load_from_text (const byte *text)
             if (get_regbyte (&text, &ma))
             {
                 grammar_load_state_destroy (&g);
+                error_msg(__LINE__, "");
                 return 0;
             }
 
@@ -2892,6 +2907,7 @@ grammar grammar_load_from_text (const byte *text)
             if (get_errtext (&text, &ma))
             {
                 grammar_load_state_destroy (&g);
+                error_msg(__LINE__, "");
                 return 0;
             }
 
@@ -2905,12 +2921,14 @@ grammar grammar_load_from_text (const byte *text)
             if (g->di->m_string != NULL)
             {
                 grammar_load_state_destroy (&g);
+                error_msg(__LINE__, "");
                 return 0;
             }
 
             if (get_identifier (&text, &g->string_symbol))
             {
                 grammar_load_state_destroy (&g);
+                error_msg(__LINE__, "");
                 return 0;
             }
 
@@ -2927,6 +2945,7 @@ grammar grammar_load_from_text (const byte *text)
             if (get_rule (&text, &ru, g->maps, g->mapb))
             {
                 grammar_load_state_destroy (&g);
+                error_msg(__LINE__, "");
                 return 0;
             }
 
@@ -2940,6 +2959,7 @@ grammar grammar_load_from_text (const byte *text)
             if (ma == NULL)
             {
                 grammar_load_state_destroy (&g);
+                error_msg(__LINE__, "");
                 return 0;
             }
 
@@ -2953,6 +2973,7 @@ grammar grammar_load_from_text (const byte *text)
         g->di->m_regbytes))
     {
         grammar_load_state_destroy (&g);
+        error_msg(__LINE__, "update_dependencies() failed");
         return 0;
     }