"Joel E. Denny" <[EMAIL PROTECTED]> writes:
> This approach is much easier, but it drops some diagnostic messages. I
> thought trying to invoke YY_SYMBOL_PRINT() would be worthwhile.
Thanks for mentioning this. However, I'd rather not complicate
all the skeletons for the sake of this GLR-specific problem.
I installed the following patch instead. It outputs a bit more
information than the patch you proposed, since it mentions which
popped items were unresolved. Please let me know how it works for you.
2005-08-25 Paul Eggert <[EMAIL PROTECTED]>
* data/glr.c (yydestroyStackItem): New function.
(yyrecoverSyntaxError, yyreturn): Use it to improve quality of
debugging information. Problem reported by Joel E. Denny.
--- data/glr.c 25 Aug 2005 06:11:34 -0000 1.115
+++ data/glr.c 25 Aug 2005 17:57:23 -0000 1.116
@@ -886,6 +886,26 @@ yyuserMerge (int yyn, YYSTYPE* yy0, YYST
]b4_yydestruct_generate([b4_c_ansi_function_def])[
+static void
+yydestroyStackItem (char const *yymsg, yyGLRState *yys)
+{
+ if (yys->yyresolved)
+ yydestruct (yymsg, yystos[yys->yylrState],
+ &yys->yysemantics.yysval]b4_location_if([, &yys->yyloc])[);
+ else
+ {
+#if YYDEBUG
+ if (yydebug)
+ {
+ YYFPRINTF (stderr, "%s unresolved ", yymsg);
+ yysymprint (stderr, yystos[yys->yylrState],
+ &yys->yysemantics.yysval]b4_location_if([,
&yys->yyloc])[);
+ YYFPRINTF (stderr, "\n");
+ }
+#endif
+ }
+}
+
/** Number of symbols composing the right hand side of rule #RULE. */
static inline int
yyrhsLength (yyRuleNum yyrule)
@@ -1981,10 +2001,7 @@ yyrecoverSyntaxError (yyGLRStack* yystac
}
}
]b4_location_if([[ yystack->yyerror_range[1].yystate.yyloc =
yys->yyloc;]])[
- if (yys->yyresolved)
- yydestruct ("Error: popping",
- yystos[yys->yylrState],
- &yys->yysemantics.yysval]b4_location_if([, &yys->yyloc])[);
+ yydestroyStackItem ("Error: popping", yys);
yystack->yytops.yystates[0] = yys->yypred;
yystack->yynextFree -= 1;
yystack->yyspaceLeft += 1;
@@ -2184,10 +2201,7 @@ b4_syncline([EMAIL PROTECTED]@], [EMAIL
PROTECTED]@])])dnl
{
yyGLRState *yys = yystates[0];
]b4_location_if([[ yystack.yyerror_range[1].yystate.yyloc = yys->yyloc;]]
-)[ if (yys->yyresolved)
- yydestruct ("Cleanup: popping",
- yystos[yys->yylrState],
- &yys->yysemantics.yysval]b4_location_if([,
&yys->yyloc])[);
+)[ yydestroyStackItem ("Cleanup: popping", yys);
yystates[0] = yys->yypred;
yystack.yynextFree -= 1;
yystack.yyspaceLeft += 1;