bison-patches
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

03-fyi-item-number-t.patch


From: Akim Demaille
Subject: 03-fyi-item-number-t.patch
Date: Mon, 08 Apr 2002 13:44:48 +0200

Index: ChangeLog
from  Akim Demaille  <address@hidden>

        * src/gram.h (item_number_t): New, the type of item numbers in
        RITEM.  Note that it must be able to code symbol numbers as
        positive number, and the negation of rule numbers as negative
        numbers.
        Adjust all dependencies (pretty many).
        * src/reduce.c (rule): Remove this `short *' pointer: use
        item_number_t.
        * src/system.h (MINSHORT, MAXSHORT): Remove.
        Include `limits.h'.
        Adjust dependencies to using SHRT_MAX and SHRT_MIN.
        (shortcpy): Remove.
        (MAXTABLE): Move to...
        * src/output.c (MAXTABLE): here.
        (prepare_rules): Use output_int_table to output rhs.
        * data/bison.simple, data/bison.c++: Adjust.
        * tests/torture.at (Big triangle): Move the limit from 254 to
        500.
        * tests/regression.at (Web2c Actions): Ajust.

        Trying with bigger grammars shows various phenomena: at 3000 (28Mb
        of grammar file) bison is killed by my system, at 2000 (12Mb) bison
        passes, but produces negative #line number, once fixed, GCC is
        killed while compiling 14Mb, at 1500 (6.7 Mb of grammar, 8.2Mb of
        C), it passes.
        * src/state.h (state_h): Code input lines on ints, not shorts.

Index: NEWS
--- NEWS Wed, 03 Apr 2002 22:07:02 +0200 akim
+++ NEWS Sun, 07 Apr 2002 21:09:28 +0200 akim
@@ -3,6 +3,9 @@

 Changes in version 1.49a:

+* Large grammars
+  Are now supported.
+
 * The initial rule is explicit.
   Bison used to play hacks with the initial rule, which the user does
   not write.  It is now explicit, and visible in the reports and
Index: src/LR0.c
--- src/LR0.c Sat, 06 Apr 2002 22:33:26 +0200 akim
+++ src/LR0.c Sun, 07 Apr 2002 20:56:30 +0200 akim
@@ -56,9 +56,9 @@
 static short *redset = NULL;
 static short *shiftset = NULL;

-static short **kernel_base = NULL;
+static item_number_t **kernel_base = NULL;
 static int *kernel_size = NULL;
-static short *kernel_items = NULL;
+static item_number_t *kernel_items = NULL;

 /* hash table for states, to recognize equivalent ones.  */

@@ -70,7 +70,7 @@
 allocate_itemsets (void)
 {
   int i, r;
-  short *rhsp;
+  item_number_t *rhsp;

   /* Count the number of occurrences of all the symbols in RITEMS.
      Note that useless productions (hence useless nonterminals) are
@@ -92,9 +92,9 @@
      appears as an item, which is symbol_count[symbol].
      We allocate that much space for each symbol.  */

-  kernel_base = XCALLOC (short *, nsyms);
+  kernel_base = XCALLOC (item_number_t *, nsyms);
   if (count)
-    kernel_items = XCALLOC (short, count);
+    kernel_items = XCALLOC (item_number_t, count);

   count = 0;
   for (i = 0; i < nsyms; i++)
@@ -194,15 +194,16 @@
             nstates, symbol, quotearg_style (escape_quoting_style,
                                              symbols[symbol]->tag));

-  if (nstates >= MAXSHORT)
-    fatal (_("too many states (max %d)"), MAXSHORT);
+  if (nstates >= SHRT_MAX)
+    fatal (_("too many states (max %d)"), SHRT_MAX);

   p = STATE_ALLOC (kernel_size[symbol]);
   p->accessing_symbol = symbol;
   p->number = nstates;
   p->nitems = kernel_size[symbol];

-  shortcpy (p->items, kernel_base[symbol], kernel_size[symbol]);
+  memcpy (p->items, kernel_base[symbol],
+         kernel_size[symbol] * sizeof (kernel_base[symbol][0]));

   /* If this is the eoftoken, and this is not the initial state, then
      this is the final state.  */
@@ -340,7 +341,7 @@
 save_shifts (void)
 {
   shifts *p = shifts_new (nshifts);
-  shortcpy (p->shifts, shiftset, nshifts);
+  memcpy (p->shifts, shiftset, nshifts * sizeof (shiftset[0]));
   this_state->shifts = p;
 }

@@ -372,7 +373,7 @@

   /* Make a reductions structure and copy the data into it.  */
   this_state->reductions = reductions_new (count);
-  shortcpy (this_state->reductions->rules, redset, count);
+  memcpy (this_state->reductions->rules, redset, count * sizeof (redset[0]));
 }

 
Index: src/closure.c
--- src/closure.c Sat, 06 Apr 2002 22:33:26 +0200 akim
+++ src/closure.c Sun, 07 Apr 2002 20:50:19 +0200 akim
@@ -30,7 +30,7 @@
 #include "derives.h"

 /* NITEMSET is the size of the array ITEMSET.  */
-short *itemset;
+item_number_t *itemset;
 int nritemset;

 static bitset ruleset;
@@ -49,13 +49,13 @@
 `-----------------*/

 static void
-print_closure (const char *title, short *array, size_t size)
+print_closure (const char *title, item_number_t *array, size_t size)
 {
   size_t i;
   fprintf (stderr, "Closure: %s\n", title);
   for (i = 0; i < size; ++i)
     {
-      short *rp;
+      item_number_t *rp;
       fprintf (stderr, "  %2d: .", array[i]);
       for (rp = &ritem[array[i]]; *rp >= 0; ++rp)
        fprintf (stderr, " %s",
@@ -100,7 +100,7 @@
       for (j = 0; j < nrules + 1; j++)
        if (bitset_test (FDERIVES (i), j))
          {
-           short *rhsp;
+           item_number_t *rhsp;
            fprintf (stderr, "\t\t%d:", j - 1);
            for (rhsp = rules[j].rhs; *rhsp >= 0; ++rhsp)
              fprintf (stderr, " %s",
@@ -231,7 +231,7 @@
 void
 new_closure (int n)
 {
-  itemset = XCALLOC (short, n);
+  itemset = XCALLOC (item_number_t, n);

   ruleset = bitset_create (nrules + 1, BITSET_FIXED);

@@ -241,7 +241,7 @@


 void
-closure (short *core, int n)
+closure (item_number_t *core, int n)
 {
   /* Index over CORE. */
   int c;
@@ -263,7 +263,7 @@
   for (ruleno = 0; ruleno < nrules + 1; ++ruleno)
     if (bitset_test (ruleset, ruleno))
       {
-       int itemno = rules[ruleno].rhs - ritem;
+       item_number_t itemno = rules[ruleno].rhs - ritem;
        while (c < n && core[c] < itemno)
          {
            itemset[nritemset] = core[c];
Index: src/closure.h
--- src/closure.h Sat, 06 Apr 2002 22:33:26 +0200 akim
+++ src/closure.h Sun, 07 Apr 2002 20:50:23 +0200 akim
@@ -42,14 +42,14 @@
    significant).  CLOSURE places there the indices of all items which
    represent units of input that could arrive next.  */

-void closure PARAMS ((short *items, int n));
+void closure PARAMS ((item_number_t *items, int n));


 /* Frees ITEMSET, RULESET and internal data.  */

 void free_closure PARAMS ((void));

-extern short *itemset;
+extern item_number_t *itemset;
 extern int nritemset;

 #endif /* !CLOSURE_H_ */
Index: src/derives.c
--- src/derives.c Mon, 25 Mar 2002 21:34:54 +0100 akim
+++ src/derives.c Sun, 07 Apr 2002 20:20:21 +0200 akim
@@ -42,7 +42,7 @@
       fprintf (stderr, "\t%s derives\n", symbols[i]->tag);
       for (sp = derives[i]; *sp > 0; sp++)
        {
-         short *rhsp;
+         item_number_t *rhsp;
          fprintf (stderr, "\t\t%d:", *sp);
          for (rhsp = rules[*sp].rhs; *rhsp >= 0; ++rhsp)
            fprintf (stderr, " %s", symbols[*rhsp]->tag);
Index: src/gram.c
--- src/gram.c Sun, 07 Apr 2002 17:21:28 +0200 akim
+++ src/gram.c Sun, 07 Apr 2002 20:20:21 +0200 akim
@@ -27,7 +27,7 @@

 /* comments for these variables are in gram.h  */

-short *ritem = NULL;
+item_number_t *ritem = NULL;
 int nritems = 0;

 rule_t *rules = NULL;
@@ -59,7 +59,7 @@
 rule_rhs_length (rule_t *rule)
 {
   int res = 0;
-  short *rhsp;
+  item_number_t *rhsp;
   for (rhsp = rule->rhs; *rhsp >= 0; ++rhsp)
     ++res;
   return res;
Index: src/gram.h
--- src/gram.h Sun, 07 Apr 2002 17:21:28 +0200 akim
+++ src/gram.h Sun, 07 Apr 2002 21:19:04 +0200 akim
@@ -109,11 +109,14 @@
 extern int ntokens;
 extern int nvars;

-extern short *ritem;
+#define ITEM_NUMBER_MAX INT_MAX
+typedef int item_number_t;
+extern item_number_t *ritem;
 extern int nritems;

 extern int start_symbol;

+
 typedef struct rule_s
 {
   /* The number of the rule in the source.  It is usually the index in
@@ -125,7 +128,7 @@
   short number;

   symbol_t *lhs;
-  short *rhs;
+  item_number_t *rhs;

   /* This symbol provides both the associativity, and the precedence. */
   symbol_t *prec;
@@ -133,14 +136,14 @@
   /* This symbol was attached to the rule via %prec. */
   symbol_t *precsym;

-  short line;
+  int line;
   bool useful;

   const char *action;
-  short action_line;
+  int action_line;

   const char *guard;
-  short guard_line;
+  int guard_line;
 } rule_t;

 extern struct rule_s *rules;
Index: src/lalr.c
--- src/lalr.c Sat, 06 Apr 2002 00:18:20 +0200 akim
+++ src/lalr.c Sun, 07 Apr 2002 20:56:27 +0200 akim
@@ -28,11 +28,11 @@
 #include "bitset.h"
 #include "bitsetv.h"
 #include "quotearg.h"
+#include "symtab.h"
+#include "gram.h"
 #include "reader.h"
 #include "types.h"
 #include "LR0.h"
-#include "symtab.h"
-#include "gram.h"
 #include "complain.h"
 #include "lalr.h"
 #include "nullable.h"
@@ -170,8 +170,8 @@
       shifts *sp = states[state]->shifts;
       for (i = sp->nshifts - 1; i >= 0 && SHIFT_IS_GOTO (sp, i); --i)
        {
-         if (ngotos == MAXSHORT)
-           fatal (_("too many gotos (max %d)"), MAXSHORT);
+         if (ngotos == SHRT_MAX)
+           fatal (_("too many gotos (max %d)"), SHRT_MAX);

          ngotos++;
          goto_map[SHIFT_SYMBOL (sp, i)]++;
@@ -275,7 +275,7 @@
       if (nedges)
        {
          reads[i] = XCALLOC (short, nedges + 1);
-         shortcpy (reads[i], edge, nedges);
+         memcpy (reads[i], edge, nedges * sizeof (edge[0]));
          reads[i][nedges] = -1;
          nedges = 0;
        }
@@ -415,7 +415,7 @@
        {
          int done;
          int length = 1;
-         short *rp;
+         item_number_t *rp;
          state_t *state = states[from_state[i]];
          states1[0] = state->number;

Index: src/main.c
--- src/main.c Sun, 03 Mar 2002 12:18:39 +0100 akim
+++ src/main.c Sun, 07 Apr 2002 20:41:19 +0200 akim
@@ -23,6 +23,8 @@
 #include "system.h"
 #include "bitset.h"
 #include "getargs.h"
+#include "symtab.h"
+#include "gram.h"
 #include "files.h"
 #include "complain.h"
 #include "derives.h"
@@ -36,7 +38,6 @@
 #include "conflicts.h"
 #include "print_graph.h"
 #include "muscle_tab.h"
-#include "symtab.h"
 #include "lex.h"

 /* The name this program was run with, for messages.  */
Index: src/nullable.c
--- src/nullable.c Mon, 25 Mar 2002 21:34:54 +0100 akim
+++ src/nullable.c Sun, 07 Apr 2002 20:20:21 +0200 akim
@@ -74,7 +74,7 @@
        if (rules[ruleno].rhs[0] >= 0)
          {
            /* This rule has a non empty RHS. */
-           short *r;
+           item_number_t *r;
            int any_tokens = 0;
            for (r = rules[ruleno].rhs; *r >= 0; ++r)
              if (ISTOKEN (*r))
Index: src/output.c
--- src/output.c Sun, 07 Apr 2002 17:21:28 +0200 akim
+++ src/output.c Sun, 07 Apr 2002 20:34:49 +0200 akim
@@ -153,11 +153,47 @@
 `----------------------------------------------------------------*/

 static inline long int
-output_table_data (struct obstack *oout,
-                  short *table_data,
-                  short first,
-                  int begin,
-                  int end)
+output_short_table (struct obstack *oout,
+                   short *table_data,
+                   short first,
+                   int begin,
+                   int end)
+{
+  long int max = first;
+  int i;
+  int j = 1;
+
+  obstack_fgrow1 (oout, "%6d", first);
+  for (i = begin; i < end; ++i)
+    {
+      obstack_1grow (oout, ',');
+      if (j >= 10)
+       {
+         obstack_sgrow (oout, "\n  ");
+         j = 1;
+       }
+      else
+       ++j;
+      obstack_fgrow1 (oout, "%6d", table_data[i]);
+      if (table_data[i] > max)
+       max = table_data[i];
+    }
+  obstack_1grow (oout, 0);
+
+  return max;
+}
+
+
+/*--------------------.
+| Similar, for ints.  |
+`--------------------*/
+
+static inline long int
+output_int_table (struct obstack *oout,
+                 int *table_data,
+                 int first,
+                 int begin,
+                 int end)
 {
   long int max = first;
   int i;
@@ -192,7 +228,7 @@
 static void
 prepare_tokens (void)
 {
-  long int max = output_table_data (&format_obstack, token_translations,
+  long int max = output_short_table (&format_obstack, token_translations,
                                    0, 1, max_user_token_number + 1);
   muscle_insert ("translate", obstack_finish (&format_obstack));
   MUSCLE_INSERT_LONG_INT ("token_number_max", max);
@@ -237,7 +273,7 @@
     short *values = XCALLOC (short, ntokens + 1);
     for (i = 0; i < ntokens + 1; ++i)
       values[i] = symbols[i]->user_token_number;
-    output_table_data (&format_obstack, values,
+    output_short_table (&format_obstack, values,
                       0, 1, ntokens + 1);
     muscle_insert ("toknum", obstack_finish (&format_obstack));
     free (values);
@@ -253,10 +289,11 @@
 static void
 prepare_rules (void)
 {
-  short *rhsp;
+  long int max;
+  item_number_t *rhsp;
   int r;
   int i = 0;
-  short *rhs = XMALLOC (short, nritems);
+  item_number_t *rhs = XMALLOC (item_number_t, nritems);
   short *prhs = XMALLOC (short, nrules + 1);
   short *r1 = XMALLOC (short, nrules + 1);
   short *r2 = XMALLOC (short, nrules + 1);
@@ -280,19 +317,20 @@
     }
   assert (i == nritems);

-  output_table_data (&format_obstack, rhs, ritem[0], 1, nritems);
+  max = output_int_table (&format_obstack, rhs, ritem[0], 1, nritems);
   muscle_insert ("rhs", obstack_finish (&format_obstack));
+  MUSCLE_INSERT_LONG_INT ("rhs_number_max", max);

-  output_table_data (&format_obstack, prhs, 0, 1, nrules + 1);
+  output_short_table (&format_obstack, prhs, 0, 1, nrules + 1);
   muscle_insert ("prhs", obstack_finish (&format_obstack));

-  output_table_data (&format_obstack, rline, 0, 1, nrules + 1);
+  output_short_table (&format_obstack, rline, 0, 1, nrules + 1);
   muscle_insert ("rline", obstack_finish (&format_obstack));

-  output_table_data (&format_obstack, r1, 0, 1, nrules + 1);
+  output_short_table (&format_obstack, r1, 0, 1, nrules + 1);
   muscle_insert ("r1", obstack_finish (&format_obstack));

-  output_table_data (&format_obstack, r2, 0, 1, nrules + 1);
+  output_short_table (&format_obstack, r2, 0, 1, nrules + 1);
   muscle_insert ("r2", obstack_finish (&format_obstack));

   free (rhs);
@@ -311,7 +349,7 @@
   short *values = (short *) alloca (sizeof (short) * nstates);
   for (i = 0; i < nstates; ++i)
     values[i] = states[i]->accessing_symbol;
-  output_table_data (&format_obstack, values,
+  output_short_table (&format_obstack, values,
                     0, 1, nstates);
   muscle_insert ("stos", obstack_finish (&format_obstack));
 }
@@ -323,7 +361,7 @@
 | default action (yydefact) for the state.  In addition, actrow is  |
 | filled with what to do for each kind of token, index by symbol    |
 | number, with zero meaning do the default action.  The value       |
-| MINSHORT, a very negative number, means this situation is an      |
+| SHRT_MIN, a very negative number, means this situation is an      |
 | error.  The parser recognizes this value specially.               |
 |                                                                   |
 | This is where conflicts are resolved.  The loop over lookahead    |
@@ -384,11 +422,11 @@
     }

   /* See which tokens are an explicit error in this state (due to
-     %nonassoc).  For them, record MINSHORT as the action.  */
+     %nonassoc).  For them, record SHRT_MIN as the action.  */
   for (i = 0; i < errp->nerrs; i++)
     {
       int symbol = errp->errs[i];
-      actrow[symbol] = MINSHORT;
+      actrow[symbol] = SHRT_MIN;
     }

   /* Now find the most common reduction and make it the default action
@@ -438,7 +476,7 @@

   if (default_rule == 0)
     for (i = 0; i < ntokens; i++)
-      if (actrow[i] == MINSHORT)
+      if (actrow[i] == SHRT_MIN)
        actrow[i] = 0;

   return default_rule;
@@ -498,7 +536,7 @@
       save_row (i);
     }

-  output_table_data (&format_obstack, yydefact,
+  output_short_table (&format_obstack, yydefact,
                     yydefact[0], 1, nstates);
   muscle_insert ("defact", obstack_finish (&format_obstack));

@@ -692,7 +730,7 @@
       yydefgoto[i - ntokens] = default_state;
     }

-  output_table_data (&format_obstack, yydefgoto,
+  output_short_table (&format_obstack, yydefgoto,
                     yydefgoto[0], 1, nsyms - ntokens);
   muscle_insert ("defgoto", obstack_finish (&format_obstack));

@@ -769,6 +807,8 @@
   return -1;
 }

+/* FIXME: For the time being, best approximation... */
+#define MAXTABLE SHRT_MAX

 static int
 pack_vector (int vector)
@@ -841,7 +881,7 @@
   high = 0;

   for (i = 0; i < nvectors; i++)
-    base[i] = MINSHORT;
+    base[i] = SHRT_MIN;

   for (i = 0; i < MAXTABLE; i++)
     check[i] = -1;
@@ -877,12 +917,12 @@
 output_base (void)
 {
   /* Output pact. */
-  output_table_data (&format_obstack, base,
+  output_short_table (&format_obstack, base,
                     base[0], 1, nstates);
   muscle_insert ("pact", obstack_finish (&format_obstack));

   /* Output pgoto. */
-  output_table_data (&format_obstack, base,
+  output_short_table (&format_obstack, base,
                     base[nstates], nstates + 1, nvectors);
   muscle_insert ("pgoto", obstack_finish (&format_obstack));

@@ -893,7 +933,7 @@
 static void
 output_table (void)
 {
-  output_table_data (&format_obstack, table,
+  output_short_table (&format_obstack, table,
                     table[0], 1, high + 1);
   muscle_insert ("table", obstack_finish (&format_obstack));
   XFREE (table);
@@ -903,7 +943,7 @@
 static void
 output_check (void)
 {
-  output_table_data (&format_obstack, check,
+  output_short_table (&format_obstack, check,
                     check[0], 1, high + 1);
   muscle_insert ("check", obstack_finish (&format_obstack));
   XFREE (check);
@@ -1033,7 +1073,7 @@
 prepare (void)
 {
   MUSCLE_INSERT_INT ("last", high);
-  MUSCLE_INSERT_INT ("flag", MINSHORT);
+  MUSCLE_INSERT_INT ("flag", SHRT_MIN);
   MUSCLE_INSERT_INT ("pure", pure_parser);
   MUSCLE_INSERT_INT ("nsym", nsyms);
   MUSCLE_INSERT_INT ("debug", debug_flag);
Index: src/print.c
--- src/print.c Sat, 06 Apr 2002 22:33:26 +0200 akim
+++ src/print.c Sun, 07 Apr 2002 20:42:30 +0200 akim
@@ -69,7 +69,7 @@
 print_core (FILE *out, state_t *state)
 {
   int i;
-  short *sitems = state->items;
+  item_number_t *sitems = state->items;
   int snritems   = state->nitems;

   /* New experimental feature: if TRACE_FLAGS output all the items of
@@ -85,8 +85,8 @@
     {
       for (i = 0; i < snritems; i++)
        {
-         short *sp;
-         short *sp1;
+         item_number_t *sp;
+         item_number_t *sp1;
          int rule;

          sp1 = sp = ritem + sitems[i];
@@ -361,7 +361,7 @@
 print_grammar (FILE *out)
 {
   int i, j;
-  short *rule;
+  item_number_t *rule;
   char buffer[90];
   int column = 0;

Index: src/print_graph.c
--- src/print_graph.c Sat, 06 Apr 2002 22:33:26 +0200 akim
+++ src/print_graph.c Sun, 07 Apr 2002 20:42:32 +0200 akim
@@ -50,7 +50,7 @@
 print_core (state_t *state, struct obstack *node_obstack)
 {
   int i;
-  short *sitems = state->items;
+  item_number_t *sitems = state->items;
   int snritems   = state->nitems;

   /* Output all the items of a state, not only its kernel.  */
@@ -64,8 +64,8 @@
   obstack_fgrow1 (node_obstack, "state %2d\n", state->number);
   for (i = 0; i < snritems; i++)
     {
-      short *sp;
-      short *sp1;
+      item_number_t *sp;
+      item_number_t *sp1;
       int rule;

       sp1 = sp = ritem + sitems[i];
Index: src/reader.c
--- src/reader.c Sun, 07 Apr 2002 17:21:28 +0200 akim
+++ src/reader.c Sun, 07 Apr 2002 20:33:28 +0200 akim
@@ -1637,9 +1637,9 @@
   grammar = p;
   startval = axiom;

-  if (nsyms > MAXSHORT)
+  if (nsyms > SHRT_MAX)
     fatal (_("too many symbols (tokens plus nonterminals); maximum %d"),
-          MAXSHORT);
+          SHRT_MAX);

   assert (nsyms == ntokens + nvars);
 }
@@ -1741,11 +1741,7 @@
   int ruleno;
   symbol_list *p;

-  /* We use short to index items.  */
-  if (nritems >= MAXSHORT)
-    fatal (_("too many items (max %d)"), MAXSHORT);
-
-  ritem = XCALLOC (short, nritems + 1);
+  ritem = XCALLOC (item_number_t, nritems + 1);
   rules = XCALLOC (rule_t, nrules) - 1;

   itemno = 0;
Index: src/reduce.c
--- src/reduce.c Sun, 07 Apr 2002 20:08:18 +0200 akim
+++ src/reduce.c Sun, 07 Apr 2002 20:20:21 +0200 akim
@@ -37,9 +37,6 @@
 #include "getargs.h"
 #include "bitset.h"

-typedef short *rule;
-
-
 /* Set of all nonterminals which are not useless.  */
 static bitset N;

@@ -67,7 +64,7 @@
 static bool
 useful_production (int i, bitset N0)
 {
-  rule r;
+  item_number_t *r;
   short n;

   /* A production is useful if all of the nonterminals in its appear
@@ -139,7 +136,7 @@
   bitset Vp, Vs, Pp;
   int i;
   short t;
-  rule r;
+  item_number_t *r;

   /* Find out which productions are reachable and which symbols are
      used.  Starting with an empty set of productions and a set of
@@ -252,7 +249,7 @@
     /* Renumber the rules markers in RITEMS.  */
     for (i = 1; i < nrules + 1; ++i)
       {
-       short *rhsp = rules[i].rhs;
+       item_number_t *rhsp = rules[i].rhs;
        for (/* Nothing. */; *rhsp >= 0; ++rhsp)
          /* Nothing. */;
        *rhsp = -i;
@@ -361,7 +358,7 @@
       fprintf (out, "%s\n\n", _("Useless rules:"));
       for (i = nrules + 1; i < nuseless_productions + nrules + 1; i++)
        {
-         rule r;
+         item_number_t *r;
          fprintf (out, "#%-4d  ", rules[i].user_number - 1);
          fprintf (out, "%s:", quotearg_style (escape_quoting_style,
                                               rules[i].lhs->tag));
@@ -378,7 +375,7 @@
 dump_grammar (FILE *out)
 {
   int i;
-  rule r;
+  item_number_t *r;

   fprintf (out, "REDUCED GRAMMAR\n\n");
   fprintf (out,
Index: src/state.c
--- src/state.c Sat, 26 Jan 2002 17:16:02 +0100 akim
+++ src/state.c Sun, 07 Apr 2002 20:42:50 +0200 akim
@@ -1,5 +1,5 @@
 /* Type definitions for nondeterministic finite state machine for bison,
-   Copyright 2001 Free Software Foundation, Inc.
+   Copyright (C) 2001, 2002  Free Software Foundation, Inc.

    This file is part of Bison, the GNU Compiler Compiler.

@@ -20,6 +20,7 @@


 #include "system.h"
+#include "gram.h"
 #include "state.h"

 /*---------------------------------.
Index: src/state.h
--- src/state.h Sat, 06 Apr 2002 22:33:26 +0200 akim
+++ src/state.h Sun, 07 Apr 2002 20:58:37 +0200 akim
@@ -186,11 +186,11 @@

   /* Its items. */
   short nitems;
-  short items[1];
+  item_number_t items[1];
 } state_t;

 #define STATE_ALLOC(Nitems)                                            \
   (state_t *) xcalloc ((unsigned) (sizeof (state_t)                    \
-                                  + (Nitems - 1) * sizeof (short)), 1)
+                                  + (Nitems - 1) * sizeof (item_number_t)), 1)

 #endif /* !STATE_H_ */
Index: src/system.h
--- src/system.h Sun, 07 Apr 2002 20:04:45 +0200 akim
+++ src/system.h Sun, 07 Apr 2002 20:54:58 +0200 akim
@@ -89,6 +89,9 @@
 # endif
 #endif

+/* FIXME: Autoconfiscate. */
+#include <limits.h>
+
 # include "xalloc.h"

 /* From xstrndup.c.  */
@@ -219,23 +222,6 @@
 } while (0)


-/*---------------------------------.
-| Machine-dependencies for Bison.  |
-`---------------------------------*/
-
-#ifdef eta10
-# define       MAXSHORT        2147483647
-# define       MINSHORT        -2147483648
-#else
-# define       MAXSHORT        32767
-# define       MINSHORT        -32768
-#endif
-
-#if defined (MSDOS) && !defined (__GO32__)
-# define MAXTABLE      16383
-#else
-# define MAXTABLE      32767
-#endif

 /*-----------------------------------------.
 | Extensions to use for the output files.  |
@@ -268,13 +254,6 @@
 #endif


-
-/*----------------------------.
-| As memcpy, but for shorts.  |
-`----------------------------*/
-
-#define shortcpy(Dest, Src, Num) \
-  memcpy (Dest, Src, Num * sizeof (short))

 /*---------------------.
 | Free a linked list.  |
Index: data/bison.simple
--- data/bison.simple Sun, 07 Apr 2002 20:00:35 +0200 akim
+++ data/bison.simple Sun, 07 Apr 2002 20:35:52 +0200 akim
@@ -286,7 +286,8 @@ m4_define([b4_token_defines],
 };

 /* YYRHS -- A `-1'-separated list of the rules' RHS. */
-static const short yyrhs[[]] =
+typedef b4_sint_type(b4_rhs_number_max) yyrhs_t;
+static const yyrhs_t yyrhs[[]] =
 {
   b4_rhs
 };
Index: data/bison.c++
--- data/bison.c++ Sun, 07 Apr 2002 20:00:35 +0200 akim
+++ data/bison.c++ Sun, 07 Apr 2002 21:06:58 +0200 akim
@@ -168,6 +168,7 @@ m4_define([b4_copyright],
   struct Traits< b4_name >
   {
     typedef typedef b4_uint_type(b4_token_number_max) TokenNumberType;
+    typedef typedef b4_sint_type(b4_item_number_max)  RhsNumberType;
     typedef int      StateType;
     typedef yystype  SemanticType;
     typedef b4_ltype LocationType;
@@ -181,8 +182,9 @@ m4_define([b4_copyright],
   public:

     typedef Traits< b4_name >::TokenNumberType TokenNumberType;
+    typedef Traits< b4_name >::RhsNumberType   TokenNumberType;
     typedef Traits< b4_name >::StateType       StateType;
-    typedef Traits< b4_name >::SemanticType     SemanticType;
+    typedef Traits< b4_name >::SemanticType    SemanticType;
     typedef Traits< b4_name >::LocationType    LocationType;

     typedef Stack< StateType >    StateStack;
@@ -684,7 +686,7 @@ yy::b4_name::r2_[[]] =

 #if YYDEBUG
 /* YYRHS -- A `-1'-separated list of the rules' RHS. */
-const short
+const RhsNumberType
 yy::b4_name::rhs_[[]] =
 {
   b4_rhs
Index: tests/regression.at
--- tests/regression.at Sun, 07 Apr 2002 17:21:28 +0200 akim
+++ tests/regression.at Sun, 07 Apr 2002 21:27:02 +0200 akim
@@ -467,7 +467,7 @@ else: "else" statement;
 {
        0,     0,     3,     5,     6,     9,    14
 };
-static const short yyrhs[] =
+static const yyrhs_t yyrhs[] =
 {
        8,     0,    -1,     9,    -1,    -1,    10,    11,    -1,     3,
        4,     5,     8,    -1,     6,     8,    -1
Index: tests/torture.at
--- tests/torture.at Sun, 07 Apr 2002 17:21:28 +0200 akim
+++ tests/torture.at Sun, 07 Apr 2002 21:08:47 +0200 akim
@@ -129,7 +129,9 @@ exp:

 AT_SETUP([Big triangle])

-AT_DATA_TRIANGULAR_GRAMMAR([input.y], [253])
+# I have been able to go up to 2000 on my machine.
+# I tried 3000, a 29Mb grammar file, but then my system killed bison.
+AT_DATA_TRIANGULAR_GRAMMAR([input.y], [500])
 AT_CHECK([bison input.y -v -o input.c])
 AT_CHECK([$CC $CFLAGS $CPPFLAGS input.c -o input], 0, [], [ignore])
 AT_CHECK([./input])



reply via email to

[Prev in Thread] Current Thread [Next in Thread]