* tests/local.at (AT_LEX_FORMALS, AT_LEX_ARGS, AT_LEX_PRE_FORMALS)
(AT_LEX_PRE_ARGS): Rename as...
(AT_YYLEX_FORMALS, AT_YYLEX_ARGS, AT_YYLEX_PRE_FORMALS)
(AT_YYLEX_PRE_ARGS): these, for consistency.
(AT_API_PREFIX): Take %name-prefix into account.
(AT_YYLEX_PROTOTYPE): New.
Use it.
* tests/actions.at, tests/calc.at, tests/cxx-type.at: Adjust to
use them.
}])
AT_LALR1_CC_IF([%define global_tokens_and_yystype])
m4_ifval([$6], [[%code provides {]], [[%code {]])
}])
AT_LALR1_CC_IF([%define global_tokens_and_yystype])
m4_ifval([$6], [[%code provides {]], [[%code {]])
-AT_LALR1_CC_IF([typedef yy::location YYLTYPE;])
-[static int yylex (]AT_LEX_FORMALS[);
+AT_LALR1_CC_IF([typedef yy::location YYLTYPE;])[
+]AT_YYLEX_DECLARE[
]AT_LALR1_CC_IF([], [AT_YYERROR_DECLARE])
[}
]AT_LALR1_CC_IF([], [AT_YYERROR_DECLARE])
[}
/* Alias to ARGV[1]. */
const char *source = YY_NULL;
/* Alias to ARGV[1]. */
const char *source = YY_NULL;
-static int
-yylex (]AT_LEX_FORMALS[)
+static
+]AT_YYLEX_PROTOTYPE[
{
static unsigned int counter = 0;
{
static unsigned int counter = 0;
m4_pushdef([AT_CALC_LEX],
[[#include <ctype.h>
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
]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[;
{
int res = getc (input);
]AT_USE_LEX_ARGS[;
-unget_char (]AT_LEX_PRE_FORMALS[ int c)
+unget_char (]AT_YYLEX_PRE_FORMALS[ int c)
{
]AT_USE_LEX_ARGS[;
]AT_LOCATION_IF([
{
]AT_USE_LEX_ARGS[;
]AT_LOCATION_IF([
-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 == '-')
{
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');
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);
| blanks and tabs, returns 0 for EOF. |
`---------------------------------------------------------------*/
| blanks and tabs, returns 0 for EOF. |
`---------------------------------------------------------------*/
-int
-]AT_NAME_PREFIX[lex (]AT_LEX_FORMALS[)
{
static int init = 1;
int c;
{
static int init = 1;
int c;
AT_LOC_FIRST_LINE = AT_LOC_LAST_LINE;
])[
}
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))
{
/* 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[);
static int power (int base, int exponent);
]AT_SKEL_CC_IF(,
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
);])[
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([], [
}
]AT_SKEL_CC_IF([AT_LOCATION_TYPE_IF([], [
-int
-yylex (]AT_LEX_FORMALS[)
{
char buffer[256];
int c;
{
char buffer[256];
int c;
[m4_bmatch([$3], [%glr-parser\|%parse-param], [$1], [$2])])
m4_pushdef([AT_NAME_PREFIX],
[m4_bmatch([$3], [%name-prefix ".*"],
[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],
[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],
[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)])
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])])
[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])])
[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_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_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.
])
# Handle the different types of location components.
# AT_BISON_OPTION_POPDEFS
# -----------------------
m4_define([AT_BISON_OPTION_POPDEFS],
# 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_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])
m4_popdef([AT_VAL])
m4_popdef([AT_LOC])
m4_popdef([AT_PURE_LEX_IF])
# AT_YYLEX_DECLARE_EXTERN
# AT_YYLEX_DECLARE
# AT_YYLEX_DEFINE(INPUT-STRING, [ACTION])
# ---------------------------------------
# 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],
m4_define([AT_YYLEX_DECLARE_EXTERN],
-[int AT_API_PREFIX[]lex (]AT_LEX_FORMALS[);dnl
])
m4_define([AT_YYLEX_DECLARE],
])
m4_define([AT_YYLEX_DECLARE],
m4_define([AT_YYLEX_DEFINE],
[[#include <stdlib.h> /* abort */
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;
{
static char const input[] = "$1";
static size_t toknum = 0;
# AT_YYERROR_DEFINE
# -------------------------
# Must be called inside a AT_BISON_OPTION_PUSHDEFS/POPDEFS pair.
# 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,
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],
])
m4_define([AT_YYERROR_DECLARE_EXTERN],