]> git.saurik.com Git - bison.git/blobdiff - src/LR0.c
* src/gram.h, src/gram.c (rules_rhs_length): New.
[bison.git] / src / LR0.c
index 47ce6dd2c613346e6309092327a82171cf85fcf9..02798cd9eb6c77203407eb692caf16f177d56262 100644 (file)
--- a/src/LR0.c
+++ b/src/LR0.c
@@ -1,5 +1,5 @@
 /* Generate the nondeterministic finite state machine for bison,
 /* Generate the nondeterministic finite state machine for bison,
-   Copyright 1984, 1986, 1989, 2000, 2001  Free Software Foundation, Inc.
+   Copyright 1984, 1986, 1989, 2000, 2001, 2002  Free Software Foundation, Inc.
 
    This file is part of Bison, the GNU Compiler Compiler.
 
 
    This file is part of Bison, the GNU Compiler Compiler.
 
@@ -23,6 +23,7 @@
    The entry point is generate_states.  */
 
 #include "system.h"
    The entry point is generate_states.  */
 
 #include "system.h"
+#include "bitset.h"
 #include "symtab.h"
 #include "getargs.h"
 #include "reader.h"
 #include "symtab.h"
 #include "getargs.h"
 #include "reader.h"
@@ -34,7 +35,7 @@
 #include "lalr.h"
 #include "reduce.h"
 
 #include "lalr.h"
 #include "reduce.h"
 
-int nstates;
+unsigned int nstates;
 /* 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,
 /* 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,
@@ -113,6 +114,7 @@ allocate_storage (void)
   shiftset = XCALLOC (short, nsyms);
   redset = XCALLOC (short, nrules + 1);
   state_hash = XCALLOC (state_t *, STATE_HASH_SIZE);
   shiftset = XCALLOC (short, nsyms);
   redset = XCALLOC (short, nrules + 1);
   state_hash = XCALLOC (state_t *, STATE_HASH_SIZE);
+  shift_symbol = XCALLOC (short, nsyms);
 }
 
 
 }
 
 
@@ -154,7 +156,6 @@ new_itemsets (void)
   for (i = 0; i < nsyms; i++)
     kernel_size[i] = 0;
 
   for (i = 0; i < nsyms; i++)
     kernel_size[i] = 0;
 
-  shift_symbol = XCALLOC (short, nsyms);
   nshifts = 0;
 
   for (i = 0; i < nitemset; ++i)
   nshifts = 0;
 
   for (i = 0; i < nitemset; ++i)
@@ -188,7 +189,7 @@ new_state (int symbol)
 
   if (trace_flag)
     fprintf (stderr, "Entering new_state, state = %d, symbol = %d (%s)\n",
 
   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);
 
   if (nstates >= MAXSHORT)
     fatal (_("too many states (max %d)"), MAXSHORT);
@@ -227,7 +228,7 @@ get_state (int symbol)
 
   if (trace_flag)
     fprintf (stderr, "Entering get_state, state = %d, symbol = %d (%s)\n",
 
   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.
      */
 
   /* Add up the target state's active item numbers to get a hash key.
      */
@@ -364,15 +365,15 @@ save_reductions (void)
 }
 
 \f
 }
 
 \f
-/*--------------------.
-| Build STATE_TABLE.  |
-`--------------------*/
+/*---------------.
+| Build STATES.  |
+`---------------*/
 
 static void
 
 static void
-set_state_table (void)
+set_states (void)
 {
   state_t *sp;
 {
   state_t *sp;
-  state_table = XCALLOC (state_t *, nstates);
+  states = XCALLOC (state_t *, nstates);
 
   for (sp = first_state; sp; sp = sp->next)
     {
 
   for (sp = first_state; sp; sp = sp->next)
     {
@@ -386,7 +387,7 @@ set_state_table (void)
       if (!sp->reductions)
        sp->reductions = reductions_new (0);
 
       if (!sp->reductions)
        sp->reductions = reductions_new (0);
 
-      state_table[sp->number] = sp;
+      states[sp->number] = sp;
     }
 }
 
     }
 }
 
@@ -406,7 +407,8 @@ generate_states (void)
     {
       if (trace_flag)
        fprintf (stderr, "Processing state %d (reached by %s)\n",
     {
       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
       /* 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
@@ -431,6 +433,6 @@ generate_states (void)
   free_closure ();
   free_storage ();
 
   free_closure ();
   free_storage ();
 
-  /* Set up STATE_TABLE. */
-  set_state_table ();
+  /* Set up STATES. */
+  set_states ();
 }
 }