+
+m4_pushdef([AT_CALC_MAIN],
+[#include <assert.h>
+#if HAVE_UNISTD_H
+# include <unistd.h>
+#else
+# undef alarm
+# define alarm(seconds) /* empty */
+#endif
+
+AT_SKEL_CC_IF([[
+/* A C++ ]AT_NAME_PREFIX[parse that simulates the C signature. */
+int
+]AT_NAME_PREFIX[parse (]AT_PARAM_IF([semantic_value *result, int *count]))[
+{
+ ]AT_NAME_PREFIX[::parser parser]AT_PARAM_IF([ (result, count)])[;
+#if YYDEBUG
+ parser.set_debug_level (1);
+#endif
+ return parser.parse ();
+}
+]])[
+
+semantic_value global_result = 0;
+int global_count = 0;
+
+/* A C main function. */
+int
+main (int argc, const char **argv)
+{
+ semantic_value result = 0;
+ int count = 0;
+ int status;
+
+ /* This used to be alarm (10), but that isn't enough time for
+ a July 1995 vintage DEC Alphastation 200 4/100 system,
+ according to Nelson H. F. Beebe. 100 seconds is enough. */
+ alarm (100);
+
+ if (argc == 2)
+ input = fopen (argv[1], "r");
+ else
+ input = stdin;
+
+ if (!input)
+ {
+ perror (argv[1]);
+ return 3;
+ }
+
+]AT_SKEL_CC_IF([], [m4_bmatch([$4], [%debug],
+[ ]AT_NAME_PREFIX[debug = 1;])])[
+ status = ]AT_NAME_PREFIX[parse (]AT_PARAM_IF([[&result, &count]])[);
+ if (fclose (input))
+ perror ("fclose");
+ assert (global_result == result);
+ assert (global_count == count);
+ return status;
+}
+]])
+
+