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.
This commit is contained in:
Akim Demaille
2008-11-23 08:39:17 +01:00
parent 6ab1adbe1e
commit 68dbdee86a
3 changed files with 28 additions and 32 deletions

View File

@@ -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.

View 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

View 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