first).
*/
+#include <stdio.h>
+
static void mem_free (void **);
/*
}
}
+
+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;
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;
}
if (get_identifier (&text, &g->syntax_symbol))
{
grammar_load_state_destroy (&g);
+ error_msg(__LINE__, "");
return 0;
}
eat_spaces (&text);
if (get_identifier (&text, &symbol))
{
grammar_load_state_destroy (&g);
+ error_msg(__LINE__, "");
return 0;
}
eat_spaces (&text);
if (get_emtcode (&text, &ma))
{
grammar_load_state_destroy (&g);
+ error_msg(__LINE__, "");
return 0;
}
if (get_regbyte (&text, &ma))
{
grammar_load_state_destroy (&g);
+ error_msg(__LINE__, "");
return 0;
}
if (get_errtext (&text, &ma))
{
grammar_load_state_destroy (&g);
+ error_msg(__LINE__, "");
return 0;
}
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;
}
if (get_rule (&text, &ru, g->maps, g->mapb))
{
grammar_load_state_destroy (&g);
+ error_msg(__LINE__, "");
return 0;
}
if (ma == NULL)
{
grammar_load_state_destroy (&g);
+ error_msg(__LINE__, "");
return 0;
}
g->di->m_regbytes))
{
grammar_load_state_destroy (&g);
+ error_msg(__LINE__, "update_dependencies() failed");
return 0;
}