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;])
\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. */
-
-#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
/*-----------------------------.
| Print this symbol on YYOUT. |
`-----------------------------*/
-static void
-#if defined (__STDC__) || defined (__cplusplus)
-yysymprint (FILE* yyout, int yytype,
- YYSTYPE yyvalue[]b4_location_if([, YYLTYPE yylocation]))
-#else
-yysymprint (yyout, yytype,
- yyvalue[]b4_location_if([, yylocation]))
- FILE* yyout;
- int yytype;
- YYSTYPE yyvalue;
- b4_location_if([YYLTYPE yylocation;])
-#endif
+b4_c_function([yysymprint],
+ [static void],
+ [[FILE*], [yyout]],
+ [[int], [yytype]],
+ [[YYSTYPE], [yyvalue]]b4_location_if([,
+ [[YYLTYPE], [yylocation]]]))
{
/* Pacify ``unused variable'' warnings. */
(void) yyvalue;
| yyreport_parse_error -- report a parse error in YYSTATE. |
`----------------------------------------------------------*/
-static void
-#if defined (__STDC__) || defined (__cplusplus)
-yyreport_parse_error (int yystate, int yychar,
- YYSTYPE yyvalue[]b4_location_if([, YYLTYPE yylocation]))
-#else
-yyreport_parse_error (yystate, yychar,
- yyvalue[]b4_location_if([, yylocation]))
- int yystate;
- int yychar;
- YYSTYPE yyvalue;
- b4_location_if([YYLTYPE yylocation;])
-#endif
+b4_c_function([yyreport_parse_error],
+ [static void],
+ [[int], [yystate]],
+ [[int], [yychar]],
+ [[YYSTYPE], [yyvalue]]b4_location_if([,
+ [[YYLTYPE], [yylocation]]]))
[{
#if YYERROR_VERBOSE
int yyn = yypact[yystate];
| Release the memory associated to this symbol. |
`-----------------------------------------------*/
-static void
-#if defined (__STDC__) || defined (__cplusplus)
-yydestruct (int yytype,
- YYSTYPE yyvalue[]b4_location_if([, YYLTYPE yylocation]))
-#else
-yydestruct (yytype,
- yyvalue[]b4_location_if([, yylocation]))
- int yytype;
- YYSTYPE yyvalue;
- b4_location_if([YYLTYPE yylocation;])
-#endif
+b4_c_function([yydestruct],
+ [static void],
+ [[int], [yytype]],
+ [[YYSTYPE], [yyvalue]]b4_location_if([,
+ [[YYLTYPE], [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. */
+
+#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.
# b4_declare_parser_variables