argument, an informative message.
Call YY_SYMBOL_PRINT.
Adjust all callers: integrate the associated YY_SYMBOL_PRINT.
* data/lalr1.cc (destruct_): Likewise.
In addition, no longer depend on b4_yysymprint_generate and
b4_yydestruct_generate to generate these functions, do it "by
hand".
+2004-09-06 Akim Demaille <akim@epita.fr>
+
+ * data/yacc.cc, data/glr.cc (yydestruct): Accept an additional
+ argument, an informative message.
+ Call YY_SYMBOL_PRINT.
+ Adjust all callers: integrate the associated YY_SYMBOL_PRINT.
+ * data/lalr1.cc (destruct_): Likewise.
+ In addition, no longer depend on b4_yysymprint_generate and
+ b4_yydestruct_generate to generate these functions, do it "by
+ hand".
+
2004-09-03 Akim Demaille <akim@epita.fr>
* data/glr.c, data/lalr1.cc, data/yacc.c: When YYABORT was
]$1([yydestruct],
[static void],
+ [[const char *yymsg], [yymsg]],
[[int yytype], [yytype]],
[[YYSTYPE *yyvaluep], [yyvaluep]]b4_location_if([,
[[YYLTYPE *yylocationp], [yylocationp]]]))[
(void) yyvaluep;
]b4_location_if([ (void) yylocationp;
])[
+ if (!yymsg)
+ yymsg = "Deleting";
+ YY_SYMBOL_PRINT (yymsg, yytype, yyvaluep, yylocationp);
+
switch (yytype)
{
]m4_map([b4_symbol_actions], m4_defn([b4_symbol_destructors]))[
while (yystack->yytops.yystates[0] != NULL)
{
yyGLRState *yys = yystack->yytops.yystates[0];
- YY_SYMBOL_PRINT ("Error: popping",
- yystos[yys->yylrState],
- &yys->yysemantics.yysval, &yys->yyloc);
- yydestruct (yystos[yys->yylrState],
+ yydestruct ("Error: popping",
+ yystos[yys->yylrState],
&yys->yysemantics.yysval]b4_location_if([, &yys->yyloc])[);
yystack->yytops.yystates[0] = yys->yypred;
yystack->yynextFree -= 1;
yyFail (yystack][]b4_lpure_args[, NULL);
}
if (*yytokenp != YYEMPTY)
- {
- YY_SYMBOL_PRINT ("Error: discarding", *yytokenp, yylvalp, yyllocp);
- yydestruct (*yytokenp, yylvalp]b4_location_if([, yyllocp])[);
- }
+ yydestruct ("Error: discarding",
+ *yytokenp, yylvalp]b4_location_if([, yyllocp])[);
YYDPRINTF ((stderr, "Reading a token: "));
yychar = YYLEX;
*yytokenp = YYTRANSLATE (yychar);
break;
}
}
- YY_SYMBOL_PRINT ("Error: popping",
- yystos[yys->yylrState],
- &yys->yysemantics.yysval, &yys->yyloc);
- yydestruct (yystos[yys->yylrState],
+ yydestruct ("Error: popping",
+ yystos[yys->yylrState],
&yys->yysemantics.yysval]b4_location_if([, &yys->yyloc])[);
yystack->yytops.yystates[0] = yys->yypred;
yystack->yynextFree -= 1;
yyDone:
/* On YYABORT, free the lookahead. */
if (yystack.yyerrflag == 1 && yytoken != YYEMPTY)
- {
- YY_SYMBOL_PRINT ("Error: discarding lookahead",
- yytoken, yylvalp, yyllocp);
- yydestruct (yytoken, yylvalp]b4_location_if([, yyllocp])[);
- }
+ yydestruct ("Error: discarding lookahead",
+ yytoken, yylvalp]b4_location_if([, yyllocp])[);
yyfreeGLRStack (&yystack);
return yystack.yyerrflag;
[ $1;])
-# b4_yysymprint_generate(FUNCTION-DECLARATOR)
-# -------------------------------------------
-# Generate the "symprint_" member function.
-m4_define([b4_yysymprint_generate],
-[[/*--------------------------------.
-| Print this symbol on YYOUTPUT. |
-`--------------------------------*/
-
-]void
-yy::b4_parser_class_name::symprint_ (int yytype, const SemanticType *yyvaluep, const LocationType *yylocationp)[
-{
- /* Pacify ``unused variable'' warnings. */
- (void) yyvaluep;
- (void) yylocationp;
-
- cdebug_ << (yytype < ntokens_ ? "token" : "nterm")
- << ' ' << name_[yytype] << " (";
- switch (yytype)
- {
-]m4_map([b4_symbol_actions], m4_defn([b4_symbol_printers]))dnl
-[ default:
- break;
- }
- cdebug_ << ')';
-}
-]])
-
-
-# b4_cxx_destruct_def(IGNORED-ARGUMENTS)
-# --------------------------------------
-# Declare the destruct_ method.
-m4_define([b4_cxx_destruct_def],
-[void
-yy::b4_parser_class_name::destruct_ (int yytype, SemanticType *yyvaluep, LocationType *yylocationp)[]dnl
-])
-
# We do want M4 expansion after # for CPP macros.
m4_changecom()
/* Even more tables. */
inline TokenNumberType translate_ (int token);
- inline void destruct_ (int yytype, SemanticType *yyvaluep,
- LocationType *yylocationp);
+ inline void destruct_ (const char *yymsg,
+ int yytype,
+ SemanticType *yyvaluep, LocationType *yylocationp);
/* Constants. */
static const int eof_;
#define YYERROR goto yyerrorlab
#if YYDEBUG
-]b4_yysymprint_generate([b4_cxx_symprint_def])[
+/*--------------------------------.
+| Print this symbol on YYOUTPUT. |
+`--------------------------------*/
+
+void
+yy::]b4_parser_class_name[::symprint_ (int yytype,
+ const SemanticType *yyvaluep, const LocationType *yylocationp)
+{
+ /* Pacify ``unused variable'' warnings. */
+ (void) yyvaluep;
+ (void) yylocationp;
+
+ cdebug_ << (yytype < ntokens_ ? "token" : "nterm")
+ << ' ' << name_[yytype] << " (";
+ switch (yytype)
+ {
+]m4_map([b4_symbol_actions], m4_defn([b4_symbol_printers]))dnl
+[ default:
+ break;
+ }
+ cdebug_ << ')';
+}
#endif /* ! YYDEBUG */
-]b4_yydestruct_generate([b4_cxx_destruct_def])[
+
+void
+yy::]b4_parser_class_name[::destruct_ (const char *yymsg,
+ int yytype, SemanticType *yyvaluep, LocationType *yylocationp)
+{
+ /* Pacify ``unused variable'' warnings. */
+ (void) yyvaluep;
+ (void) yylocationp;
+
+ if (!yymsg)
+ yymsg = "Deleting";
+ YY_SYMBOL_PRINT (yymsg, yytype, yyvaluep, yylocationp);
+
+ switch (yytype)
+ {
+]m4_map([b4_symbol_actions], m4_defn([b4_symbol_destructors]))[
+ default:
+ break;
+ }
+}
int
yy::]b4_parser_class_name[::parse ()
location_stack_.pop ();
if (state_stack_.height () == 1)
YYABORT;
- YY_SYMBOL_PRINT ("Error: popping",
- stos_[state_stack_[0]],
- &semantic_stack_[0],
- &location_stack_[0]);
- destruct_ (stos_[state_stack_[0]],
+ destruct_ ("Error: popping",
+ stos_[state_stack_[0]],
&semantic_stack_[0],
&location_stack_[0]);
}
}
else
{
- YY_SYMBOL_PRINT ("Error: discarding", ilooka_, &value, &location);
- destruct_ (ilooka_, &value, &location);
+ destruct_ ("Error: discarding", ilooka_, &value, &location);
looka_ = empty_;
}
}
if (state_stack_.height () == 1)
YYABORT;
- YY_SYMBOL_PRINT ("Error: popping",
- stos_[state_],
- &semantic_stack_[0], &location_stack_[0]);
- destruct_ (stos_[state_], &semantic_stack_[0], &location_stack_[0]);
+ destruct_ ("Error: popping",
+ stos_[state_], &semantic_stack_[0], &location_stack_[0]);
error_start_ = location_stack_[0].begin;
state_stack_.pop ();
/* Abort. */
yyabortlab:
/* Free the lookahead. */
- YY_SYMBOL_PRINT ("Error: discarding lookahead", ilooka_, &value, &location);
- destruct_ (ilooka_, &value, &location);
+ destruct_ ("Error: discarding lookahead", ilooka_, &value, &location);
looka_ = empty_;
return 1;
}
YYPOPSTACK;
if (yyssp == yyss)
YYABORT;
- YY_SYMBOL_PRINT ("Error: popping",
- yystos[*yyssp], yyvsp, yylsp);
- yydestruct (yystos[*yyssp], yyvsp]b4_location_if([, yylsp])[);
+ yydestruct ("Error: popping",
+ yystos[*yyssp], yyvsp]b4_location_if([, yylsp])[);
}
}
else
{
- YY_SYMBOL_PRINT ("Error: discarding", yytoken, &yylval, &yylloc);
- yydestruct (yytoken, &yylval]b4_location_if([, &yylloc])[);
+ yydestruct ("Error: discarding", yytoken, &yylval]b4_location_if([, &yylloc])[);
yychar = YYEMPTY;
]b4_location_if([ *++yylerrsp = yylloc;])[
}
if (yyssp == yyss)
YYABORT;
- YY_SYMBOL_PRINT ("Error: popping", yystos[*yyssp], yyvsp, yylsp);
- yydestruct (yystos[yystate], yyvsp]b4_location_if([, yylsp])[);
+ yydestruct ("Error: popping", yystos[yystate], yyvsp]b4_location_if([, yylsp])[);
YYPOPSTACK;
yystate = *yyssp;
YY_STACK_PRINT (yyss, yyssp);
| yyabortlab -- YYABORT comes here. |
`-----------------------------------*/
yyabortlab:
- YY_SYMBOL_PRINT ("Error: discarding lookahead", yytoken, &yylval, &yylloc);
- yydestruct (yytoken, &yylval]b4_location_if([, &yylloc])[);
+ yydestruct ("Error: discarding lookahead",
+ yytoken, &yylval]b4_location_if([, &yylloc])[);
yychar = YYEMPTY;
yyresult = 1;
goto yyreturn;