mirror of
https://git.savannah.gnu.org/git/bison.git
synced 2026-03-09 12:23:04 +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>
|
2002-11-16 Akim Demaille <akim@epita.fr>
|
||||||
|
|
||||||
* src/getargs.h, src/getargs.c (trace_e, trace_args, trace_types):
|
* 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)
|
yy_reduce_print (size_t yyk, yyRuleNum yyrule)
|
||||||
{
|
{
|
||||||
int yyi;
|
int yyi;
|
||||||
YYDPRINTF ((stderr, "Reducing stack %d by rule %d (line %d), ",
|
YYFPRINTF (stderr, "Reducing stack %d by rule %d (line %d), ",
|
||||||
yyk, yyrule - 1, yyrline[yyrule]));
|
yyk, yyrule - 1, yyrline[yyrule]);
|
||||||
/* Print the symbols being reduced, and their result. */
|
/* Print the symbols being reduced, and their result. */
|
||||||
for (yyi = yyprhs[yyrule]; 0 <= yyrhs[yyi]; yyi++)
|
for (yyi = yyprhs[yyrule]; 0 <= yyrhs[yyi]; yyi++)
|
||||||
YYFPRINTF (stderr, "%s ", yytokenName (yyrhs[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,
|
yyLRgotoState (yystack->yytops.yystates[yyk]->yylrState,
|
||||||
yylhsNonterm (yyrule)),
|
yylhsNonterm (yyrule)),
|
||||||
yyposn, yysval, &yyloc]b4_user_args[);
|
yyposn, yysval, &yyloc]b4_user_args[);
|
||||||
YYDPRINTF ((stderr, "Stack %d entering state %d\n",
|
|
||||||
yyk, yystack->yytops.yystates[yyk]->yylrState));
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -1512,6 +1510,7 @@ yyprocessOneStack (yyGLRStack* yystack, int yyk,
|
|||||||
while (yystack->yytops.yystates[yyk] != NULL)
|
while (yystack->yytops.yystates[yyk] != NULL)
|
||||||
{
|
{
|
||||||
yyStateNum yystate = yystack->yytops.yystates[yyk]->yylrState;
|
yyStateNum yystate = yystack->yytops.yystates[yyk]->yylrState;
|
||||||
|
YYDPRINTF ((stderr, "Stack %d Entering state %d\n", yyk, yystate));
|
||||||
|
|
||||||
assert (yystate != YYFINAL);
|
assert (yystate != YYFINAL);
|
||||||
if (yyisDefaultedState (yystate))
|
if (yyisDefaultedState (yystate))
|
||||||
@@ -1711,8 +1710,6 @@ yyrecoverParseError (yyGLRStack* yystack,
|
|||||||
YYDPRINTF ((stderr, "Shifting error token, "));
|
YYDPRINTF ((stderr, "Shifting error token, "));
|
||||||
yyglrShift (yystack, 0, yytable[yyj],
|
yyglrShift (yystack, 0, yytable[yyj],
|
||||||
yys->yyposn, *yylvalp, yyllocp]b4_user_args[);
|
yys->yyposn, *yylvalp, yyllocp]b4_user_args[);
|
||||||
YYDPRINTF ((stderr, "Entering state %d\n",
|
|
||||||
yystack->yytops.yystates[0]->yylrState));
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1783,7 +1780,6 @@ yyrecoverParseError (yyGLRStack* yystack,
|
|||||||
/* For efficiency, we have two loops, the first of which is
|
/* For efficiency, we have two loops, the first of which is
|
||||||
specialized to deterministic operation (single stack, no
|
specialized to deterministic operation (single stack, no
|
||||||
potential ambiguity). */
|
potential ambiguity). */
|
||||||
|
|
||||||
/* Standard mode */
|
/* Standard mode */
|
||||||
while (yytrue)
|
while (yytrue)
|
||||||
{
|
{
|
||||||
@@ -1792,6 +1788,7 @@ yyrecoverParseError (yyGLRStack* yystack,
|
|||||||
const short* yyconflicts;
|
const short* yyconflicts;
|
||||||
|
|
||||||
yyStateNum yystate = yystack.yytops.yystates[0]->yylrState;
|
yyStateNum yystate = yystack.yytops.yystates[0]->yylrState;
|
||||||
|
YYDPRINTF ((stderr, "Entering state %d\n", yystate));
|
||||||
if (yystate == YYFINAL)
|
if (yystate == YYFINAL)
|
||||||
goto yyDone;
|
goto yyDone;
|
||||||
if (yyisDefaultedState (yystate))
|
if (yyisDefaultedState (yystate))
|
||||||
@@ -1827,8 +1824,6 @@ yyrecoverParseError (yyGLRStack* yystack,
|
|||||||
yylval, yyllocp]b4_user_args[);
|
yylval, yyllocp]b4_user_args[);
|
||||||
if (0 < yystack.yyerrState)
|
if (0 < yystack.yyerrState)
|
||||||
yystack.yyerrState -= 1;
|
yystack.yyerrState -= 1;
|
||||||
YYDPRINTF ((stderr, "Entering state %d\n",
|
|
||||||
yystack.yytops.yystates[0]->yylrState));
|
|
||||||
}
|
}
|
||||||
else if (yyisErrorAction (yyaction))
|
else if (yyisErrorAction (yyaction))
|
||||||
{
|
{
|
||||||
|
|||||||
88
data/yacc.c
88
data/yacc.c
@@ -547,6 +547,50 @@ do { \
|
|||||||
} \
|
} \
|
||||||
} while (0)
|
} 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
|
/* Nonzero means print parse trace. It is left uninitialized so that
|
||||||
multiple parsers can coexist. */
|
multiple parsers can coexist. */
|
||||||
int yydebug;
|
int yydebug;
|
||||||
@@ -554,8 +598,11 @@ int yydebug;
|
|||||||
# define YYDPRINTF(Args)
|
# define YYDPRINTF(Args)
|
||||||
# define YYDSYMPRINT(Args)
|
# define YYDSYMPRINT(Args)
|
||||||
# define YYDSYMPRINTF(Title, Token, Value, Location)
|
# define YYDSYMPRINTF(Title, Token, Value, Location)
|
||||||
|
# define YY_STACK_PRINT(Bottom, Top)
|
||||||
|
# define YY_REDUCE_PRINT(Rule)
|
||||||
#endif /* !YYDEBUG */
|
#endif /* !YYDEBUG */
|
||||||
|
|
||||||
|
|
||||||
/* YYINITDEPTH -- initial size of the parser's stacks. */
|
/* YYINITDEPTH -- initial size of the parser's stacks. */
|
||||||
#ifndef YYINITDEPTH
|
#ifndef YYINITDEPTH
|
||||||
# define YYINITDEPTH ]b4_stack_depth_init[
|
# define YYINITDEPTH ]b4_stack_depth_init[
|
||||||
@@ -936,23 +983,7 @@ yyreduce:
|
|||||||
]b4_location_if(
|
]b4_location_if(
|
||||||
[ /* Default location. */
|
[ /* Default location. */
|
||||||
YYLLOC_DEFAULT (yyloc, (yylsp - yylen), yylen);])[
|
YYLLOC_DEFAULT (yyloc, (yylsp - yylen), yylen);])[
|
||||||
|
YY_REDUCE_PRINT (yyn);
|
||||||
#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
|
|
||||||
switch (yyn)
|
switch (yyn)
|
||||||
]{
|
]{
|
||||||
b4_actions
|
b4_actions
|
||||||
@@ -965,16 +996,7 @@ b4_syncline([@oline@], [@ofile@])
|
|||||||
yyssp -= yylen;
|
yyssp -= yylen;
|
||||||
]b4_location_if([ yylsp -= yylen;])[
|
]b4_location_if([ yylsp -= yylen;])[
|
||||||
|
|
||||||
#if YYDEBUG
|
YY_STACK_PRINT (yyss, yyssp);
|
||||||
if (yydebug)
|
|
||||||
{
|
|
||||||
short *yyssp1 = yyss - 1;
|
|
||||||
YYFPRINTF (stderr, "state stack now");
|
|
||||||
while (yyssp1 != yyssp)
|
|
||||||
YYFPRINTF (stderr, " %d", *++yyssp1);
|
|
||||||
YYFPRINTF (stderr, "\n");
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
*++yyvsp = yyval;
|
*++yyvsp = yyval;
|
||||||
]b4_location_if([ *++yylsp = yyloc;])[
|
]b4_location_if([ *++yylsp = yyloc;])[
|
||||||
@@ -1111,17 +1133,7 @@ yyerrlab1:
|
|||||||
yyvsp--;
|
yyvsp--;
|
||||||
yystate = *--yyssp;
|
yystate = *--yyssp;
|
||||||
]b4_location_if([ yylsp--;])[
|
]b4_location_if([ yylsp--;])[
|
||||||
|
YY_STACK_PRINT (yyss, yyssp);
|
||||||
#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
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (yyn == YYFINAL)
|
if (yyn == YYFINAL)
|
||||||
|
|||||||
Reference in New Issue
Block a user