mirror of
https://git.savannah.gnu.org/git/bison.git
synced 2026-03-18 00:33:03 +00:00
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:
16
ChangeLog
16
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>
|
2008-11-25 Akim Demaille <demaille@gostai.com>
|
||||||
|
|
||||||
b4_tables_map.
|
b4_tables_map.
|
||||||
|
|||||||
35
data/yacc.c
35
data/yacc.c
@@ -501,19 +501,6 @@ static const ]b4_int_type_for([b4_translate])[ yytranslate[] =
|
|||||||
};
|
};
|
||||||
|
|
||||||
#if YYDEBUG
|
#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. */
|
/* YYRLINE[YYN] -- source line where rule number YYN was defined. */
|
||||||
static const ]b4_int_type_for([b4_rline])[ yyrline[] =
|
static const ]b4_int_type_for([b4_rline])[ yyrline[] =
|
||||||
{
|
{
|
||||||
@@ -748,24 +735,26 @@ do { \
|
|||||||
`------------------------------------------------*/
|
`------------------------------------------------*/
|
||||||
|
|
||||||
]b4_c_function_def([yy_reduce_print], [static void],
|
]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]],
|
b4_locations_if([[[YYLTYPE *yylsp], [yylsp]],
|
||||||
])[[int yyrule], [yyrule]]m4_ifset([b4_parse_param], [,
|
])[[int yyrule], [yyrule]]m4_ifset([b4_parse_param], [,
|
||||||
b4_parse_param]))[
|
b4_parse_param]))[
|
||||||
{
|
{
|
||||||
|
unsigned long int yylno = yyrline[yyrule];
|
||||||
int yynrhs = yyr2[yyrule];
|
int yynrhs = yyr2[yyrule];
|
||||||
int yyi;
|
int yyi;
|
||||||
unsigned long int yylno = yyrline[yyrule];
|
|
||||||
YYFPRINTF (stderr, "Reducing stack by rule %d (line %lu):\n",
|
YYFPRINTF (stderr, "Reducing stack by rule %d (line %lu):\n",
|
||||||
yyrule - 1, yylno);
|
yyrule - 1, yylno);
|
||||||
/* The symbols being reduced. */
|
/* The symbols being reduced. */
|
||||||
for (yyi = 0; yyi < yynrhs; yyi++)
|
for (yyi = 0; yyi < yynrhs; yyi++)
|
||||||
{
|
{
|
||||||
YYFPRINTF (stderr, " $%d = ", yyi + 1);
|
YYFPRINTF (stderr, " $%d = ", yyi + 1);
|
||||||
yy_symbol_print (stderr, yyrhs[yyprhs[yyrule] + yyi],
|
yy_symbol_print (stderr,
|
||||||
&]b4_rhs_value(yynrhs, yyi + 1)[
|
yystos[yyssp[yyi + 1 - yynrhs]],
|
||||||
]b4_locations_if([, &]b4_rhs_location(yynrhs, yyi + 1))[]dnl
|
&]b4_rhs_value(yynrhs, yyi + 1)[
|
||||||
b4_user_args[);
|
]b4_locations_if([, &]b4_rhs_location(yynrhs, yyi + 1))[]dnl
|
||||||
|
b4_user_args[);
|
||||||
YYFPRINTF (stderr, "\n");
|
YYFPRINTF (stderr, "\n");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -773,7 +762,7 @@ do { \
|
|||||||
# define YY_REDUCE_PRINT(Rule) \
|
# define YY_REDUCE_PRINT(Rule) \
|
||||||
do { \
|
do { \
|
||||||
if (yydebug) \
|
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))
|
} while (YYID (0))
|
||||||
|
|
||||||
/* Nonzero means print parse trace. It is left uninitialized so that
|
/* Nonzero means print parse trace. It is left uninitialized so that
|
||||||
|
|||||||
@@ -754,15 +754,6 @@ AT_CHECK([[cat tables.c]], 0,
|
|||||||
2, 2, 2, 2, 2, 2, 1, 2, 3, 4,
|
2, 2, 2, 2, 2, 2, 1, 2, 3, 4,
|
||||||
5, 6
|
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[] =
|
static const yytype_uint8 yyrline[] =
|
||||||
{
|
{
|
||||||
0, 2, 2, 3, 3, 4, 5
|
0, 2, 2, 3, 3, 4, 5
|
||||||
|
|||||||
Reference in New Issue
Block a user