mirror of
https://git.savannah.gnu.org/git/bison.git
synced 2026-03-09 04:13:03 +00:00
Augment the similarity between GLR and LALR traces.
* data/yacc.c (yy_stack_print, YY_STACK_PRINT, yy_reduce_print) (YY_REDUCE_PRINT): New. (yyparse): Use them. * data/glr.c (yy_reduce_print): Use YYFPRINTF, no need for YYDPRINT here. (yyglrReduce, yyrecoverParseError, yyparse): Don't report the state reached after the reduction/recovery, since... (yyparse, yyprocessOneStack): Report the state we are entering in.
This commit is contained in:
13
ChangeLog
13
ChangeLog
@@ -1,3 +1,16 @@
|
||||
2002-11-16 Akim Demaille <akim@epita.fr>
|
||||
|
||||
Augment the similarity between GLR and LALR traces.
|
||||
|
||||
* data/yacc.c (yy_stack_print, YY_STACK_PRINT, yy_reduce_print)
|
||||
(YY_REDUCE_PRINT): New.
|
||||
(yyparse): Use them.
|
||||
* data/glr.c (yy_reduce_print): Use YYFPRINTF, no need for
|
||||
YYDPRINT here.
|
||||
(yyglrReduce, yyrecoverParseError, yyparse): Don't report the
|
||||
state reached after the reduction/recovery, since...
|
||||
(yyparse, yyprocessOneStack): Report the state we are entering in.
|
||||
|
||||
2002-11-16 Akim Demaille <akim@epita.fr>
|
||||
|
||||
* src/getargs.h, src/getargs.c (trace_e, trace_args, trace_types):
|
||||
|
||||
13
data/glr.c
13
data/glr.c
@@ -1106,8 +1106,8 @@ static inline void
|
||||
yy_reduce_print (size_t yyk, yyRuleNum yyrule)
|
||||
{
|
||||
int yyi;
|
||||
YYDPRINTF ((stderr, "Reducing stack %d by rule %d (line %d), ",
|
||||
yyk, yyrule - 1, yyrline[yyrule]));
|
||||
YYFPRINTF (stderr, "Reducing stack %d by rule %d (line %d), ",
|
||||
yyk, yyrule - 1, yyrline[yyrule]);
|
||||
/* Print the symbols being reduced, and their result. */
|
||||
for (yyi = yyprhs[yyrule]; 0 <= yyrhs[yyi]; yyi++)
|
||||
YYFPRINTF (stderr, "%s ", yytokenName (yyrhs[yyi]));
|
||||
@@ -1143,8 +1143,6 @@ yyglrReduce (yyGLRStack* yystack, size_t yyk, yyRuleNum yyrule,
|
||||
yyLRgotoState (yystack->yytops.yystates[yyk]->yylrState,
|
||||
yylhsNonterm (yyrule)),
|
||||
yyposn, yysval, &yyloc]b4_user_args[);
|
||||
YYDPRINTF ((stderr, "Stack %d entering state %d\n",
|
||||
yyk, yystack->yytops.yystates[yyk]->yylrState));
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -1512,6 +1510,7 @@ yyprocessOneStack (yyGLRStack* yystack, int yyk,
|
||||
while (yystack->yytops.yystates[yyk] != NULL)
|
||||
{
|
||||
yyStateNum yystate = yystack->yytops.yystates[yyk]->yylrState;
|
||||
YYDPRINTF ((stderr, "Stack %d Entering state %d\n", yyk, yystate));
|
||||
|
||||
assert (yystate != YYFINAL);
|
||||
if (yyisDefaultedState (yystate))
|
||||
@@ -1711,8 +1710,6 @@ yyrecoverParseError (yyGLRStack* yystack,
|
||||
YYDPRINTF ((stderr, "Shifting error token, "));
|
||||
yyglrShift (yystack, 0, yytable[yyj],
|
||||
yys->yyposn, *yylvalp, yyllocp]b4_user_args[);
|
||||
YYDPRINTF ((stderr, "Entering state %d\n",
|
||||
yystack->yytops.yystates[0]->yylrState));
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -1783,7 +1780,6 @@ yyrecoverParseError (yyGLRStack* yystack,
|
||||
/* For efficiency, we have two loops, the first of which is
|
||||
specialized to deterministic operation (single stack, no
|
||||
potential ambiguity). */
|
||||
|
||||
/* Standard mode */
|
||||
while (yytrue)
|
||||
{
|
||||
@@ -1792,6 +1788,7 @@ yyrecoverParseError (yyGLRStack* yystack,
|
||||
const short* yyconflicts;
|
||||
|
||||
yyStateNum yystate = yystack.yytops.yystates[0]->yylrState;
|
||||
YYDPRINTF ((stderr, "Entering state %d\n", yystate));
|
||||
if (yystate == YYFINAL)
|
||||
goto yyDone;
|
||||
if (yyisDefaultedState (yystate))
|
||||
@@ -1827,8 +1824,6 @@ yyrecoverParseError (yyGLRStack* yystack,
|
||||
yylval, yyllocp]b4_user_args[);
|
||||
if (0 < yystack.yyerrState)
|
||||
yystack.yyerrState -= 1;
|
||||
YYDPRINTF ((stderr, "Entering state %d\n",
|
||||
yystack.yytops.yystates[0]->yylrState));
|
||||
}
|
||||
else if (yyisErrorAction (yyaction))
|
||||
{
|
||||
|
||||
88
data/yacc.c
88
data/yacc.c
@@ -547,6 +547,50 @@ do { \
|
||||
} \
|
||||
} while (0)
|
||||
|
||||
/*------------------------------------------------------------------.
|
||||
| yy_stack_print -- Print the state stack from its BOTTOM up to its |
|
||||
| TOP (cinluded). |
|
||||
`------------------------------------------------------------------*/
|
||||
|
||||
]b4_c_function_def([yy_stack_print], [static void],
|
||||
[[short *bottom], [bottom]],
|
||||
[[short *top], [top]])[
|
||||
{
|
||||
YYFPRINTF (stderr, "Stack now");
|
||||
for (/* Nothing. */; bottom <= top; ++bottom)
|
||||
YYFPRINTF (stderr, " %d", *bottom);
|
||||
YYFPRINTF (stderr, "\n");
|
||||
}
|
||||
|
||||
# define YY_STACK_PRINT(Bottom, Top) \
|
||||
do { \
|
||||
if (yydebug) \
|
||||
yy_stack_print ((Bottom), (Top)); \
|
||||
} while (0)
|
||||
|
||||
|
||||
/*------------------------------------------------.
|
||||
| Report that the YYRULE is going to be reduced. |
|
||||
`------------------------------------------------*/
|
||||
|
||||
]b4_c_function_def([yy_reduce_print], [static void],
|
||||
[[int yyrule], [yyrule]])[
|
||||
{
|
||||
int yyi;
|
||||
YYFPRINTF (stderr, "Reducing stack by rule %d (line %d), ",
|
||||
yyrule - 1, yyrline[yyrule]);
|
||||
/* Print the symbols being reduced, and their result. */
|
||||
for (yyi = yyprhs[yyrule]; 0 <= yyrhs[yyi]; yyi++)
|
||||
YYFPRINTF (stderr, "%s ", yytname [yyrhs[yyi]]);
|
||||
YYFPRINTF (stderr, "-> %s\n", yytname [yyr1[yyrule]]);
|
||||
}
|
||||
|
||||
# define YY_REDUCE_PRINT(Rule) \
|
||||
do { \
|
||||
if (yydebug) \
|
||||
yy_reduce_print (Rule); \
|
||||
} while (0)
|
||||
|
||||
/* Nonzero means print parse trace. It is left uninitialized so that
|
||||
multiple parsers can coexist. */
|
||||
int yydebug;
|
||||
@@ -554,8 +598,11 @@ int yydebug;
|
||||
# define YYDPRINTF(Args)
|
||||
# define YYDSYMPRINT(Args)
|
||||
# define YYDSYMPRINTF(Title, Token, Value, Location)
|
||||
# define YY_STACK_PRINT(Bottom, Top)
|
||||
# define YY_REDUCE_PRINT(Rule)
|
||||
#endif /* !YYDEBUG */
|
||||
|
||||
|
||||
/* YYINITDEPTH -- initial size of the parser's stacks. */
|
||||
#ifndef YYINITDEPTH
|
||||
# define YYINITDEPTH ]b4_stack_depth_init[
|
||||
@@ -936,23 +983,7 @@ yyreduce:
|
||||
]b4_location_if(
|
||||
[ /* Default location. */
|
||||
YYLLOC_DEFAULT (yyloc, (yylsp - yylen), yylen);])[
|
||||
|
||||
#if YYDEBUG
|
||||
/* We have to keep this `#if YYDEBUG', since we use variables which
|
||||
are defined only if `YYDEBUG' is set. */
|
||||
if (yydebug)
|
||||
{
|
||||
int yyi;
|
||||
|
||||
YYFPRINTF (stderr, "Reducing by rule %d (line %d), ",
|
||||
yyn - 1, yyrline[yyn]);
|
||||
|
||||
/* Print the symbols being reduced, and their result. */
|
||||
for (yyi = yyprhs[yyn]; 0 <= yyrhs[yyi]; yyi++)
|
||||
YYFPRINTF (stderr, "%s ", yytname[yyrhs[yyi]]);
|
||||
YYFPRINTF (stderr, "-> %s\n", yytname[yyr1[yyn]]);
|
||||
}
|
||||
#endif
|
||||
YY_REDUCE_PRINT (yyn);
|
||||
switch (yyn)
|
||||
]{
|
||||
b4_actions
|
||||
@@ -965,16 +996,7 @@ b4_syncline([@oline@], [@ofile@])
|
||||
yyssp -= yylen;
|
||||
]b4_location_if([ yylsp -= yylen;])[
|
||||
|
||||
#if YYDEBUG
|
||||
if (yydebug)
|
||||
{
|
||||
short *yyssp1 = yyss - 1;
|
||||
YYFPRINTF (stderr, "state stack now");
|
||||
while (yyssp1 != yyssp)
|
||||
YYFPRINTF (stderr, " %d", *++yyssp1);
|
||||
YYFPRINTF (stderr, "\n");
|
||||
}
|
||||
#endif
|
||||
YY_STACK_PRINT (yyss, yyssp);
|
||||
|
||||
*++yyvsp = yyval;
|
||||
]b4_location_if([ *++yylsp = yyloc;])[
|
||||
@@ -1111,17 +1133,7 @@ yyerrlab1:
|
||||
yyvsp--;
|
||||
yystate = *--yyssp;
|
||||
]b4_location_if([ yylsp--;])[
|
||||
|
||||
#if YYDEBUG
|
||||
if (yydebug)
|
||||
{
|
||||
short *yyssp1 = yyss - 1;
|
||||
YYFPRINTF (stderr, "Error: state stack now");
|
||||
while (yyssp1 != yyssp)
|
||||
YYFPRINTF (stderr, " %d", *++yyssp1);
|
||||
YYFPRINTF (stderr, "\n");
|
||||
}
|
||||
#endif
|
||||
YY_STACK_PRINT (yyss, yyssp);
|
||||
}
|
||||
|
||||
if (yyn == YYFINAL)
|
||||
|
||||
Reference in New Issue
Block a user