[m4_bmatch([$3], [%glr-parser\|%parse-param], [$1], [$2])])
m4_pushdef([AT_NAME_PREFIX],
[m4_bmatch([$3], [%name-prefix ".*"],
- [m4_bregexp([$3], [name-prefix "\([^""]*\)"], [\1])],
+ [m4_bregexp([$3], [%name-prefix "\([^""]*\)"], [\1])],
[yy])])
m4_pushdef([AT_API_PREFIX],
-[m4_bmatch([$3], [%define api\.prefix ".*"],
- [m4_bregexp([$3], [%define api\.prefix "\([^""]*\)"], [\1])],
+[m4_bmatch([$3], [\(%define api\.prefix\|%name-prefix\) ".*"],
+ [m4_bregexp([$3], [\(%define api\.prefix\|%name-prefix\) "\([^""]*\)"], [\2])],
[yy])])
# yyerror receives the location if %location & %pure & (%glr or %parse-param).
m4_pushdef([AT_YYERROR_ARG_LOC_IF],
AT_PURE_LEX_IF(
[m4_pushdef([AT_LOC], [(*llocp)])
m4_pushdef([AT_VAL], [(*lvalp)])
- m4_pushdef([AT_LEX_FORMALS],
+ m4_pushdef([AT_YYLEX_FORMALS],
[YYSTYPE *lvalp[]AT_LOCATION_IF([, YYLTYPE *llocp])])
- m4_pushdef([AT_LEX_ARGS],
+ m4_pushdef([AT_YYLEX_ARGS],
[lvalp[]AT_LOCATION_IF([, llocp])])
m4_pushdef([AT_USE_LEX_ARGS],
[(void) lvalp;AT_LOCATION_IF([(void) llocp])])
- m4_pushdef([AT_LEX_PRE_FORMALS],
- [AT_LEX_FORMALS, ])
- m4_pushdef([AT_LEX_PRE_ARGS],
- [AT_LEX_ARGS, ])
+ m4_pushdef([AT_YYLEX_PRE_FORMALS],
+ [AT_YYLEX_FORMALS, ])
+ m4_pushdef([AT_YYLEX_PRE_ARGS],
+ [AT_YYLEX_ARGS, ])
],
[m4_pushdef([AT_LOC], [[(]AT_NAME_PREFIX[lloc)]])
m4_pushdef([AT_VAL], [[(]AT_NAME_PREFIX[lval)]])
- m4_pushdef([AT_LEX_FORMALS], [void])
- m4_pushdef([AT_LEX_ARGS], [])
+ m4_pushdef([AT_YYLEX_FORMALS], [void])
+ m4_pushdef([AT_YYLEX_ARGS], [])
m4_pushdef([AT_USE_LEX_ARGS], [])
- m4_pushdef([AT_LEX_PRE_FORMALS], [])
- m4_pushdef([AT_LEX_PRE_ARGS], [])
+ m4_pushdef([AT_YYLEX_PRE_FORMALS], [])
+ m4_pushdef([AT_YYLEX_PRE_ARGS], [])
])
# Handle the different types of location components.
# AT_BISON_OPTION_POPDEFS
# -----------------------
m4_define([AT_BISON_OPTION_POPDEFS],
-[m4_popdef([AT_LEX_PRE_ARGS])
-m4_popdef([AT_LEX_PRE_FORMALS])
+[m4_popdef([AT_YYLEX_PRE_ARGS])
+m4_popdef([AT_YYLEX_PRE_FORMALS])
m4_popdef([AT_USE_LEX_ARGS])
-m4_popdef([AT_LEX_ARGS])
-m4_popdef([AT_LEX_FORMALS])
+m4_popdef([AT_YYLEX_ARGS])
+m4_popdef([AT_YYLEX_FORMALS])
m4_popdef([AT_VAL])
m4_popdef([AT_LOC])
m4_popdef([AT_PURE_LEX_IF])
$2])
])
+# AT_YYLEX_PROTOTYPE
# AT_YYLEX_DECLARE_EXTERN
# AT_YYLEX_DECLARE
# AT_YYLEX_DEFINE(INPUT-STRING, [ACTION])
# ---------------------------------------
+m4_define([AT_YYLEX_PROTOTYPE],
+[int AT_API_PREFIX[]lex (]AT_YYLEX_FORMALS[)[]dnl
+])
+
m4_define([AT_YYLEX_DECLARE_EXTERN],
-[int AT_API_PREFIX[]lex (void);dnl
+[AT_YYLEX_PROTOTYPE;dnl
])
m4_define([AT_YYLEX_DECLARE],
m4_define([AT_YYLEX_DEFINE],
[[#include <stdlib.h> /* abort */
-static int
-]AT_API_PREFIX[lex (void)
+static
+]AT_YYLEX_PROTOTYPE[
{
static char const input[] = "$1";
static size_t toknum = 0;
}]dnl
])
+# AT_YYERROR_PROTOTYPE
# AT_YYERROR_DECLARE_EXTERN
# AT_YYERROR_DECLARE
# AT_YYERROR_DEFINE
# -------------------------
-# Beware that must be called inside a AT_BISON_OPTION_PUSHDEFS/POPDEFS
-# pair.
+# 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([YYLTYPE *llocp, ])[const char *msg]])[]dnl
+])
+
+m4_define([AT_YYERROR_PROTOTYPE],
+[m4_case(AT_LANG,
+[c], [[void ]AT_API_PREFIX[error (]AT_YYERROR_FORMALS[)]])[]dnl
+])
+
m4_define([AT_YYERROR_DECLARE_EXTERN],
[m4_case(AT_LANG,
-[c], [void AT_API_PREFIX[]error (const char *msg);])[]dnl
+[c], [AT_YYERROR_PROTOTYPE;])[]dnl
])
m4_define([AT_YYERROR_DECLARE],
m4_define([AT_YYERROR_DEFINE],
[m4_case(AT_LANG,
[c], [[#include <stdio.h>
-static void
-]AT_API_PREFIX[error (char const *msg)
+/* A C error reporting function. */
+static
+]AT_YYERROR_PROTOTYPE[
{
+]AT_YYERROR_SEES_LOC_IF([[
+ fprintf (stderr, "%d.%d",
+ ]AT_LOC_FIRST_LINE[, ]AT_LOC_FIRST_COLUMN[);
+ if (]AT_LOC_FIRST_LINE[ != ]AT_LOC_LAST_LINE[)
+ fprintf (stderr, "-%d.%d",
+ ]AT_LOC_LAST_LINE[, ]AT_LOC_LAST_COLUMN[ - 1);
+ else if (]AT_LOC_FIRST_COLUMN[ != ]AT_LOC_LAST_COLUMN[ - 1)
+ fprintf (stderr, "-%d",
+ ]AT_LOC_LAST_COLUMN[ - 1);
+ fprintf (stderr, ": ");]])[
fprintf (stderr, "%s\n", msg);
}]],
-[c++], [[void
-]AT_NAME_PREFIX[::parser::error (const yy::location &, std::string const &msg)
+[c++], [[/* A C++ error reporting function. */
+void
+]AT_NAME_PREFIX[::parser::error (const location_type& l, const std::string& m)
{
- std::cerr << msg << std::endl;
+ (void) l;
+ std::cerr << ]AT_LOCATION_IF([l << ": " << ])[m << std::endl;
}]],
-[java], [[public void yyerror (String msg)
-{
- System.err.println (msg);
-}]])])
+[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);
+ }]])])dnl
+])
## --------------- ##