mirror of
https://git.savannah.gnu.org/git/bison.git
synced 2026-03-09 20:33:03 +00:00
skeletons: remove K&R C support
* data/c.m4 (b4_c_modern, b4_c_knr_formal_names, b4_c_knr_formal_decls) (b4_c_knr_formal_decl, b4_c_formal_names, b4_c_formal_decls) (b4_c_formal_decl): Remove. (b4_c_ansi_formal_names, b4_c_ansi_formal_decls, b4_c_ansi_formal_decl): Rename as... (b4_c_formal_names, b4_c_formal_decls, b4_c_formal_decl): these. * data/glr.c, data/glr.cc, data/yacc.c: Adjust.
This commit is contained in:
99
data/c.m4
99
data/c.m4
@@ -317,106 +317,43 @@ m4_define([b4_symbol_value],
|
||||
|
||||
|
||||
|
||||
## --------------------------------------------- ##
|
||||
## Defining C functions in both K&R and ANSI-C. ##
|
||||
## --------------------------------------------- ##
|
||||
## ---------------------- ##
|
||||
## Defining C functions. ##
|
||||
## ---------------------- ##
|
||||
|
||||
|
||||
# b4_modern_c
|
||||
# -----------
|
||||
# A predicate useful in #if to determine whether C is ancient or modern.
|
||||
#
|
||||
# If __STDC__ is defined, the compiler is modern. IBM xlc 7.0 when run
|
||||
# as 'cc' doesn't define __STDC__ (or __STDC_VERSION__) for pedantic
|
||||
# reasons, but it defines __C99__FUNC__ so check that as well.
|
||||
# Microsoft C normally doesn't define these macros, but it defines _MSC_VER.
|
||||
# Consider a C++ compiler to be modern if it defines __cplusplus.
|
||||
#
|
||||
m4_define([b4_c_modern],
|
||||
[[(defined __STDC__ || defined __C99__FUNC__ \
|
||||
|| defined __cplusplus || defined _MSC_VER)]])
|
||||
|
||||
# b4_c_function_def(NAME, RETURN-VALUE, [DECL1, NAME1], ...)
|
||||
# ----------------------------------------------------------
|
||||
# Declare the function NAME.
|
||||
# Declare the function NAME in C.
|
||||
m4_define([b4_c_function_def],
|
||||
[#if b4_c_modern
|
||||
b4_c_ansi_function_def($@)
|
||||
#else
|
||||
$2
|
||||
$1 (b4_c_knr_formal_names(m4_shift2($@)))
|
||||
b4_c_knr_formal_decls(m4_shift2($@))
|
||||
#endif[]dnl
|
||||
])
|
||||
|
||||
|
||||
# b4_c_ansi_function_def(NAME, RETURN-VALUE, [DECL1, NAME1], ...)
|
||||
# ---------------------------------------------------------------
|
||||
# Declare the function NAME in ANSI.
|
||||
m4_define([b4_c_ansi_function_def],
|
||||
[$2
|
||||
$1 (b4_c_ansi_formals(m4_shift2($@)))[]dnl
|
||||
$1 (b4_c_formals(m4_shift2($@)))[]dnl
|
||||
])
|
||||
|
||||
|
||||
# b4_c_ansi_formals([DECL1, NAME1], ...)
|
||||
# --------------------------------------
|
||||
# Output the arguments ANSI-C definition.
|
||||
m4_define([b4_c_ansi_formals],
|
||||
# b4_c_formals([DECL1, NAME1], ...)
|
||||
# ---------------------------------
|
||||
# The formal arguments of a C function definition.
|
||||
m4_define([b4_c_formals],
|
||||
[m4_if([$#], [0], [void],
|
||||
[$#$1], [1], [void],
|
||||
[m4_map_sep([b4_c_ansi_formal], [, ], [$@])])])
|
||||
[m4_map_sep([b4_c_formal], [, ], [$@])])])
|
||||
|
||||
m4_define([b4_c_ansi_formal],
|
||||
m4_define([b4_c_formal],
|
||||
[$1])
|
||||
|
||||
|
||||
# b4_c_knr_formal_names([DECL1, NAME1], ...)
|
||||
# ------------------------------------------
|
||||
# Output the argument names.
|
||||
m4_define([b4_c_knr_formal_names],
|
||||
[m4_map_sep([b4_c_knr_formal_name], [, ], [$@])])
|
||||
|
||||
m4_define([b4_c_knr_formal_name],
|
||||
[$2])
|
||||
|
||||
|
||||
# b4_c_knr_formal_decls([DECL1, NAME1], ...)
|
||||
# ------------------------------------------
|
||||
# Output the K&R argument declarations.
|
||||
m4_define([b4_c_knr_formal_decls],
|
||||
[m4_map_sep([b4_c_knr_formal_decl],
|
||||
[
|
||||
],
|
||||
[$@])])
|
||||
|
||||
m4_define([b4_c_knr_formal_decl],
|
||||
[ $1;])
|
||||
|
||||
|
||||
|
||||
## ------------------------------------------------------------ ##
|
||||
## Declaring (prototyping) C functions in both K&R and ANSI-C. ##
|
||||
## ------------------------------------------------------------ ##
|
||||
## ----------------------- ##
|
||||
## Declaring C functions. ##
|
||||
## ----------------------- ##
|
||||
|
||||
|
||||
# b4_c_function_decl(NAME, RETURN-VALUE, [DECL1, NAME1], ...)
|
||||
# -----------------------------------------------------------
|
||||
# Declare the function NAME.
|
||||
m4_define([b4_c_function_decl],
|
||||
[#if b4_c_modern
|
||||
b4_c_ansi_function_decl($@)
|
||||
#else
|
||||
$2 $1 ();
|
||||
#endif[]dnl
|
||||
])
|
||||
|
||||
|
||||
# b4_c_ansi_function_decl(NAME, RETURN-VALUE, [DECL1, NAME1], ...)
|
||||
# ----------------------------------------------------------------
|
||||
# Declare the function NAME.
|
||||
m4_define([b4_c_ansi_function_decl],
|
||||
[$2 $1 (b4_c_ansi_formals(m4_shift2($@)));[]dnl
|
||||
[$2 $1 (b4_c_formals(m4_shift2($@)));[]dnl
|
||||
])
|
||||
|
||||
|
||||
@@ -479,8 +416,7 @@ b4_syncline([@oline@], [@ofile@])
|
||||
# b4_yydestruct_generate(FUNCTION-DECLARATOR)
|
||||
# -------------------------------------------
|
||||
# Generate the "yydestruct" function, which declaration is issued using
|
||||
# FUNCTION-DECLARATOR, which may be "b4_c_ansi_function_def" for ISO C
|
||||
# or "b4_c_function_def" for K&R.
|
||||
# FUNCTION-DECLARATOR, which may be "b4_c_function_def".
|
||||
m4_define_default([b4_yydestruct_generate],
|
||||
[[/*-----------------------------------------------.
|
||||
| Release the memory associated to this symbol. |
|
||||
@@ -513,8 +449,7 @@ m4_ifset([b4_parse_param], [, b4_parse_param]))[
|
||||
# b4_yy_symbol_print_generate(FUNCTION-DECLARATOR)
|
||||
# ------------------------------------------------
|
||||
# Generate the "yy_symbol_print" function, which declaration is issued using
|
||||
# FUNCTION-DECLARATOR, which may be "b4_c_ansi_function_def" for ISO C
|
||||
# or "b4_c_function_def" for K&R.
|
||||
# FUNCTION-DECLARATOR, which may be "b4_c_function_def".
|
||||
m4_define_default([b4_yy_symbol_print_generate],
|
||||
[[
|
||||
/*--------------------------------.
|
||||
|
||||
10
data/glr.c
10
data/glr.c
@@ -52,7 +52,7 @@ m4_ifndef([b4_pure_flag],
|
||||
# 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_c_ansi_formals(b4_parse_param)])])
|
||||
[m4_ifset([b4_parse_param], [, b4_c_formals(b4_parse_param)])])
|
||||
|
||||
|
||||
# b4_lex_param
|
||||
@@ -178,7 +178,7 @@ m4_define([b4_shared_declarations],
|
||||
]b4_percent_code_get([[requires]])[
|
||||
]b4_token_enums[
|
||||
]b4_declare_yylstype[
|
||||
]b4_c_ansi_function_decl(b4_prefix[parse], [int], b4_parse_param)[
|
||||
]b4_c_function_decl(b4_prefix[parse], [int], b4_parse_param)[
|
||||
]b4_percent_code_get([[provides]])[]dnl
|
||||
])
|
||||
|
||||
@@ -491,7 +491,7 @@ typedef enum { yyok, yyaccept, yyabort, yyerr } YYRESULTTAG;
|
||||
YYFPRINTF Args; \
|
||||
} while (YYID (0))
|
||||
|
||||
]b4_yy_symbol_print_generate([b4_c_ansi_function_def])[
|
||||
]b4_yy_symbol_print_generate([b4_c_function_def])[
|
||||
|
||||
# define YY_SYMBOL_PRINT(Title, Type, Value, Location) \
|
||||
do { \
|
||||
@@ -872,7 +872,7 @@ yyuserMerge (int yyn, YYSTYPE* yy0, YYSTYPE* yy1)
|
||||
|
||||
/* Bison grammar-table manipulation. */
|
||||
|
||||
]b4_yydestruct_generate([b4_c_ansi_function_def])[
|
||||
]b4_yydestruct_generate([b4_c_function_def])[
|
||||
|
||||
/** Number of symbols composing the right hand side of rule #RULE. */
|
||||
static inline int
|
||||
@@ -2276,7 +2276,7 @@ yyrecoverSyntaxError (yyGLRStack* yystackp]b4_user_formals[)
|
||||
| yyparse. |
|
||||
`----------*/
|
||||
|
||||
]b4_c_ansi_function_def([yyparse], [int], b4_parse_param)[
|
||||
]b4_c_function_def([yyparse], [int], b4_parse_param)[
|
||||
{
|
||||
int yyresult;
|
||||
yyGLRStack yystack;
|
||||
|
||||
@@ -71,7 +71,7 @@ m4_define([b4_yy_symbol_print_generate],
|
||||
| Print this symbol. |
|
||||
`--------------------*/
|
||||
|
||||
]b4_c_ansi_function_def([yy_symbol_print],
|
||||
]b4_c_function_def([yy_symbol_print],
|
||||
[static void],
|
||||
[[FILE *], []],
|
||||
[[int yytype], [yytype]],
|
||||
@@ -94,7 +94,7 @@ m4_append([b4_post_prologue],
|
||||
[b4_syncline([@oline@], [@ofile@])[
|
||||
]b4_yylloc_default_define[
|
||||
#define YYRHSLOC(Rhs, K) ((Rhs)[K].yystate.yyloc)
|
||||
]b4_c_ansi_function_decl([yyerror],
|
||||
]b4_c_function_decl([yyerror],
|
||||
[static void],b4_locations_if([
|
||||
[[const ]b4_namespace_ref::b4_parser_class_name[::location_type *yylocationp],
|
||||
[yylocationp]],])
|
||||
@@ -110,7 +110,7 @@ m4_append([b4_epilogue],
|
||||
| Report an error. |
|
||||
`------------------*/
|
||||
|
||||
]b4_c_ansi_function_def([yyerror],
|
||||
]b4_c_function_def([yyerror],
|
||||
[static void],b4_locations_if([
|
||||
[[const ]b4_namespace_ref::b4_parser_class_name[::location_type *yylocationp],
|
||||
[yylocationp]],])
|
||||
|
||||
12
data/yacc.c
12
data/yacc.c
@@ -366,10 +366,8 @@ typedef unsigned char yytype_uint8;
|
||||
|
||||
#ifdef YYTYPE_INT8
|
||||
typedef YYTYPE_INT8 yytype_int8;
|
||||
#elif ]b4_c_modern[
|
||||
typedef signed char yytype_int8;
|
||||
#else
|
||||
typedef short int yytype_int8;
|
||||
typedef signed char yytype_int8;
|
||||
#endif
|
||||
|
||||
#ifdef YYTYPE_UINT16
|
||||
@@ -389,7 +387,7 @@ typedef short int yytype_int16;
|
||||
# define YYSIZE_T __SIZE_TYPE__
|
||||
# elif defined size_t
|
||||
# define YYSIZE_T size_t
|
||||
# elif ! defined YYSIZE_T && ]b4_c_modern[
|
||||
# elif ! defined YYSIZE_T
|
||||
# include <stddef.h> /* INFRINGES ON USER NAME SPACE */
|
||||
# define YYSIZE_T size_t
|
||||
# else
|
||||
@@ -446,7 +444,7 @@ b4_push_if([], [b4_lac_if([], [[
|
||||
# define alloca _alloca
|
||||
# else
|
||||
# define YYSTACK_ALLOC alloca
|
||||
# if ! defined _ALLOCA_H && ! defined EXIT_SUCCESS && ]b4_c_modern[
|
||||
# if ! defined _ALLOCA_H && ! defined EXIT_SUCCESS
|
||||
# include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
|
||||
/* Use EXIT_SUCCESS as a witness for stdlib.h. */
|
||||
# ifndef EXIT_SUCCESS
|
||||
@@ -483,13 +481,13 @@ b4_push_if([], [b4_lac_if([], [[
|
||||
# endif
|
||||
# ifndef YYMALLOC
|
||||
# define YYMALLOC malloc
|
||||
# if ! defined malloc && ! defined EXIT_SUCCESS && ]b4_c_modern[
|
||||
# if ! defined malloc && ! defined EXIT_SUCCESS
|
||||
void *malloc (YYSIZE_T); /* INFRINGES ON USER NAME SPACE */
|
||||
# endif
|
||||
# endif
|
||||
# ifndef YYFREE
|
||||
# define YYFREE free
|
||||
# if ! defined free && ! defined EXIT_SUCCESS && ]b4_c_modern[
|
||||
# if ! defined free && ! defined EXIT_SUCCESS
|
||||
void free (void *); /* INFRINGES ON USER NAME SPACE */
|
||||
# endif
|
||||
# endif
|
||||
|
||||
Reference in New Issue
Block a user