diff options
-rw-r--r-- | src/mesa/shader/grammar/grammar.c | 25 |
1 files changed, 23 insertions, 2 deletions
diff --git a/src/mesa/shader/grammar/grammar.c b/src/mesa/shader/grammar/grammar.c index 7f2ee42d21d..989e9544911 100644 --- a/src/mesa/shader/grammar/grammar.c +++ b/src/mesa/shader/grammar/grammar.c @@ -260,6 +260,8 @@ 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; } |