bison-patches
[Top][All Lists]
Advanced

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

02-more-dynamic-types.patch


From: Akim Demaille
Subject: 02-more-dynamic-types.patch
Date: Sun, 05 May 2002 13:52:32 +0200

Index: ChangeLog
from  Akim Demaille  <address@hidden>
        * src/output.c (output_unsigned_int_table): New.
        (prepare_rules): `i' is unsigned.
        `prhs', `rline', `r2' are unsigned int.
        Rename muscle `rhs_number_max' as `rhs_max'.
        Output muscles `prhs_max', `rline_max', and `r2_max'.
        Free rline and r1.
        * data/bison.simple, data/bison.c++: Adjust to use these muscles
        to compute types instead of constant types.
        * tests/regression.at (Web2c Actions): Adjust.
        
        
Index: src/output.c
--- src/output.c Sat, 04 May 2002 10:44:42 +0200 akim
+++ src/output.c Sat, 04 May 2002 21:55:50 +0200 akim
@@ -208,6 +208,7 @@
 }
 
 GENERATE_OUTPUT_TABLE(output_int_table, int)
+GENERATE_OUTPUT_TABLE(output_unsigned_int_table, unsigned int)
 GENERATE_OUTPUT_TABLE(output_short_table, short)
 GENERATE_OUTPUT_TABLE(output_token_number_table, token_number_t)
 GENERATE_OUTPUT_TABLE(output_item_number_table, item_number_t)
@@ -284,17 +285,17 @@
 prepare_rules (void)
 {
   long int max;
-  item_number_t *rhsp;
   int r;
-  int i = 0;
+  unsigned int i = 0;
   item_number_t *rhs = XMALLOC (item_number_t, nritems);
-  short *prhs = XMALLOC (short, nrules + 1);
+  unsigned int *prhs = XMALLOC (unsigned int, nrules + 1);
+  unsigned int *rline = XMALLOC (unsigned int, nrules + 1);
   token_number_t *r1 = XMALLOC (token_number_t, nrules + 1);
-  short *r2 = XMALLOC (short, nrules + 1);
-  short *rline = XMALLOC (short, nrules + 1);
+  unsigned int *r2 = XMALLOC (unsigned int, nrules + 1);
 
   for (r = 1; r < nrules + 1; ++r)
     {
+      item_number_t *rhsp;
       /* Index of rule R in RHS. */
       prhs[r] = i;
       /* RHS of the rule R. */
@@ -311,24 +312,29 @@
     }
   assert (i == nritems);
 
-  max = output_int_table (&format_obstack, rhs, ritem[0], 1, nritems);
+  max = output_item_number_table (&format_obstack, rhs, ritem[0], 1, nritems);
   muscle_insert ("rhs", obstack_finish (&format_obstack));
-  MUSCLE_INSERT_LONG_INT ("rhs_number_max", max);
+  MUSCLE_INSERT_LONG_INT ("rhs_max", max);
 
-  output_short_table (&format_obstack, prhs, 0, 1, nrules + 1);
+  max = output_unsigned_int_table (&format_obstack, prhs, 0, 1, nrules + 1);
   muscle_insert ("prhs", obstack_finish (&format_obstack));
+  MUSCLE_INSERT_LONG_INT ("prhs_max", max);
 
-  output_short_table (&format_obstack, rline, 0, 1, nrules + 1);
+  max = output_unsigned_int_table (&format_obstack, rline, 0, 1, nrules + 1);
   muscle_insert ("rline", obstack_finish (&format_obstack));
+  MUSCLE_INSERT_LONG_INT ("rline_max", max);
 
   output_token_number_table (&format_obstack, r1, 0, 1, nrules + 1);
   muscle_insert ("r1", obstack_finish (&format_obstack));
 
-  output_short_table (&format_obstack, r2, 0, 1, nrules + 1);
+  max = output_unsigned_int_table (&format_obstack, r2, 0, 1, nrules + 1);
   muscle_insert ("r2", obstack_finish (&format_obstack));
+  MUSCLE_INSERT_LONG_INT ("r2_max", max);
 
   free (rhs);
   free (prhs);
+  free (rline);
+  free (r1);
   free (r2);
 }
 
Index: data/bison.simple
--- data/bison.simple Fri, 03 May 2002 23:39:21 +0200 akim
+++ data/bison.simple Sat, 04 May 2002 21:55:50 +0200 akim
@@ -347,20 +347,19 @@ m4_define([b4_token_defines],
 #if YYDEBUG
 /* YYPRHS[[YYN]] -- Index of the first RHS symbol of rule number YYN in
    YYRHS.  */
-static const short yyprhs[[]] =
+static const b4_uint_type(b4_prhs_max) yyprhs[[]] =
 {
   b4_prhs
 };
 
 /* YYRHS -- A `-1'-separated list of the rules' RHS. */
-typedef b4_sint_type(b4_rhs_number_max) yyrhs_t;
-static const yyrhs_t yyrhs[[]] =
+static const b4_sint_type(b4_rhs_max) yyrhs[[]] =
 {
   b4_rhs
 };
 
 /* YYRLINE[[YYN]] -- source line where rule number YYN was defined.  */
-static const short yyrline[[]] =
+static const b4_uint_type(b4_rline_max) yyrline[[]] =
 {
   b4_rline
 };
@@ -388,7 +387,7 @@ m4_define([b4_token_defines],
 };
 
 /* YYR2[[YYN]] -- Number of symbols composing right hand side of rule YYN.  */
-static const short yyr2[[]] =
+static const b4_uint_type(b4_r2_max) yyr2[[]] =
 {
   b4_r2
 };
Index: data/bison.c++
--- data/bison.c++ Fri, 03 May 2002 07:58:20 +0200 akim
+++ data/bison.c++ Sat, 04 May 2002 21:55:50 +0200 akim
@@ -203,7 +203,7 @@ m4_define([b4_copyright],
   struct Traits< b4_name >
   {
     typedef b4_uint_type(b4_token_number_max) TokenNumberType;
-    typedef b4_sint_type(b4_rhs_number_max)   RhsNumberType;
+    typedef b4_sint_type(b4_rhs_max)          RhsNumberType;
     typedef int      StateType;
     typedef yystype  SemanticType;
     typedef b4_ltype LocationType;
@@ -263,7 +263,7 @@ m4_define([b4_copyright],
     static const short table_[[]];
     static const short check_[[]];
     static const TokenNumberType r1_[[]];
-    static const short r2_[[]];
+    static const b4_uint_type(b4_r2_max) r2_[[]];
 
 #if YYDEBUG || YYERROR_VERBOSE
     static const char* const name_[[]];
@@ -272,8 +272,8 @@ m4_define([b4_copyright],
     /* More tables, for debugging.  */
 #if YYDEBUG
     static const RhsNumberType rhs_[[]];
-    static const short prhs_[[]];
-    static const short rline_[[]];
+    static const b4_uint_type(b4_prhs_max) prhs_[[]];
+    static const b4_uint_type(b4_rline_max) rline_[[]];
 #endif
 
     /* Even more tables.  */
@@ -466,7 +466,7 @@ yy::b4_name::parse ()
   if (debug_)
     {
       YYFPRINTF (stderr, "Reducing via rule %d (line %d), ", n_ - 1, 
rline_[[n_]]);
-      for (unsigned i = prhs_[[n_]];
+      for (b4_uint_type(b4_prhs_max) i = prhs_[[n_]];
           rhs_[[i]] >= 0; ++i)
        YYFPRINTF (stderr, "%s ", name_[[rhs_[i]]]);
       YYFPRINTF (stderr, "-> %s\n", name_[[r1_[n_]]]);
@@ -696,7 +696,7 @@ yy::b4_name::r1_[[]] =
 };
 
 /* YYR2[[YYN]] -- Number of symbols composing right hand side of rule YYN.  */
-const short
+const b4_uint_type(b4_r2_max)
 yy::b4_name::r2_[[]] =
 {
   b4_r2
@@ -722,14 +722,14 @@ yy::b4_name::rhs_[[]] =
 
 /* YYPRHS[[YYN]] -- Index of the first RHS symbol of rule number YYN in
    YYRHS.  */
-const short
+const b4_uint_type(b4_prhs_max)
 yy::b4_name::prhs_[[]] =
 {
   b4_prhs
 };
 
 /* YYRLINE[[YYN]] -- source line where rule number YYN was defined.  */
-const short
+const b4_uint_type(b4_rline_max)
 yy::b4_name::rline_[[]] =
 {
   b4_rline
Index: tests/regression.at
--- tests/regression.at Sat, 04 May 2002 10:44:42 +0200 akim
+++ tests/regression.at Sat, 04 May 2002 21:56:27 +0200 akim
@@ -489,16 +489,16 @@ else: "else" statement;
        2,     2,     2,     2,     2,     2,     1,     2,     3,     4,
        5,     6
 };
-static const short yyprhs[] =
+static const unsigned char yyprhs[] =
 {
        0,     0,     3,     5,     6,     9,    14
 };
-static const yyrhs_t yyrhs[] =
+static const signed char yyrhs[] =
 {
        8,     0,    -1,     9,    -1,    -1,    10,    11,    -1,     3,
        4,     5,     8,    -1,     6,     8,    -1
 };
-static const short yyrline[] =
+static const unsigned char yyrline[] =
 {
        0,     2,     2,     3,     3,     4,     5
 };
@@ -515,7 +515,7 @@ else: "else" statement;
 {
        0,     7,     8,     9,     9,    10,    11
 };
-static const short yyr2[] =
+static const unsigned char yyr2[] =
 {
        0,     2,     1,     0,     2,     4,     2
 };



reply via email to

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