mirror of
https://git.savannah.gnu.org/git/bison.git
synced 2026-03-19 17:23:02 +00:00
"Use" parse parameters.
* data/c.m4 (b4_parse_param_for, b4_parse_param_use): New. * data/glr.c, data/glr.cc: Use them. * data/glr.c (YYUSE): Have a C++ definition that supports non-pointer types.
This commit is contained in:
@@ -1,3 +1,11 @@
|
|||||||
|
2005-11-14 Akim Demaille <akim@epita.fr>
|
||||||
|
|
||||||
|
"Use" parse parameters.
|
||||||
|
* data/c.m4 (b4_parse_param_for, b4_parse_param_use): New.
|
||||||
|
* data/glr.c, data/glr.cc: Use them.
|
||||||
|
* data/glr.c (YYUSE): Have a C++ definition that supports
|
||||||
|
non-pointer types.
|
||||||
|
|
||||||
2005-11-14 Akim Demaille <akim@epita.fr>
|
2005-11-14 Akim Demaille <akim@epita.fr>
|
||||||
|
|
||||||
* data/glr.c (yyexpandGLRStack): Declare only if defined.
|
* data/glr.c (yyexpandGLRStack): Declare only if defined.
|
||||||
|
|||||||
34
data/c.m4
34
data/c.m4
@@ -95,6 +95,27 @@ m4_define_default([b4_parse_param])
|
|||||||
m4_define([b4_parse_param],
|
m4_define([b4_parse_param],
|
||||||
b4_parse_param))
|
b4_parse_param))
|
||||||
|
|
||||||
|
# b4_parse_param_for(DECL, FORMAL, BODY)
|
||||||
|
# ---------------------------------------
|
||||||
|
# Iterate over the user parameters, binding the declaration to DECL,
|
||||||
|
# the formal name to FORMAL, and evaluating the BODY.
|
||||||
|
m4_define([b4_parse_param_for],
|
||||||
|
[m4_foreach([$1_$2], m4_defn([b4_parse_param]),
|
||||||
|
[m4_pushdef([$1], m4_fst($1_$2))dnl
|
||||||
|
m4_pushdef([$2], m4_shift($1_$2))dnl
|
||||||
|
$3[]dnl
|
||||||
|
m4_popdef([$2])dnl
|
||||||
|
m4_popdef([$1])dnl
|
||||||
|
])])
|
||||||
|
|
||||||
|
# b4_parse_param_use
|
||||||
|
# ------------------
|
||||||
|
# `YYUSE' all the parse-params.
|
||||||
|
# WARNING: Ends with a dnl, there must be nothing behind it.
|
||||||
|
m4_define([b4_parse_param_use],
|
||||||
|
[b4_parse_param_for([Decl], [Formal], [ YYUSE (Formal);
|
||||||
|
])dnl
|
||||||
|
])
|
||||||
|
|
||||||
## ------------ ##
|
## ------------ ##
|
||||||
## Data Types. ##
|
## Data Types. ##
|
||||||
@@ -348,6 +369,11 @@ m4_define([b4_syncline],
|
|||||||
[[#]line $1 $2])])
|
[[#]line $1 $2])])
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
## -------------- ##
|
||||||
|
## User actions. ##
|
||||||
|
## -------------- ##
|
||||||
|
|
||||||
# b4_symbol_actions(FILENAME, LINENO,
|
# b4_symbol_actions(FILENAME, LINENO,
|
||||||
# SYMBOL-TAG, SYMBOL-NUM,
|
# SYMBOL-TAG, SYMBOL-NUM,
|
||||||
# SYMBOL-ACTION, SYMBOL-TYPENAME)
|
# SYMBOL-ACTION, SYMBOL-TYPENAME)
|
||||||
@@ -386,7 +412,9 @@ m4_ifset([b4_parse_param], [, b4_parse_param]))[
|
|||||||
{
|
{
|
||||||
YYUSE (yyvaluep);
|
YYUSE (yyvaluep);
|
||||||
]b4_location_if([ YYUSE (yylocationp);
|
]b4_location_if([ YYUSE (yylocationp);
|
||||||
])[
|
])dnl
|
||||||
|
b4_parse_param_use[]dnl
|
||||||
|
[
|
||||||
if (!yymsg)
|
if (!yymsg)
|
||||||
yymsg = "Deleting";
|
yymsg = "Deleting";
|
||||||
YY_SYMBOL_PRINT (yymsg, yytype, yyvaluep, yylocationp);
|
YY_SYMBOL_PRINT (yymsg, yytype, yyvaluep, yylocationp);
|
||||||
@@ -422,8 +450,8 @@ m4_ifset([b4_parse_param], [, b4_parse_param]))[
|
|||||||
YYUSE (yyvaluep);
|
YYUSE (yyvaluep);
|
||||||
]b4_location_if([ YYUSE (yylocationp);
|
]b4_location_if([ YYUSE (yylocationp);
|
||||||
])dnl
|
])dnl
|
||||||
[
|
b4_parse_param_use[]dnl
|
||||||
if (yytype < YYNTOKENS)
|
[ if (yytype < YYNTOKENS)
|
||||||
YYFPRINTF (yyoutput, "token %s (", yytname[yytype]);
|
YYFPRINTF (yyoutput, "token %s (", yytname[yytype]);
|
||||||
else
|
else
|
||||||
YYFPRINTF (yyoutput, "nterm %s (", yytname[yytype]);
|
YYFPRINTF (yyoutput, "nterm %s (", yytname[yytype]);
|
||||||
|
|||||||
15
data/glr.c
15
data/glr.c
@@ -257,7 +257,11 @@ b4_syncline([@oline@], [@ofile@])
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* Suppress unused-variable warnings by "using" E. */
|
/* Suppress unused-variable warnings by "using" E. */
|
||||||
#define YYUSE(e) do {;} while (/*CONSTCOND*/ yyfalse && (e))
|
#if __cplusplus
|
||||||
|
# define YYUSE(e) (void) (e)
|
||||||
|
#else
|
||||||
|
# define YYUSE(e) do {;} while (/*CONSTCOND*/ yyfalse && (e))
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifndef YYFREE
|
#ifndef YYFREE
|
||||||
# define YYFREE free
|
# define YYFREE free
|
||||||
@@ -868,8 +872,8 @@ yyuserAction (yyRuleNum yyn, int yyrhslen, yyGLRStackItem* yyvsp,
|
|||||||
yybool yynormal __attribute__ ((__unused__)) =
|
yybool yynormal __attribute__ ((__unused__)) =
|
||||||
(yystack->yysplitPoint == NULL);
|
(yystack->yysplitPoint == NULL);
|
||||||
int yylow;
|
int yylow;
|
||||||
|
]b4_parse_param_use[]dnl
|
||||||
# undef yyerrok
|
[# undef yyerrok
|
||||||
# define yyerrok (yystack->yyerrState = 0)
|
# define yyerrok (yystack->yyerrState = 0)
|
||||||
# undef YYACCEPT
|
# undef YYACCEPT
|
||||||
# define YYACCEPT return yyaccept
|
# define YYACCEPT return yyaccept
|
||||||
@@ -1372,7 +1376,10 @@ yy_reduce_print (yyGLRStack* yystack, size_t yyk, yyRuleNum yyrule,
|
|||||||
yyGLRStackItem* yyvsp = (yyGLRStackItem*) yystack->yytops.yystates[yyk];
|
yyGLRStackItem* yyvsp = (yyGLRStackItem*) yystack->yytops.yystates[yyk];
|
||||||
int yylow = 1;
|
int yylow = 1;
|
||||||
int yyi;
|
int yyi;
|
||||||
YYFPRINTF (stderr, "Reducing stack %lu by rule %d (line %lu):\n",
|
YYUSE (yyvalp);
|
||||||
|
YYUSE (yylocp);
|
||||||
|
]b4_parse_param_use[]dnl
|
||||||
|
[ YYFPRINTF (stderr, "Reducing stack %lu by rule %d (line %lu):\n",
|
||||||
(unsigned long int) yyk, yyrule - 1,
|
(unsigned long int) yyk, yyrule - 1,
|
||||||
(unsigned long int) yyrline[yyrule]);
|
(unsigned long int) yyrline[yyrule]);
|
||||||
/* Print the symbols being reduced, and their result. */
|
/* Print the symbols being reduced, and their result. */
|
||||||
|
|||||||
12
data/glr.cc
12
data/glr.cc
@@ -53,7 +53,9 @@ b4_location_if([,
|
|||||||
[yylocationp]]])[]dnl
|
[yylocationp]]])[]dnl
|
||||||
m4_ifset([b4_parse_param], [, b4_parse_param]))[
|
m4_ifset([b4_parse_param], [, b4_parse_param]))[
|
||||||
{
|
{
|
||||||
(void) yyoutput;
|
YYUSE (yyoutput);
|
||||||
|
]b4_parse_param_use[]dnl
|
||||||
|
[
|
||||||
yyparser.yysymprint_ (yytype, yyvaluep]b4_location_if([, yylocationp])[);
|
yyparser.yysymprint_ (yytype, yyvaluep]b4_location_if([, yylocationp])[);
|
||||||
}
|
}
|
||||||
]])
|
]])
|
||||||
@@ -70,6 +72,8 @@ m4_prepend([b4_epilogue],
|
|||||||
b4_parse_param,
|
b4_parse_param,
|
||||||
[[const char* msg], [msg]])[
|
[[const char* msg], [msg]])[
|
||||||
{
|
{
|
||||||
|
]b4_parse_param_use[]dnl
|
||||||
|
[
|
||||||
yyparser.error (*yylocationp, msg);
|
yyparser.error (*yylocationp, msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -106,11 +110,11 @@ m4_popdef([b4_parse_param])dnl
|
|||||||
const semantic_type* yyvaluep, const location_type* yylocationp)
|
const semantic_type* yyvaluep, const location_type* yylocationp)
|
||||||
{
|
{
|
||||||
/* Pacify ``unused variable'' warnings. */
|
/* Pacify ``unused variable'' warnings. */
|
||||||
(void) yyvaluep;
|
YYUSE (yyvaluep);
|
||||||
(void) yylocationp;
|
YYUSE (yylocationp);
|
||||||
/* Backward compatibility, but should be removed eventually. */
|
/* Backward compatibility, but should be removed eventually. */
|
||||||
std::ostream& cdebug_ = *yycdebug_;
|
std::ostream& cdebug_ = *yycdebug_;
|
||||||
(void) cdebug_;
|
YYUSE (cdebug_);
|
||||||
|
|
||||||
*yycdebug_ << (yytype < YYNTOKENS ? "token" : "nterm")
|
*yycdebug_ << (yytype < YYNTOKENS ? "token" : "nterm")
|
||||||
<< ' ' << yytname[yytype] << " ("
|
<< ' ' << yytname[yytype] << " ("
|
||||||
|
|||||||
Reference in New Issue
Block a user