[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
FYI: More YY_SYMBOL_PRINT invocation into yydestruct
From: |
Akim Demaille |
Subject: |
FYI: More YY_SYMBOL_PRINT invocation into yydestruct |
Date: |
Mon, 06 Sep 2004 12:30:07 +0200 |
User-agent: |
Gnus/5.1006 (Gnus v5.10.6) Emacs/21.3 (gnu/linux) |
Index: ChangeLog
from Akim Demaille <address@hidden>
* 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".
Index: data/c.m4
===================================================================
RCS file: /cvsroot/bison/bison/data/c.m4,v
retrieving revision 1.23
diff -u -u -r1.23 c.m4
--- data/c.m4 22 Jul 2004 14:39:03 -0000 1.23
+++ data/c.m4 6 Sep 2004 10:28:53 -0000
@@ -352,6 +352,7 @@
]$1([yydestruct],
[static void],
+ [[const char *yymsg], [yymsg]],
[[int yytype], [yytype]],
[[YYSTYPE *yyvaluep], [yyvaluep]]b4_location_if([,
[[YYLTYPE *yylocationp], [yylocationp]]]))[
@@ -360,6 +361,10 @@
(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]))[
Index: data/glr.c
===================================================================
RCS file: /cvsroot/bison/bison/data/glr.c,v
retrieving revision 1.73
diff -u -u -r1.73 glr.c
--- data/glr.c 6 Sep 2004 07:48:19 -0000 1.73
+++ data/glr.c 6 Sep 2004 10:28:54 -0000
@@ -1698,10 +1698,8 @@
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;
@@ -1710,10 +1708,8 @@
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);
@@ -1760,10 +1756,8 @@
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;
@@ -1918,11 +1912,8 @@
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;
Index: data/lalr1.cc
===================================================================
RCS file: /cvsroot/bison/bison/data/lalr1.cc,v
retrieving revision 1.51
diff -u -u -r1.51 lalr1.cc
--- data/lalr1.cc 6 Sep 2004 07:48:19 -0000 1.51
+++ data/lalr1.cc 6 Sep 2004 10:28:54 -0000
@@ -115,42 +115,6 @@
[ $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()
@@ -316,8 +280,9 @@
/* 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_;
@@ -419,9 +384,49 @@
#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 ()
@@ -614,19 +619,15 @@
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_;
}
}
@@ -679,10 +680,8 @@
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 ();
@@ -715,8 +714,7 @@
/* 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;
}
Index: data/yacc.c
===================================================================
RCS file: /cvsroot/bison/bison/data/yacc.c,v
retrieving revision 1.66
diff -u -u -r1.66 yacc.c
--- data/yacc.c 6 Sep 2004 07:48:19 -0000 1.66
+++ data/yacc.c 6 Sep 2004 10:28:54 -0000
@@ -1114,15 +1114,13 @@
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;])[
}
@@ -1178,8 +1176,7 @@
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);
@@ -1209,8 +1206,8 @@
| 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;
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- FYI: More YY_SYMBOL_PRINT invocation into yydestruct,
Akim Demaille <=