]> git.saurik.com Git - bison.git/blobdiff - src/LR0.c
* src/lalr.c (build_relations): Rename `states' as `states1'.
[bison.git] / src / LR0.c
index 3a036e84ecf0c4561b7c1a97bf72eeaba4bc6c36..2b78dd03c76c53a6242862283d7e10294614a1a9 100644 (file)
--- a/src/LR0.c
+++ b/src/LR0.c
@@ -23,6 +23,7 @@
    The entry point is generate_states.  */
 
 #include "system.h"
+#include "symtab.h"
 #include "getargs.h"
 #include "reader.h"
 #include "gram.h"
 #include "reduce.h"
 
 int nstates;
-int final_state;
+/* Initialize the final state to -1, otherwise, it might be set to 0
+   by default, and since we don't compute the reductions of the final
+   state, we end up not computing the reductions of the initial state,
+   which is of course needed.
+
+   FINAL_STATE is properly set by new_state when it recognizes the
+   accessing symbol: EOF.  */
+int final_state = -1;
 static state_t *first_state = NULL;
 
 static state_t *this_state = NULL;
@@ -180,7 +188,7 @@ new_state (int symbol)
 
   if (trace_flag)
     fprintf (stderr, "Entering new_state, state = %d, symbol = %d (%s)\n",
-            this_state->number, symbol, tags[symbol]);
+            this_state->number, symbol, symbols[symbol]->tag);
 
   if (nstates >= MAXSHORT)
     fatal (_("too many states (max %d)"), MAXSHORT);
@@ -219,7 +227,7 @@ get_state (int symbol)
 
   if (trace_flag)
     fprintf (stderr, "Entering get_state, state = %d, symbol = %d (%s)\n",
-            this_state->number, symbol, tags[symbol]);
+            this_state->number, symbol, symbols[symbol]->tag);
 
   /* Add up the target state's active item numbers to get a hash key.
      */
@@ -398,7 +406,8 @@ generate_states (void)
     {
       if (trace_flag)
        fprintf (stderr, "Processing state %d (reached by %s)\n",
-                this_state->number, tags[this_state->accessing_symbol]);
+                this_state->number,
+                symbols[this_state->accessing_symbol]->tag);
       /* Set up ruleset and itemset for the transitions out of this
          state.  ruleset gets a 1 bit for each rule that could reduce
          now.  itemset gets a vector of all the items that could be