#include <grammar.h>
+#ifdef DEBUG
+#include <stdio.h>
+#endif
typedef struct
{
g_free (item);
}
+#ifdef DEBUG
+void item_print (item_t* item)
+{
+ GList* l;
+ fprintf (stdout, "%s -> ", g_quark_to_string (item->left->value));
+ l = grammar_rule_get (item->right);
+ while (l != NULL)
+ {
+ symbol_t* symbol;
+ symbol = (symbol_t*) l->data;
+ if (l == item->dot)
+ {
+ fprintf (stdout, ".");
+ }
+ fprintf (stdout, " %s ", g_quark_to_string (symbol->value));
+ }
+ if (item->dot == NULL)
+ {
+ fprintf (stdout, ".");
+ }
+ fprintf (stdout, "\n");
+}
+#endif
+
GHashTable* item_set_new ()
{
return g_hash_table_new_full (item_hash, item_equal, item_delete, NULL);
return newitem_set;
}
+#ifdef DEBUG
+void item_set_print_each (gpointer key, gpointer val, gpointer data)
+{
+ item_print (key);
+}
+
+void item_set_print (GHashTable* item_set)
+{
+ g_hash_table_foreach (item_set, item_set_print_each, NULL);
+}
+#endif
+
void item_set_closure_step (GHashTable* item_set, Grammar* grammar,
item_t* item)
{
return state;
}
+#ifdef DEBUG
+void item_collection_print_each (gpointer key, gpointer val, gpointer data)
+{
+ GHashTable* item_set;
+ state_t* state;
+ item_set = (GHashTable*) key;
+ state = (state_t*) val;
+ fprintf (stdout, "Item %d:\n", state->code);
+ item_set_print (item_set);
+ fprintf (stdout, "\n");
+}
+
+void item_set_print_goto (gpointer key, gpointer val, gpointer data)
+{
+ symbol_t* symbol;
+ gint code;
+ state_t* state;
+ symbol = (symbol_t*) symbol;
+ code = GINT_TO_POINTER (val);
+ state = (state_t*) data;
+ fprintf (stdout, "GOTO (%d, %s) =\t %d\n", state->code,
+ g_quark_to_string (symbol->value), code);
+}
+
+void item_collection_print_goto (gpointer key, gpointer val, gpointer data)
+{
+ state_t* state;
+ state = (state_t*) val;
+ g_hash_table_foreach (state->symbols, item_set_print_goto, state);
+ fprintf (stdout, "\n");
+}
+
+void item_collection_print (GHashTable* collection)
+{
+ g_hash_table_foreach (collection, item_collection_print_each, NULL);
+ g_hash_table_foreach (collection, item_collection_print_goto, NULL);
+}
+#endif
+
GHashTable* item_collection_goto (GHashTable* collection, Grammar* grammar,
GHashTable* item_set, symbol_t* symbol)
{
new_item_sets = g_list_next (new_item_sets);
}
g_list_free (new_item_sets);
+#ifdef DEBUG
+ item_collection_print (collection);
+#endif
+ g_hash_table_destroy (collection);
}