+# AT_YYLEX_PROTOTYPE
+# AT_YYLEX_DECLARE_EXTERN
+# AT_YYLEX_DECLARE
+# AT_YYLEX_DEFINE([INPUT], [ACTION])
+# ----------------------------------
+# INPUT can be empty, or in double quotes, or a list (in braces).
+# ACTION may compute yylval for instance, using "res" as token type,
+# and "toknum" as the number of calls to yylex (starting at 0).
+m4_define([AT_YYLEX_PROTOTYPE],
+[int AT_NAME_PREFIX[]lex (]AT_YYLEX_FORMALS[)[]dnl
+])
+
+m4_define([AT_YYLEX_DECLARE_EXTERN],
+[AT_YYLEX_PROTOTYPE;dnl
+])
+
+m4_define([AT_YYLEX_DECLARE],
+[static AT_YYLEX_DECLARE_EXTERN[]dnl
+])
+
+m4_define([AT_YYLEX_DEFINE],
+[[#include <assert.h>
+static
+]AT_YYLEX_PROTOTYPE[
+{
+ ]m4_bmatch([$1], [^\(".*"\)?$],
+ [[static char const input[] = ]m4_default([$1], [""])],
+ [[static int const input[] = ]$1])[;
+ static size_t toknum = 0;
+ int res;
+ ]AT_USE_LEX_ARGS[;
+ assert (toknum < sizeof input / sizeof input[0]);
+ res = input[toknum++];
+ ]$2[;]AT_LOCATION_IF([[
+ ]AT_LOC_FIRST_LINE[ = ]AT_LOC_LAST_LINE[ = 1;
+ ]AT_LOC_FIRST_COLUMN[ = ]AT_LOC_LAST_COLUMN[ = toknum;]])[
+ return res;
+}]dnl
+])
+
+# AT_YYERROR_FORMALS
+# AT_YYERROR_PROTOTYPE
+# AT_YYERROR_DECLARE_EXTERN
+# AT_YYERROR_DECLARE
+# AT_YYERROR_DEFINE
+# -------------------------
+# Must be called inside a AT_BISON_OPTION_PUSHDEFS/POPDEFS pair.
+m4_define([AT_YYERROR_FORMALS],
+[m4_case(AT_LANG,
+[c], [AT_YYERROR_ARG_LOC_IF([AT_YYLTYPE const * const llocp, ])AT_PARSE_PARAMS [const char *msg]])[]dnl
+])
+
+m4_define([AT_YYERROR_PROTOTYPE],
+[m4_case(AT_LANG,
+[c], [[void ]AT_NAME_PREFIX[error (]AT_YYERROR_FORMALS[)]])[]dnl
+])
+
+m4_define([AT_YYERROR_DECLARE_EXTERN],
+[m4_case(AT_LANG,
+[c], [AT_YYERROR_PROTOTYPE;])[]dnl
+])
+
+m4_define([AT_YYERROR_DECLARE],
+[m4_case(AT_LANG,
+[c], [static AT_YYERROR_DECLARE_EXTERN])[]dnl
+])
+
+m4_define([AT_YYERROR_DEFINE],
+[m4_case(AT_LANG,
+[c], [[#include <stdio.h>
+/* A C error reporting function. */
+static
+]AT_YYERROR_PROTOTYPE[
+{]m4_bpatsubst(m4_defn([AT_PARSE_PARAMS]),
+ [[^,]+[^A-Za-z_0-9]\([A-Za-z_][A-Za-z_0-9]*\), *], [
+ YYUSE(\1);])dnl
+AT_YYERROR_SEES_LOC_IF([[
+ YY_LOCATION_PRINT (stderr, ]AT_LOC[);
+ fprintf (stderr, ": ");]])[
+ fprintf (stderr, "%s\n", msg);
+}]],
+[c++], [[/* A C++ error reporting function. */
+void
+]AT_NAME_PREFIX[::parser::error (]AT_LOCATION_IF([[const location_type& l, ]])[const std::string& m)
+{ std::cerr << ]AT_LOCATION_IF([l << ": " << ])[m << std::endl;
+}]],
+[java], [AT_LOCATION_IF([[public void yyerror (Calc.Location l, String s)
+{
+ if (l == null)
+ System.err.println (s);
+ else
+ System.err.println (l + ": " + s);
+ }
+]], [[
+ public void yyerror (String s)
+ {
+ System.err.println (s);
+ }]])],
+[m4_fatal([$0: invalid language: ]AT_LANG)])dnl
+])
+
+
+## --------------- ##
+## Running Bison. ##
+## --------------- ##
+