]> git.saurik.com Git - bison.git/commitdiff
Get rid of yyrhs and yyprhs in yacc.c.
authorAkim Demaille <demaille@gostai.com>
Sun, 23 Nov 2008 07:39:17 +0000 (08:39 +0100)
committerAkim Demaille <demaille@gostai.com>
Tue, 25 Nov 2008 21:21:24 +0000 (22:21 +0100)
They were used to get the symbol types, given a rule number,  when
displaying the top of the stack before a reduction.  But the symbol type
is available from the state stack.  This has two be benefits: two tables
less in the parser (making it smaller), and a more consistent use of the
three stacks which will help to fuse them.

* data/yacc.c (yyprhs, yyrhs): Remove.
(YY_REDUCE_PRINT): Pass yyssp to yy_reduce_print.
(yy_reduce_print): Take yyssp as argument.
Use it, together with yystos, to get the symbol type.
* tests/regression.at (Web2c Report): Remove these tables from the
expected output.

ChangeLog
data/yacc.c
tests/regression.at

index c6a85e05c3da75590184b7d187bb7db47963c0dc..725b2912379edd8b9016555b8b25899d0849a20d 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,19 @@
+2008-11-25  Akim Demaille  <demaille@gostai.com>
+
+       Get rid of yyrhs and yyprhs in yacc.c.
+       They were used to get the symbol types, given a rule number,  when
+       displaying the top of the stack before a reduction.  But the symbol type
+       is available from the state stack.  This has two be benefits: two tables
+       less in the parser (making it smaller), and a more consistent use of the
+       three stacks which will help to fuse them.
+       
+       * data/yacc.c (yyprhs, yyrhs): Remove.
+       (YY_REDUCE_PRINT): Pass yyssp to yy_reduce_print.
+       (yy_reduce_print): Take yyssp as argument.
+       Use it, together with yystos, to get the symbol type.
+       * tests/regression.at (Web2c Report): Remove these tables from the
+       expected output.
+
 2008-11-25  Akim Demaille  <demaille@gostai.com>
 
        b4_tables_map.
index 872e63f1c20737bcecaa26722c1d9c274e46dac8..faec957e33741520dccb2cec9f66dfcf9fcfd646 100644 (file)
@@ -501,19 +501,6 @@ static const ]b4_int_type_for([b4_translate])[ yytranslate[] =
 };
 
 #if YYDEBUG
-/* YYPRHS[YYN] -- Index of the first RHS symbol of rule number YYN in
-   YYRHS.  */
-static const ]b4_int_type_for([b4_prhs])[ yyprhs[] =
-{
-  ]b4_prhs[
-};
-
-/* YYRHS -- A `-1'-separated list of the rules' RHS.  */
-static const ]b4_int_type_for([b4_rhs])[ yyrhs[] =
-{
-  ]b4_rhs[
-};
-
 /* YYRLINE[YYN] -- source line where rule number YYN was defined.  */
 static const ]b4_int_type_for([b4_rline])[ yyrline[] =
 {
@@ -748,24 +735,26 @@ do {                                                              \
 `------------------------------------------------*/
 
 ]b4_c_function_def([yy_reduce_print], [static void],
-                  [[YYSTYPE *yyvsp], [yyvsp]],
+                   [[yytype_int16 *yyssp], [yyssp]],
+                   [[YYSTYPE *yyvsp], [yyvsp]],
     b4_locations_if([[[YYLTYPE *yylsp], [yylsp]],
-                  ])[[int yyrule], [yyrule]]m4_ifset([b4_parse_param], [,
-                  b4_parse_param]))[
+                   ])[[int yyrule], [yyrule]]m4_ifset([b4_parse_param], [,
+                   b4_parse_param]))[
 {
+  unsigned long int yylno = yyrline[yyrule];
   int yynrhs = yyr2[yyrule];
   int yyi;
-  unsigned long int yylno = yyrline[yyrule];
   YYFPRINTF (stderr, "Reducing stack by rule %d (line %lu):\n",
-            yyrule - 1, yylno);
+             yyrule - 1, yylno);
   /* The symbols being reduced.  */
   for (yyi = 0; yyi < yynrhs; yyi++)
     {
       YYFPRINTF (stderr, "   $%d = ", yyi + 1);
-      yy_symbol_print (stderr, yyrhs[yyprhs[yyrule] + yyi],
-                      &]b4_rhs_value(yynrhs, yyi + 1)[
-                      ]b4_locations_if([, &]b4_rhs_location(yynrhs, yyi + 1))[]dnl
-                      b4_user_args[);
+      yy_symbol_print (stderr,
+                       yystos[yyssp[yyi + 1 - yynrhs]],
+                       &]b4_rhs_value(yynrhs, yyi + 1)[
+                       ]b4_locations_if([, &]b4_rhs_location(yynrhs, yyi + 1))[]dnl
+                       b4_user_args[);
       YYFPRINTF (stderr, "\n");
     }
 }
@@ -773,7 +762,7 @@ do {                                                                \
 # define YY_REDUCE_PRINT(Rule)         \
 do {                                   \
   if (yydebug)                         \
-    yy_reduce_print (yyvsp, ]b4_locations_if([yylsp, ])[Rule]b4_user_args[); \
+    yy_reduce_print (yyssp, yyvsp, ]b4_locations_if([yylsp, ])[Rule]b4_user_args[); \
 } while (YYID (0))
 
 /* Nonzero means print parse trace.  It is left uninitialized so that
index 1845524238186751918918a6b02aa20052d7e8c1..01bbb7a3a9ea033f300bfab3acf9ff0124a50690 100644 (file)
@@ -754,15 +754,6 @@ AT_CHECK([[cat tables.c]], 0,
        2,     2,     2,     2,     2,     2,     1,     2,     3,     4,
        5,     6
 };
-static const yytype_uint8 yyprhs[] =
-{
-       0,     0,     3,     5,     6,     9,    14
-};
-static const yytype_int8 yyrhs[] =
-{
-       8,     0,    -1,     9,    -1,    -1,    10,    11,    -1,     3,
-       4,     5,     8,    -1,     6,     8,    -1
-};
 static const yytype_uint8 yyrline[] =
 {
        0,     2,     2,     3,     3,     4,     5