Added GPLv2+ as license for libgrammatic
[cascardo/grammar.git] / lr1_gen.c
index 3ff7cbf..71da644 100644 (file)
--- a/lr1_gen.c
+++ b/lr1_gen.c
@@ -1,3 +1,23 @@
+/*
+ *  Copyright (C) 2005  Thadeu Lima de Souza Cascardo <cascardo@holoscopio.com>
+ *
+ *  This program is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *  the Free Software Foundation; either version 2 of the License, or
+ *  (at your option) any later version.
+ *
+ *  This program is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU General Public License for more details.
+ *
+ *  You should have received a copy of the GNU General Public License along
+ *  with this program; if not, write to the Free Software Foundation, Inc.,
+ *  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ */
+
+
+
 #include <grammar.h>
 #include <item.h>
 #include <lr1.h>
@@ -42,20 +62,23 @@ void lr1_gen_add (gpointer key, gpointer val, gpointer data)
          if (item->dot == NULL)
            {
 #ifdef DEBUG
-             printf ("ACCEPT: %x\n", key);
+             printf ("ACCEPT: %p\n", key);
 #endif
              transition = transition_accept_new ();
              lr1_add (data, key, symbol_new (TRUE, 0), transition);
            }
          else
            {
+#ifdef DEBUG
+             printf ("START: %p\n", key);
+#endif
              lr1_push (data, key, NULL);
            }
        }
       else if (item->dot == NULL)
        {
 #ifdef DEBUG
-         printf ("REDUCE: %x, %s\n", key,
+         printf ("REDUCE: %p, %s\n", key,
                  g_quark_to_string (item->lookahead->value));
 #endif
          transition = transition_reduce_new (item->left, item->right);
@@ -80,7 +103,7 @@ void lr1_gen_add (gpointer key, gpointer val, gpointer data)
       l = g_list_next (l);
 
 #ifdef DEBUG
-      printf ("SHIFT: %x, %s, %x\n", key,
+      printf ("SHIFT: %p, %s, %p\n", key,
              g_quark_to_string (symbol->value), l->data);
 #endif
       transition = transition_shift_new (l->data);
@@ -104,6 +127,9 @@ lr1_t* lr1_gen (grammar_t* grammar, symbol_t* start, nextcb cb, gpointer data)
   lr1 = lr1_new (cb, data);
 
   first = grammar_first (grammar);
+#ifdef DEBUG
+  first_print (first);
+#endif
 
   collection = item_set_collection (grammar, first, start);