[b4_int_type($1_min, $1_max)])
+## ------------------ ##
+## Decoding options. ##
+## ------------------ ##
+
+
+# b4_location_if(IF-TRUE, IF-FALSE)
+# ---------------------------------
+# Expand IF-TRUE, if locations are used, IF-FALSE otherwise.
+m4_define([b4_location_if],
+[m4_if(b4_locations_flag, [1],
+ [$1],
+ [$2])])
+
+
+# b4_pure_if(IF-TRUE, IF-FALSE)
+# -----------------------------
+# Expand IF-TRUE, if %pure-parser, IF-FALSE otherwise.
+m4_define([b4_pure_if],
+[m4_if(b4_pure, [1],
+ [$1],
+ [$2])])
+
+
+
## ------------------------- ##
## Assigning token numbers. ##
## ------------------------- ##
])
-## --------------------- ##
-## Calling C functions. ##
-## --------------------- ##
-
-
-# b4_c_function_call(NAME, RETURN-VALUE, [TYPE1, NAME1], ...)
-# -----------------------------------------------------------
-# Call the function NAME with arguments NAME1, NAME2 etc.
-m4_define([b4_c_function_call],
-[$1 (b4_c_args(m4_shiftn(2, $@)))[]dnl
-])
-
-
-# b4_c_args([TYPE1, NAME1], ...)
-# ------------------------------
-# Output the arguments NAME1, NAME2...
-m4_define([b4_c_args],
-[m4_map_sep([b4_c_arg], [, ], [$@])])
-
-m4_define([b4_c_arg],
-[$2])
-
-## ---------------------------------------------- ##
-## Declaring C functions in both K&R and ANSI-C. ##
-## ---------------------------------------------- ##
+## --------------------------------------------- ##
+## Defining C functions in both K&R and ANSI-C. ##
+## --------------------------------------------- ##
-# b4_c_function(NAME, RETURN-VALUE, [TYPE1, NAME1], ...)
-# ------------------------------------------------------
+# b4_c_function_def(NAME, RETURN-VALUE, [DECL1, NAME1], ...)
+# ----------------------------------------------------------
# Declare the function NAME.
-m4_define([b4_c_function],
-[$2
-#if defined (__STDC__) || defined (__cplusplus)
-$1 (b4_c_ansi_args(m4_shiftn(2, $@)))
+m4_define([b4_c_function_def],
+[#if defined (__STDC__) || defined (__cplusplus)
+b4_c_ansi_function_def($@)
#else
-$1 (b4_c_knr_arg_names(m4_shiftn(2, $@)))
-b4_c_knr_arg_decls(m4_shiftn(2, $@))
+$2
+$1 (b4_c_knr_formal_names(m4_shiftn(2, $@)))
+b4_c_knr_formal_decls(m4_shiftn(2, $@))
#endif[]dnl
])
-# b4_c_ansi_args([TYPE1, NAME1], ...)
-# -----------------------------------
+# 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_shiftn(2, $@)))[]dnl
+])
+
+
+# b4_c_ansi_formals([DECL1, 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_formals],
+[m4_case([$@],
+ [], [void],
+ [[]], [void],
+ [m4_map_sep([b4_c_ansi_formal], [, ], [$@])])])
-m4_define([b4_c_ansi_arg],
-[$1 $2])
+m4_define([b4_c_ansi_formal],
+[$1])
-# b4_c_knr_args([TYPE1, NAME1], ...)
-# ----------------------------------
+# b4_c_knr_formal_names([DECL1, 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_formal_names],
+[m4_map_sep([b4_c_knr_formal_name], [, ], [$@])])
-m4_define([b4_c_knr_arg_name],
+m4_define([b4_c_knr_formal_name],
[$2])
-# b4_c_knr_args([TYPE1, NAME1], ...)
-# ----------------------------------
+# b4_c_knr_formal_decls([DECL1, 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_formal_decls],
+[m4_map_sep([b4_c_knr_formal_decl],
[
],
[$@])])
-m4_define([b4_c_knr_arg_decl],
-[ $1 $2;])
+m4_define([b4_c_knr_formal_decl],
+[ $1;])
-## ------------------ ##
-## Decoding options. ##
-## ------------------ ##
+## ------------------------------------------------------------ ##
+## Declaring (prototyping) C functions in both K&R and ANSI-C. ##
+## ------------------------------------------------------------ ##
-# b4_location_if(IF-TRUE, IF-FALSE)
-# ---------------------------------
-# Expand IF-TRUE, if locations are used, IF-FALSE otherwise.
-m4_define([b4_location_if],
-[m4_if(b4_locations_flag, [1],
- [$1],
- [$2])])
+# b4_c_function_decl(NAME, RETURN-VALUE, [DECL1, NAME1], ...)
+# -----------------------------------------------------------
+# Declare the function NAME.
+m4_define([b4_c_function_decl],
+[#if defined (__STDC__) || defined (__cplusplus)
+b4_c_ansi_function_decl($@)
+#else
+$2 $1 ();
+#endif[]dnl
+])
-# b4_pure_if(IF-TRUE, IF-FALSE)
-# -----------------------------
-# Expand IF-TRUE, if %pure-parser, IF-FALSE otherwise.
-m4_define([b4_pure_if],
-[m4_if(b4_pure, [1],
- [$1],
- [$2])])
+# 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_shiftn(2, $@)));[]dnl
+])
+
+
+
+
+## --------------------- ##
+## Calling C functions. ##
+## --------------------- ##
+
+
+# b4_c_function_call(NAME, RETURN-VALUE, [DECL1, NAME1], ...)
+# -----------------------------------------------------------
+# Call the function NAME with arguments NAME1, NAME2 etc.
+m4_define([b4_c_function_call],
+[$1 (b4_c_args(m4_shiftn(2, $@)))[]dnl
+])
+
+
+# b4_c_args([DECL1, NAME1], ...)
+# ------------------------------
+# Output the arguments NAME1, NAME2...
+m4_define([b4_c_args],
+[m4_map_sep([b4_c_arg], [, ], [$@])])
+
+m4_define([b4_c_arg],
+[$2])
b4_location_if([, [[YYLTYPE *], [&yylloc]]])])dnl
m4_ifdef([b4_lex_param], [, ]b4_lex_param)))
+# Yes, this is quite ugly...
+m4_define_default([b4_parse_param])
+m4_ifdef([b4_parse_param],
+[m4_define([b4_parse_param],
+ b4_parse_param)])
+
## ----------------- ##
## Semantic Values. ##
| Print this symbol on YYOUT. |
`-----------------------------*/
-b4_c_function([yysymprint],
- [static void],
- [[FILE*], [yyout]],
- [[int], [yytype]],
- [[YYSTYPE], [yyvalue]]b4_location_if([,
- [[YYLTYPE], [yylocation]]]))
+b4_c_function_def([yysymprint],
+ [static void],
+ [[FILE *yyout], [yyout]],
+ [[int yytype], [yytype]],
+ [[YYSTYPE yyvalue], [yyvalue]]b4_location_if([,
+ [[YYLTYPE yylocation], [yylocation]]]))
{
/* Pacify ``unused variable'' warnings. */
(void) yyvalue;
| Release the memory associated to this symbol. |
`-----------------------------------------------*/
-b4_c_function([yydestruct],
- [static void],
- [[int], [yytype]],
- [[YYSTYPE], [yyvalue]]b4_location_if([,
- [[YYLTYPE], [yylocation]]]))
+b4_c_function_def([yydestruct],
+ [static void],
+ [[int yytype], [yytype]],
+ [[YYSTYPE yyvalue], [yyvalue]]b4_location_if([,
+ [[YYLTYPE yylocation], [yylocation]]]))
{
/* Pacify ``unused variable'' warnings. */
(void) yyvalue;
\f
-/* 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. */
+/* Prevent warnings from -Wmissing-prototypes. */
#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 *);
+int yyparse (void *YYPARSE_PARAM);
# else
-int yyparse (void);
+int yyparse ();
# endif
+#else /* ! YYPARSE_PARAM */
+b4_c_function_decl([yyparse], [int], b4_parse_param)
#endif
+
m4_divert_push([KILL])# ======================== M4 code.
# b4_declare_parser_variables
# ---------------------------
# Declare the variables that are global, or local to YYPARSE if
-# pure-parser
+# pure-parser.
m4_define([b4_declare_parser_variables],
[/* The lookahead symbol. */
int yychar;
b4_pure_if([],
[b4_declare_parser_variables])
-int
-yyparse (YYPARSE_PARAM_ARG)
- YYPARSE_PARAM_DECL
+
+/*----------.
+| yyparse. |
+`----------*/
+
+#ifdef YYPARSE_PARAM
+# if defined (__STDC__) || defined (__cplusplus)
+int yyparse (void *YYPARSE_PARAM)
+# else
+int yyparse (YYPARSE_PARAM)
+ void *YYPARSE_PARAM;
+# endif
+#else /* ! YYPARSE_PARAM */
+b4_c_function_def([yyparse], [int], b4_parse_param)
+#endif
{[
]b4_pure_if([b4_declare_parser_variables])[
register int yystate;