Updated from branch dev
[cascardo/grammar.git] / lr1.c
diff --git a/lr1.c b/lr1.c
index d7f2d98..2124bb1 100644 (file)
--- a/lr1.c
+++ b/lr1.c
@@ -1,5 +1,6 @@
 #include <grammar.h>
 #include <stdlib.h>
 #include <grammar.h>
 #include <stdlib.h>
+#include <lr1.h>
 
 enum { PARSER_SHIFT, PARSER_REDUCE, PARSER_ACCEPT };
 
 
 enum { PARSER_SHIFT, PARSER_REDUCE, PARSER_ACCEPT };
 
@@ -67,7 +68,7 @@ void transition_delete (transition_t* transition)
   g_free (transition);
 }
 
   g_free (transition);
 }
 
-static void lr1_push (lr1_t* parser, gint st, gpointer attrib)
+void lr1_push (lr1_t* parser, gint st, gpointer attrib)
 {
   state_t* state;
   state = g_malloc (sizeof (state_t));
 {
   state_t* state;
   state = g_malloc (sizeof (state_t));
@@ -103,7 +104,6 @@ lr1_t* lr1_new (nextcb cb, gpointer data)
   parser->data = data;
 
   parser->stack = NULL;
   parser->data = data;
 
   parser->stack = NULL;
-  lr1_push (parser, 0, NULL);
   parser->table = g_hash_table_new_full (g_direct_hash, g_direct_equal,
                                         NULL, g_hash_table_destroy);
 
   parser->table = g_hash_table_new_full (g_direct_hash, g_direct_equal,
                                         NULL, g_hash_table_destroy);
 
@@ -236,7 +236,7 @@ gpointer lr1_build (lr1_t* parser)
 
          for (l = grammar_get_rule (transition->right);
               l != NULL;
 
          for (l = grammar_get_rule (transition->right);
               l != NULL;
-              l = g_list_previous (l))
+              l = g_list_next (l))
            {
              gpointer attr;
              if (!lr1_pop (parser, &attr))
            {
              gpointer attr;
              if (!lr1_pop (parser, &attr))