mirror of
https://git.savannah.gnu.org/git/bison.git
synced 2026-03-21 18:23:03 +00:00
* data/c.m4 (b4_c_function, b4_c_ansi_args, b4_c_ansi_arg)
(b4_c_knr_arg_names, b4_c_knr_arg_name, b4_c_knr_arg_decls) (b4_c_knr_arg_decl): New. * data/yacc.c: Use it to define yysymprint, yydestruct, and yyreport_parse_error.
This commit is contained in:
@@ -1,3 +1,11 @@
|
|||||||
|
2002-07-25 Akim Demaille <akim@epita.fr>
|
||||||
|
|
||||||
|
* data/c.m4 (b4_c_function, b4_c_ansi_args, b4_c_ansi_arg)
|
||||||
|
(b4_c_knr_arg_names, b4_c_knr_arg_name, b4_c_knr_arg_decls)
|
||||||
|
(b4_c_knr_arg_decl): New.
|
||||||
|
* data/yacc.c: Use it to define yysymprint, yydestruct, and
|
||||||
|
yyreport_parse_error.
|
||||||
|
|
||||||
2002-07-25 Akim Demaille <akim@epita.fr>
|
2002-07-25 Akim Demaille <akim@epita.fr>
|
||||||
|
|
||||||
* data/yacc.c (yyreport_parse_error): New, extracted from...
|
* data/yacc.c (yyreport_parse_error): New, extracted from...
|
||||||
|
|||||||
52
data/c.m4
52
data/c.m4
@@ -128,3 +128,55 @@ m4_map_sep([ b4_token_enum], [,
|
|||||||
m4_map([b4_token_define], [$@])
|
m4_map([b4_token_define], [$@])
|
||||||
])
|
])
|
||||||
])
|
])
|
||||||
|
|
||||||
|
|
||||||
|
## ---------------------------------------------- ##
|
||||||
|
## Declaring C functions in both K&R and ANSI-C. ##
|
||||||
|
## ---------------------------------------------- ##
|
||||||
|
|
||||||
|
|
||||||
|
# b4_c_function(NAME, RETURN-VALUE, [TYPE1, NAME1], ...)
|
||||||
|
# ------------------------------------------------
|
||||||
|
# Declare the function NAME.
|
||||||
|
m4_define([b4_c_function],
|
||||||
|
[$2
|
||||||
|
#if defined (__STDC__) || defined (__cplusplus)
|
||||||
|
$1 (b4_c_ansi_args(m4_shiftn(2, $@)))
|
||||||
|
#else
|
||||||
|
$1 (b4_c_knr_arg_names(m4_shiftn(2, $@)))
|
||||||
|
b4_c_knr_arg_decls(m4_shiftn(2, $@))
|
||||||
|
#endif[]dnl
|
||||||
|
])
|
||||||
|
|
||||||
|
|
||||||
|
# b4_c_ansi_args([TYPE1, NAME1], ...)
|
||||||
|
# -----------------------------------
|
||||||
|
# Output the arguments ANSI-C definition.
|
||||||
|
m4_define([b4_c_ansi_args],
|
||||||
|
[m4_map_sep([b4_c_ansi_arg], [, ], [$@])])
|
||||||
|
|
||||||
|
m4_define([b4_c_ansi_arg],
|
||||||
|
[$1 $2])
|
||||||
|
|
||||||
|
|
||||||
|
# b4_c_knr_args([TYPE1, NAME1], ...)
|
||||||
|
# ----------------------------------
|
||||||
|
# Output the argument names.
|
||||||
|
m4_define([b4_c_knr_arg_names],
|
||||||
|
[m4_map_sep([b4_c_knr_arg_name], [, ], [$@])])
|
||||||
|
|
||||||
|
m4_define([b4_c_knr_arg_name],
|
||||||
|
[$2])
|
||||||
|
|
||||||
|
|
||||||
|
# b4_c_knr_args([TYPE1, NAME1], ...)
|
||||||
|
# ----------------------------------
|
||||||
|
# Output the K&R argument declarations.
|
||||||
|
m4_define([b4_c_knr_arg_decls],
|
||||||
|
[m4_map_sep([b4_c_knr_arg_decl],
|
||||||
|
[
|
||||||
|
],
|
||||||
|
[$@])])
|
||||||
|
|
||||||
|
m4_define([b4_c_knr_arg_decl],
|
||||||
|
[ $1 $2;])
|
||||||
|
|||||||
110
data/yacc.c
110
data/yacc.c
@@ -603,52 +603,17 @@ yystpcpy (yydest, yysrc)
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
/* The user can define YYPARSE_PARAM as the name of an argument to be passed
|
|
||||||
into yyparse. The argument should have type void *.
|
|
||||||
It should actually point to an object.
|
|
||||||
Grammar actions can access the variable by casting it
|
|
||||||
to the proper pointer type. */
|
|
||||||
|
|
||||||
#ifdef YYPARSE_PARAM
|
|
||||||
# if defined (__STDC__) || defined (__cplusplus)
|
|
||||||
# define YYPARSE_PARAM_ARG void *YYPARSE_PARAM
|
|
||||||
# define YYPARSE_PARAM_DECL
|
|
||||||
# else
|
|
||||||
# define YYPARSE_PARAM_ARG YYPARSE_PARAM
|
|
||||||
# define YYPARSE_PARAM_DECL void *YYPARSE_PARAM;
|
|
||||||
# endif
|
|
||||||
#else /* !YYPARSE_PARAM */
|
|
||||||
# define YYPARSE_PARAM_ARG
|
|
||||||
# define YYPARSE_PARAM_DECL
|
|
||||||
#endif /* !YYPARSE_PARAM */
|
|
||||||
|
|
||||||
/* Prevent warning if -Wstrict-prototypes. */
|
|
||||||
#ifdef __GNUC__
|
|
||||||
# ifdef YYPARSE_PARAM
|
|
||||||
int yyparse (void *);
|
|
||||||
# else
|
|
||||||
int yyparse (void);
|
|
||||||
# endif
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
#if YYDEBUG
|
#if YYDEBUG
|
||||||
/*-----------------------------.
|
/*-----------------------------.
|
||||||
| Print this symbol on YYOUT. |
|
| Print this symbol on YYOUT. |
|
||||||
`-----------------------------*/
|
`-----------------------------*/
|
||||||
|
|
||||||
static void
|
b4_c_function([yysymprint],
|
||||||
#if defined (__STDC__) || defined (__cplusplus)
|
[static void],
|
||||||
yysymprint (FILE* yyout, int yytype,
|
[[FILE*], [yyout]],
|
||||||
YYSTYPE yyvalue[]b4_location_if([, YYLTYPE yylocation]))
|
[[int], [yytype]],
|
||||||
#else
|
[[YYSTYPE], [yyvalue]]b4_location_if([,
|
||||||
yysymprint (yyout, yytype,
|
[[YYLTYPE], [yylocation]]]))
|
||||||
yyvalue[]b4_location_if([, yylocation]))
|
|
||||||
FILE* yyout;
|
|
||||||
int yytype;
|
|
||||||
YYSTYPE yyvalue;
|
|
||||||
b4_location_if([YYLTYPE yylocation;])
|
|
||||||
#endif
|
|
||||||
{
|
{
|
||||||
/* Pacify ``unused variable'' warnings. */
|
/* Pacify ``unused variable'' warnings. */
|
||||||
(void) yyvalue;
|
(void) yyvalue;
|
||||||
@@ -680,18 +645,12 @@ m4_map([b4_symbol_actions], m4_defn([b4_symbol_printers]))dnl
|
|||||||
| yyreport_parse_error -- report a parse error in YYSTATE. |
|
| yyreport_parse_error -- report a parse error in YYSTATE. |
|
||||||
`----------------------------------------------------------*/
|
`----------------------------------------------------------*/
|
||||||
|
|
||||||
static void
|
b4_c_function([yyreport_parse_error],
|
||||||
#if defined (__STDC__) || defined (__cplusplus)
|
[static void],
|
||||||
yyreport_parse_error (int yystate, int yychar,
|
[[int], [yystate]],
|
||||||
YYSTYPE yyvalue[]b4_location_if([, YYLTYPE yylocation]))
|
[[int], [yychar]],
|
||||||
#else
|
[[YYSTYPE], [yyvalue]]b4_location_if([,
|
||||||
yyreport_parse_error (yystate, yychar,
|
[[YYLTYPE], [yylocation]]]))
|
||||||
yyvalue[]b4_location_if([, yylocation]))
|
|
||||||
int yystate;
|
|
||||||
int yychar;
|
|
||||||
YYSTYPE yyvalue;
|
|
||||||
b4_location_if([YYLTYPE yylocation;])
|
|
||||||
#endif
|
|
||||||
[{
|
[{
|
||||||
#if YYERROR_VERBOSE
|
#if YYERROR_VERBOSE
|
||||||
int yyn = yypact[yystate];
|
int yyn = yypact[yystate];
|
||||||
@@ -754,17 +713,11 @@ yyreport_parse_error (yystate, yychar,
|
|||||||
| Release the memory associated to this symbol. |
|
| Release the memory associated to this symbol. |
|
||||||
`-----------------------------------------------*/
|
`-----------------------------------------------*/
|
||||||
|
|
||||||
static void
|
b4_c_function([yydestruct],
|
||||||
#if defined (__STDC__) || defined (__cplusplus)
|
[static void],
|
||||||
yydestruct (int yytype,
|
[[int], [yytype]],
|
||||||
YYSTYPE yyvalue[]b4_location_if([, YYLTYPE yylocation]))
|
[[YYSTYPE], [yyvalue]]b4_location_if([,
|
||||||
#else
|
[[YYLTYPE], [yylocation]]]))
|
||||||
yydestruct (yytype,
|
|
||||||
yyvalue[]b4_location_if([, yylocation]))
|
|
||||||
int yytype;
|
|
||||||
YYSTYPE yyvalue;
|
|
||||||
b4_location_if([YYLTYPE yylocation;])
|
|
||||||
#endif
|
|
||||||
{
|
{
|
||||||
/* Pacify ``unused variable'' warnings. */
|
/* Pacify ``unused variable'' warnings. */
|
||||||
(void) yyvalue;
|
(void) yyvalue;
|
||||||
@@ -779,6 +732,35 @@ m4_map([b4_symbol_actions], m4_defn([b4_symbol_destructors]))dnl
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/* The user can define YYPARSE_PARAM as the name of an argument to be passed
|
||||||
|
into yyparse. The argument should have type void *.
|
||||||
|
It should actually point to an object.
|
||||||
|
Grammar actions can access the variable by casting it
|
||||||
|
to the proper pointer type. */
|
||||||
|
|
||||||
|
#ifdef YYPARSE_PARAM
|
||||||
|
# if defined (__STDC__) || defined (__cplusplus)
|
||||||
|
# define YYPARSE_PARAM_ARG void *YYPARSE_PARAM
|
||||||
|
# define YYPARSE_PARAM_DECL
|
||||||
|
# else
|
||||||
|
# define YYPARSE_PARAM_ARG YYPARSE_PARAM
|
||||||
|
# define YYPARSE_PARAM_DECL void *YYPARSE_PARAM;
|
||||||
|
# endif
|
||||||
|
#else /* !YYPARSE_PARAM */
|
||||||
|
# define YYPARSE_PARAM_ARG
|
||||||
|
# define YYPARSE_PARAM_DECL
|
||||||
|
#endif /* !YYPARSE_PARAM */
|
||||||
|
|
||||||
|
/* Prevent warning if -Wstrict-prototypes. */
|
||||||
|
#ifdef __GNUC__
|
||||||
|
# ifdef YYPARSE_PARAM
|
||||||
|
int yyparse (void *);
|
||||||
|
# else
|
||||||
|
int yyparse (void);
|
||||||
|
# endif
|
||||||
|
#endif
|
||||||
|
|
||||||
m4_divert_push([KILL])# ======================== M4 code.
|
m4_divert_push([KILL])# ======================== M4 code.
|
||||||
# b4_declare_parser_variables
|
# b4_declare_parser_variables
|
||||||
|
|||||||
Reference in New Issue
Block a user