m4_pushdef([AT_CALC_LEX],
[[#include <ctype.h>
-int ]AT_NAME_PREFIX[lex (]AT_LEX_FORMALS[);
-static int get_char (]AT_LEX_FORMALS[);
-static void unget_char (]AT_LEX_PRE_FORMALS[ int c);
+]AT_YYLEX_DECLARE_EXTERN[
+static int get_char (]AT_YYLEX_FORMALS[);
+static void unget_char (]AT_YYLEX_PRE_FORMALS[ int c);
]AT_LOCATION_IF([
static YYLTYPE last_yylloc;
])[
static int
-get_char (]AT_LEX_FORMALS[)
+get_char (]AT_YYLEX_FORMALS[)
{
int res = getc (input);
]AT_USE_LEX_ARGS[;
}
static void
-unget_char (]AT_LEX_PRE_FORMALS[ int c)
+unget_char (]AT_YYLEX_PRE_FORMALS[ int c)
{
]AT_USE_LEX_ARGS[;
]AT_LOCATION_IF([
}
static int
-read_signed_integer (]AT_LEX_FORMALS[)
+read_signed_integer (]AT_YYLEX_FORMALS[)
{
- int c = get_char (]AT_LEX_ARGS[);
+ int c = get_char (]AT_YYLEX_ARGS[);
int sign = 1;
int n = 0;
]AT_USE_LEX_ARGS[;
if (c == '-')
{
- c = get_char (]AT_LEX_ARGS[);
+ c = get_char (]AT_YYLEX_ARGS[);
sign = -1;
}
while (isdigit (c))
{
n = 10 * n + (c - '0');
- c = get_char (]AT_LEX_ARGS[);
+ c = get_char (]AT_YYLEX_ARGS[);
}
- unget_char (]AT_LEX_PRE_ARGS[ c);
+ unget_char (]AT_YYLEX_PRE_ARGS[ c);
return sign * n;
}
| blanks and tabs, returns 0 for EOF. |
`---------------------------------------------------------------*/
-int
-]AT_NAME_PREFIX[lex (]AT_LEX_FORMALS[)
+]AT_YYLEX_PROTOTYPE[
{
static int init = 1;
int c;
AT_LOC_FIRST_LINE = AT_LOC_LAST_LINE;
])[
}
- while ((c = get_char (]AT_LEX_ARGS[)) == ' ' || c == '\t');
+ while ((c = get_char (]AT_YYLEX_ARGS[)) == ' ' || c == '\t');
/* process numbers */
if (c == '.' || isdigit (c))
{
- unget_char (]AT_LEX_PRE_ARGS[ c);
- ]AT_VAL[.ival = read_signed_integer (]AT_LEX_ARGS[);
+ unget_char (]AT_YYLEX_PRE_ARGS[ c);
+ ]AT_VAL[.ival = read_signed_integer (]AT_YYLEX_ARGS[);
return NUM;
}
static int power (int base, int exponent);
]AT_SKEL_CC_IF(,
-[/* yyerror receives the location if:
- - %location & %pure & %glr
- - %location & %pure & %yacc & %parse-param. */
-static void yyerror (AT_YYERROR_ARG_LOC_IF([YYLTYPE *llocp, ])
+[static void yyerror (AT_YYERROR_ARG_LOC_IF([YYLTYPE *llocp, ])
AT_PARAM_IF([semantic_value *result, int *count, ])
const char *s
);])[
-int yylex (]AT_LEX_FORMALS[);
+]AT_YYLEX_DECLARE_EXTERN[
}
]AT_SKEL_CC_IF([AT_LOCATION_TYPE_IF([], [
[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 (]AT_LEX_FORMALS[);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 (]AT_LEX_FORMALS[)
+static
+]AT_YYLEX_PROTOTYPE[
{
static char const input[] = "$1";
static size_t toknum = 0;
# 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([YYLTYPE *llocp, ])[const char *msg]])[]dnl
+])
+
m4_define([AT_YYERROR_PROTOTYPE],
[m4_case(AT_LANG,
-[c], [[void ]AT_API_PREFIX[error (]AT_YYERROR_ARG_LOC_IF([YYLTYPE *llocp, ])[const char *msg)]])[]dnl
+[c], [[void ]AT_API_PREFIX[error (]AT_YYERROR_FORMALS[)]])[]dnl
])
m4_define([AT_YYERROR_DECLARE_EXTERN],