mirror of
https://git.savannah.gnu.org/git/bison.git
synced 2026-03-09 12:23:04 +00:00
m4: decommission function generating macro
These macros have been extremely useful when we had to support K&R C, which we dropped long ago. Now, they merely make the code uselessly hard to read. * data/skeletons/c.m4, data/skeletons/glr.c, data/skeletons/glr.cc, * data/skeletons/yacc.c: Stop using b4_function_define.
This commit is contained in:
@@ -129,6 +129,13 @@ m4_define([b4_user_args],
|
||||
[m4_ifset([b4_parse_param], [, b4_args(b4_parse_param)])])
|
||||
|
||||
|
||||
# b4_user_formals
|
||||
# ---------------
|
||||
# The possible parse-params formal arguments preceded by a comma.
|
||||
m4_define([b4_user_formals],
|
||||
[m4_ifset([b4_parse_param], [, b4_formals(b4_parse_param)])])
|
||||
|
||||
|
||||
# b4_parse_param
|
||||
# --------------
|
||||
# If defined, b4_parse_param arrives double quoted, but below we prefer
|
||||
@@ -600,13 +607,10 @@ m4_define_default([b4_yydestruct_define],
|
||||
| Release the memory associated to this symbol. |
|
||||
`-----------------------------------------------*/
|
||||
|
||||
]b4_function_define([yydestruct],
|
||||
[static void],
|
||||
[[const char *yymsg], [yymsg]],
|
||||
[[int yytype], [yytype]],
|
||||
[[YYSTYPE *yyvaluep], [yyvaluep]][]dnl
|
||||
b4_locations_if( [, [[YYLTYPE *yylocationp], [yylocationp]]])[]dnl
|
||||
m4_ifset([b4_parse_param], [, b4_parse_param]))[
|
||||
static void
|
||||
yydestruct (const char *yymsg,
|
||||
int yytype, YYSTYPE *yyvaluep]b4_locations_if(dnl
|
||||
[[, YYLTYPE *yylocationp]])[]b4_user_formals[)
|
||||
{
|
||||
]b4_parse_param_use([yyvaluep], [yylocationp])dnl
|
||||
[ if (!yymsg)
|
||||
@@ -629,13 +633,10 @@ m4_define_default([b4_yy_symbol_print_define],
|
||||
| Print this symbol's value on YYO. |
|
||||
`-----------------------------------*/
|
||||
|
||||
]b4_function_define([yy_symbol_value_print],
|
||||
[static void],
|
||||
[[FILE *yyo], [yyo]],
|
||||
[[int yytype], [yytype]],
|
||||
[[YYSTYPE const * const yyvaluep], [yyvaluep]][]dnl
|
||||
b4_locations_if([, [[YYLTYPE const * const yylocationp], [yylocationp]]])[]dnl
|
||||
m4_ifset([b4_parse_param], [, b4_parse_param]))[
|
||||
static void
|
||||
yy_symbol_value_print (FILE *yyo,
|
||||
int yytype, YYSTYPE const * const yyvaluep]b4_locations_if(dnl
|
||||
[[, YYLTYPE const * const yylocationp]])[]b4_user_formals[)
|
||||
{
|
||||
FILE *yyoutput = yyo;
|
||||
]b4_parse_param_use([yyoutput], [yylocationp])dnl
|
||||
@@ -660,13 +661,10 @@ b4_percent_code_get([[post-printer]])dnl
|
||||
| Print this symbol on YYO. |
|
||||
`---------------------------*/
|
||||
|
||||
]b4_function_define([yy_symbol_print],
|
||||
[static void],
|
||||
[[FILE *yyo], [yyo]],
|
||||
[[int yytype], [yytype]],
|
||||
[[YYSTYPE const * const yyvaluep], [yyvaluep]][]dnl
|
||||
b4_locations_if([, [[YYLTYPE const * const yylocationp], [yylocationp]]])[]dnl
|
||||
m4_ifset([b4_parse_param], [, b4_parse_param]))[
|
||||
static void
|
||||
yy_symbol_print (FILE *yyo,
|
||||
int yytype, YYSTYPE const * const yyvaluep]b4_locations_if(dnl
|
||||
[[, YYLTYPE const * const yylocationp]])[]b4_user_formals[)
|
||||
{
|
||||
YYFPRINTF (yyo, "%s %s (",
|
||||
yytype < YYNTOKENS ? "token" : "nterm", yysymbol_name (yytype));
|
||||
@@ -943,10 +941,8 @@ m4_define([b4_yy_location_print_define],
|
||||
/* Print *YYLOCP on YYO. Private, do not rely on its existence. */
|
||||
|
||||
YY_ATTRIBUTE_UNUSED
|
||||
]b4_function_define([yy_location_print_],
|
||||
[static int],
|
||||
[[FILE *yyo], [yyo]],
|
||||
[[YYLTYPE const * const yylocp], [yylocp]])[
|
||||
static int
|
||||
yy_location_print_ (FILE *yyo, YYLTYPE const * const yylocp)
|
||||
{
|
||||
int res = 0;
|
||||
int end_col = 0 != yylocp->last_column ? yylocp->last_column - 1 : 0;
|
||||
|
||||
@@ -46,16 +46,6 @@ m4_ifndef([b4_pure_flag],
|
||||
m4_define([b4_pure_flag],
|
||||
[b4_percent_define_flag_if([[api.pure]], [[1]], [[0]])])])
|
||||
|
||||
# b4_user_formals
|
||||
# ---------------
|
||||
# The possible parse-params formal arguments preceded by a comma.
|
||||
#
|
||||
# This is not shared with yacc.c in c.m4 because GLR relies on ISO C
|
||||
# formal argument declarations.
|
||||
m4_define([b4_user_formals],
|
||||
[m4_ifset([b4_parse_param], [, b4_formals(b4_parse_param)])])
|
||||
|
||||
|
||||
# b4_yyerror_args
|
||||
# ---------------
|
||||
# Optional effective arguments passed to yyerror: user args plus yylloc, and
|
||||
|
||||
@@ -77,16 +77,10 @@ m4_define([b4_yy_symbol_print_define],
|
||||
| Print this symbol. |
|
||||
`--------------------*/
|
||||
|
||||
]b4_function_define([yy_symbol_print],
|
||||
[static void],
|
||||
[[FILE *], []],
|
||||
[[int yytype], [yytype]],
|
||||
[[const ]b4_namespace_ref::b4_parser_class[::semantic_type *yyvaluep],
|
||||
[yyvaluep]][]dnl
|
||||
b4_locations_if([,
|
||||
[[const ]b4_namespace_ref::b4_parser_class[::location_type *yylocationp],
|
||||
[yylocationp]]]),
|
||||
b4_parse_param)[
|
||||
static void
|
||||
yy_symbol_print (FILE *, int yytype,
|
||||
const ]b4_namespace_ref::b4_parser_class[::semantic_type *yyvaluep]b4_locations_if([[,
|
||||
const ]b4_namespace_ref::b4_parser_class[::location_type *yylocationp]])[]b4_user_formals[)
|
||||
{
|
||||
]b4_parse_param_use[]dnl
|
||||
[ yyparser.yy_symbol_print_ (yytype, yyvaluep]b4_locations_if([, yylocationp])[);
|
||||
@@ -134,12 +128,10 @@ m4_append([b4_epilogue],
|
||||
| Report an error. |
|
||||
`------------------*/
|
||||
|
||||
]b4_function_define([yyerror],
|
||||
[static void],b4_locations_if([
|
||||
[[const ]b4_namespace_ref::b4_parser_class[::location_type *yylocationp],
|
||||
[yylocationp]],])
|
||||
b4_parse_param,
|
||||
[[const char* msg], [msg]])[
|
||||
static void
|
||||
yyerror (]b4_locations_if([[const ]b4_namespace_ref::b4_parser_class[::location_type *yylocationp,
|
||||
]])[]m4_ifset([b4_parse_param], [b4_formals(b4_parse_param),
|
||||
])[const char* msg)
|
||||
{
|
||||
]b4_parse_param_use[]dnl
|
||||
[ yyparser.error (]b4_locations_if([[*yylocationp, ]])[msg);
|
||||
|
||||
@@ -735,9 +735,8 @@ do { \
|
||||
| TOP (included). |
|
||||
`------------------------------------------------------------------*/
|
||||
|
||||
]b4_function_define([yy_stack_print], [static void],
|
||||
[[yy_state_t *yybottom], [yybottom]],
|
||||
[[yy_state_t *yytop], [yytop]])[
|
||||
static void
|
||||
yy_stack_print (yy_state_t *yybottom, yy_state_t *yytop)
|
||||
{
|
||||
YYFPRINTF (stderr, "Stack now");
|
||||
for (; yybottom <= yytop; yybottom++)
|
||||
@@ -759,12 +758,9 @@ do { \
|
||||
| Report that the YYRULE is going to be reduced. |
|
||||
`------------------------------------------------*/
|
||||
|
||||
]b4_function_define([yy_reduce_print], [static void],
|
||||
[[yy_state_t *yyssp], [yyssp]],
|
||||
[[YYSTYPE *yyvsp], [yyvsp]],
|
||||
b4_locations_if([[[YYLTYPE *yylsp], [yylsp]],
|
||||
])[[int yyrule], [yyrule]]m4_ifset([b4_parse_param], [,
|
||||
b4_parse_param]))[
|
||||
static void
|
||||
yy_reduce_print (yy_state_t *yyssp, YYSTYPE *yyvsp,]b4_locations_if([[ YYLTYPE *yylsp,]])[
|
||||
int yyrule]b4_user_formals[)
|
||||
{
|
||||
int yylno = yyrline[yyrule];
|
||||
int yynrhs = yyr2[yyrule];
|
||||
@@ -1207,8 +1203,8 @@ yyparse_context_location (const yyparse_context_t *yyctx)
|
||||
# define yystrlen(S) (YY_CAST (YYPTRDIFF_T, strlen (S)))
|
||||
# else
|
||||
/* Return the length of YYSTR. */
|
||||
]b4_function_define([yystrlen], [static YYPTRDIFF_T],
|
||||
[[const char *yystr], [yystr]])[
|
||||
static YYPTRDIFF_T
|
||||
yystrlen (const char *yystr)
|
||||
{
|
||||
YYPTRDIFF_T yylen;
|
||||
for (yylen = 0; yystr[yylen]; yylen++)
|
||||
@@ -1224,8 +1220,8 @@ yyparse_context_location (const yyparse_context_t *yyctx)
|
||||
# else
|
||||
/* Copy YYSRC to YYDEST, returning the address of the terminating '\0' in
|
||||
YYDEST. */
|
||||
]b4_function_define([yystpcpy], [static char *],
|
||||
[[char *yydest], [yydest]], [[const char *yysrc], [yysrc]])[
|
||||
static char *
|
||||
yystpcpy (char *yydest, const char *yysrc)
|
||||
{
|
||||
char *yyd = yydest;
|
||||
const char *yys = yysrc;
|
||||
@@ -1388,10 +1384,9 @@ yysyntax_error (YYPTRDIFF_T *yymsg_alloc, char **yymsg,
|
||||
|
||||
]b4_yydestruct_define[
|
||||
|
||||
]b4_pure_if([], [[
|
||||
|
||||
]b4_declare_scanner_communication_variables])[]b4_push_if([[
|
||||
]b4_pure_if([], [b4_declare_scanner_communication_variables])[
|
||||
|
||||
]b4_push_if([[
|
||||
struct yypstate
|
||||
{]b4_declare_parser_state_variables[
|
||||
/* Used to determine if this is the first time this instance has
|
||||
@@ -1399,17 +1394,16 @@ struct yypstate
|
||||
int yynew;
|
||||
};]b4_pure_if([], [[
|
||||
|
||||
static char yypstate_allocated = 0;]])b4_pull_if([
|
||||
static char yypstate_allocated = 0;]])b4_pull_if([[
|
||||
|
||||
b4_function_define([[yyparse]], [[int]], b4_parse_param)[
|
||||
int
|
||||
yyparse (]m4_ifset([b4_parse_param], [b4_formals(b4_parse_param)], [void])[)
|
||||
{
|
||||
return yypull_parse (YY_NULLPTR]m4_ifset([b4_parse_param],
|
||||
[[, ]b4_args(b4_parse_param)])[);
|
||||
return yypull_parse (YY_NULLPTR]b4_user_args[);
|
||||
}
|
||||
|
||||
]b4_function_define([[yypull_parse]], [[int]],
|
||||
[[[yypstate *yyps]], [[yyps]]]m4_ifset([b4_parse_param], [,
|
||||
b4_parse_param]))[
|
||||
int
|
||||
yypull_parse (yypstate *yyps]b4_user_formals[)
|
||||
{]b4_pure_if([b4_locations_if([[
|
||||
static YYLTYPE yyloc_default][]b4_yyloc_default[;
|
||||
YYLTYPE yylloc = yyloc_default;]])])[
|
||||
@@ -1440,7 +1434,8 @@ b4_function_define([[yyparse]], [[int]], b4_parse_param)[
|
||||
}]])[
|
||||
|
||||
/* Initialize the parser data structure. */
|
||||
]b4_function_define([[yypstate_new]], [[yypstate *]])[
|
||||
yypstate *
|
||||
yypstate_new (void)
|
||||
{
|
||||
yypstate *yyps;]b4_pure_if([], [[
|
||||
if (yypstate_allocated)
|
||||
@@ -1453,8 +1448,8 @@ b4_function_define([[yyparse]], [[int]], b4_parse_param)[
|
||||
return yyps;
|
||||
}
|
||||
|
||||
]b4_function_define([[yypstate_delete]], [[void]],
|
||||
[[[yypstate *yyps]], [[yyps]]])[
|
||||
void
|
||||
yypstate_delete (yypstate *yyps)
|
||||
{
|
||||
if (yyps)
|
||||
{
|
||||
@@ -1488,25 +1483,23 @@ b4_function_define([[yyparse]], [[int]], b4_parse_param)[
|
||||
#define yyesa yyps->yyesa
|
||||
#define yyes yyps->yyes
|
||||
#define yyes_capacity yyps->yyes_capacity]])[
|
||||
]])[
|
||||
|
||||
|
||||
]b4_push_if([[
|
||||
/*---------------.
|
||||
| yypush_parse. |
|
||||
`---------------*/
|
||||
|
||||
]b4_function_define([[yypush_parse]], [[int]],
|
||||
[[[yypstate *yyps]], [[yyps]]]b4_pure_if([,
|
||||
[[[int yypushed_char]], [[yypushed_char]]],
|
||||
[[[YYSTYPE const *yypushed_val]], [[yypushed_val]]]b4_locations_if([,
|
||||
[[[YYLTYPE *yypushed_loc]], [[yypushed_loc]]]])])m4_ifset([b4_parse_param], [,
|
||||
b4_parse_param]))], [[
|
||||
|
||||
|
||||
int
|
||||
yypush_parse (yypstate *yyps]b4_pure_if([[,
|
||||
int yypushed_char, YYSTYPE const *yypushed_val]b4_locations_if([[, YYLTYPE *yypushed_loc]])])b4_user_formals[)]],
|
||||
[[
|
||||
/*----------.
|
||||
| yyparse. |
|
||||
`----------*/
|
||||
|
||||
]b4_function_define([yyparse], [int], b4_parse_param)])[
|
||||
int
|
||||
yyparse (]m4_ifset([b4_parse_param], [b4_formals(b4_parse_param)], [void])[)]])[
|
||||
{]b4_pure_if([b4_declare_scanner_communication_variables
|
||||
])b4_push_if([b4_pure_if([], [[
|
||||
int yypushed_char = yychar;
|
||||
|
||||
Reference in New Issue
Block a user