Have more complete shift traces.

* data/yacc.c, data/lalr1.c, data/glr.c: Use YY_SYMBOL_PRINT
to report Shifts instead of ad hoc YYDPRINTF invocations,
including for the error token.
* data/lalr1.cc (symprint_): Output the location.
* tests/actions.at (_AT_CHECK_PRINTER_AND_DESTRUCTOR): In C++, don't
output the location within the %printer.
Activate GLR tests, at least to make sure they compile properly.
They still don't pass though.
* tests/calc.at: Adjust expect verbose output, since now "Entering
state..." is on a different line than the "Shifting" message.
This commit is contained in:
Akim Demaille
2004-09-16 14:14:27 +00:00
parent 9c66f418c4
commit 1576d44dce
6 changed files with 44 additions and 32 deletions

View File

@@ -1578,11 +1578,11 @@ yyprocessOneStack (yyGLRStack* yystack, int yyk,
if (yyisShiftAction (yyaction))
{
YYDPRINTF ((stderr, "Shifting token %s on stack %d, ",
yytokenName (*yytokenp), yyk));
YYDPRINTF ((stderr, "On stack %d, ", yyk));
YY_SYMBOL_PRINT ("shifting", yytokenp, yylvalp, yyllocp);
yyglrShift (yystack, yyk, yyaction, yyposn+1,
*yylvalp, yyllocp]b4_user_args[);
YYDPRINTF ((stderr, "which is now in state #%d\n",
YYDPRINTF ((stderr, ", now in state #%d\n",
yystack->yytops.yystates[yyk]->yylrState));
break;
}
@@ -1750,7 +1750,8 @@ yyrecoverSyntaxError (yyGLRStack* yystack,
if (0 <= yyj && yyj <= YYLAST && yycheck[yyj] == YYTERROR
&& yyisShiftAction (yytable[yyj]))
{
YYDPRINTF ((stderr, "Shifting error token, "));
YY_SYMBOL_PRINT ("Shifting", yystos[yytable[yyj]],
yylvalp, yyllocp);
yyglrShift (yystack, 0, yytable[yyj],
yys->yyposn, *yylvalp, yyllocp]b4_user_args[);
break;
@@ -1856,8 +1857,7 @@ yyrecoverSyntaxError (yyGLRStack* yystack,
break;
if (yyisShiftAction (yyaction))
{
YYDPRINTF ((stderr, "Shifting token %s, ",
yytokenName (yytoken)));
YY_SYMBOL_PRINT ("Shifting", yytoken, yylvalp, yyllocp);
if (yytoken != YYEOF)
yytoken = YYEMPTY;
yyposn += 1;

View File

@@ -400,7 +400,8 @@ yy::]b4_parser_class_name[::symprint_ (int yytype,
(void) yylocationp;
cdebug_ << (yytype < ntokens_ ? "token" : "nterm")
<< ' ' << name_[yytype] << " (";
<< ' ' << name_[yytype] << " ("
<< *yylocationp << ": ";
switch (yytype)
{
]m4_map([b4_symbol_actions], m4_defn([b4_symbol_printers]))dnl
@@ -419,8 +420,6 @@ yy::]b4_parser_class_name[::destruct_ (const char *yymsg,
(void) yyvaluep;
(void) yylocationp;
if (!yymsg)
yymsg = "Deleting";
YY_SYMBOL_PRINT (yymsg, yytype, yyvaluep, yylocationp);
switch (yytype)
@@ -520,10 +519,7 @@ yybackup:
goto yyacceptlab;
/* Shift the look-ahead token. */
#if YYDEBUG
YYCDEBUG << "Shifting token " << looka_
<< " (" << name_[ilooka_] << "), ";
#endif
YY_SYMBOL_PRINT ("Shifting", ilooka_, &value, &location);
/* Discard the token being shifted unless it is eof. */
if (looka_ != eof_)
@@ -697,8 +693,6 @@ yyerrlab1:
if (n_ == final_)
goto yyacceptlab;
YYCDEBUG << "Shifting error token, ";
{
Location errloc;
errloc.begin = error_start_;
@@ -707,6 +701,10 @@ yyerrlab1:
location_stack_.push (errloc);
}
/* Shift the error token. */
YY_SYMBOL_PRINT ("Shifting", stos_[n_],
&semantic_stack_[0], &location_stack_[0]);
state_ = n_;
goto yynewstate;

View File

@@ -946,7 +946,7 @@ yybackup:
YYACCEPT;
/* Shift the look-ahead token. */
YYDPRINTF ((stderr, "Shifting token %s, ", yytname[yytoken]));
YY_SYMBOL_PRINT ("Shifting", yytoken, &yylval, &yylloc);
/* Discard the token being shifted unless it is eof. */
if (yychar != YYEOF)
@@ -1185,12 +1185,13 @@ yyerrlab1:
if (yyn == YYFINAL)
YYACCEPT;
YYDPRINTF ((stderr, "Shifting error token, "));
*++yyvsp = yylval;
]b4_location_if([ YYLLOC_DEFAULT (yyloc, yylsp, yylerrsp - yylsp);
*++yylsp = yyloc;])[
/* Shift the error token. */
YY_SYMBOL_PRINT ("Shifting", yystos[yyn], yyvsp, yylsp);
yystate = yyn;
goto yynewstate;