Added some debugging
[cascardo/grammar.git] / item.c
diff --git a/item.c b/item.c
index ef98647..8f4f4cf 100644 (file)
--- a/item.c
+++ b/item.c
@@ -1,17 +1,10 @@
 #include <grammar.h>
 #include <first.h>
+#include <item.h>
 #ifdef DEBUG
 #include <stdio.h>
 #endif
 
-typedef struct
-{
-  symbol_t* left;
-  rule_t* right;
-  GList* dot;
-  symbol_t* lookahead;
-} item_t;
-
 item_t* item_new (symbol_t* left, rule_t* right, symbol_t* lookahead)
 {
   item_t* item;
@@ -354,13 +347,13 @@ GHashTable* item_collection_lookup (GHashTable* collection,
   return symbols;
 }
 
-#define HASH_ITEM_SET(item_set) (((GPOINTER_TO_INT(item_set) & 0x3f00) >> 8))
+#define HASH_ITEM_SET(item_set) (item_set)
 #ifdef DEBUG
 void item_collection_print_each (gpointer key, gpointer val, gpointer data)
 {
   GHashTable* item_set;
   item_set = (GHashTable*) key;
-  fprintf (stdout, "Item %x:\n", HASH_ITEM_SET(key));
+  fprintf (stdout, "Item %p:\n", HASH_ITEM_SET(key));
   item_set_print (item_set);
   fprintf (stdout, "\n");
 }
@@ -369,7 +362,7 @@ void item_set_print_goto (gpointer key, gpointer val, gpointer data)
 {
   symbol_t* symbol;
   symbol = (symbol_t*) key;
-  fprintf (stdout, "GOTO (%x, %s) =\t %x\n", HASH_ITEM_SET(data),
+  fprintf (stdout, "GOTO (%p, %s) =\t %p\n", HASH_ITEM_SET(data),
           g_quark_to_string (symbol->value), HASH_ITEM_SET(val));
 }
 
@@ -420,7 +413,8 @@ GHashTable* item_collection_goto (GHashTable* collection, grammar_t* grammar,
     }
 }
 
-void item_set_collection (grammar_t* grammar, GHashTable* first, symbol_t* start)
+GHashTable* item_set_collection (grammar_t* grammar, GHashTable* first,
+                                symbol_t* start)
 {
   GHashTable* collection;
   GHashTable* item_set;
@@ -469,5 +463,5 @@ void item_set_collection (grammar_t* grammar, GHashTable* first, symbol_t* start
 #ifdef DEBUG
   item_collection_print (collection);
 #endif
-  g_hash_table_destroy (collection);
+  return collection;
 }