mirror of
https://git.savannah.gnu.org/git/bison.git
synced 2026-03-09 04:13:03 +00:00
c: rename yyparse_context_t as yypcontext_t
The first name is too long. We already have `yypstate`, so `yypcontext` is ok. We are also migrating to using `*_t` for our types. * NEWS, data/skeletons/glr.c, data/skeletons/yacc.c, doc/bison.texi, * examples/c/bistromathic/parse.y, src/parse-gram.y, tests/local.at: (yyparse_context_t, yyparse_context_location, yyparse_context_token): Rename as... (yypcontext_t, yypcontext_location, yypcontext_token): these.
This commit is contained in:
4
NEWS
4
NEWS
@@ -37,14 +37,14 @@ GNU Bison NEWS
|
||||
herself by defining a function such as:
|
||||
|
||||
int
|
||||
yyreport_syntax_error (const yyparse_context_t *ctx)
|
||||
yyreport_syntax_error (const yypcontext_t *ctx)
|
||||
{
|
||||
enum { ARGMAX = 10 };
|
||||
int arg[ARGMAX];
|
||||
int n = yysyntax_error_arguments (ctx, arg, ARGMAX);
|
||||
if (n == -2)
|
||||
return 2; // Memory exhausted.
|
||||
YY_LOCATION_PRINT (stderr, *yyparse_context_location (ctx));
|
||||
YY_LOCATION_PRINT (stderr, *yypcontext_location (ctx));
|
||||
fprintf (stderr, ": syntax error");
|
||||
for (int i = 1; i < n; ++i)
|
||||
fprintf (stderr, " %s %s",
|
||||
|
||||
@@ -2123,16 +2123,16 @@ yyexpected_tokens (const yyGLRStack* yystackp,
|
||||
]b4_parse_error_bmatch(
|
||||
[custom],
|
||||
[[/* User defined function to report a syntax error. */
|
||||
typedef yyGLRStack yyparse_context_t;
|
||||
typedef yyGLRStack yypcontext_t;
|
||||
static int
|
||||
yyreport_syntax_error (const yyGLRStack* yystackp]b4_user_formals[);
|
||||
|
||||
/* The token type of the lookahead of this context. */
|
||||
static yysymbol_type_t
|
||||
yyparse_context_token (const yyGLRStack *yystackp) YY_ATTRIBUTE_UNUSED;
|
||||
yypcontext_token (const yyGLRStack *yystackp) YY_ATTRIBUTE_UNUSED;
|
||||
|
||||
static yysymbol_type_t
|
||||
yyparse_context_token (const yyGLRStack *yystackp)
|
||||
yypcontext_token (const yyGLRStack *yystackp)
|
||||
{
|
||||
YYUSE (yystackp);
|
||||
yysymbol_type_t yytoken = yychar == YYEMPTY ? YYSYMBOL_YYEMPTY : YYTRANSLATE (yychar);
|
||||
@@ -2141,10 +2141,10 @@ yyparse_context_token (const yyGLRStack *yystackp)
|
||||
|
||||
]b4_locations_if([[/* The location of the lookahead of this context. */
|
||||
static YYLTYPE *
|
||||
yyparse_context_location (const yyGLRStack *yystackp) YY_ATTRIBUTE_UNUSED;
|
||||
yypcontext_location (const yyGLRStack *yystackp) YY_ATTRIBUTE_UNUSED;
|
||||
|
||||
static YYLTYPE *
|
||||
yyparse_context_location (const yyGLRStack *yystackp)
|
||||
yypcontext_location (const yyGLRStack *yystackp)
|
||||
{
|
||||
YYUSE (yystackp);
|
||||
return &yylloc;
|
||||
|
||||
@@ -1132,7 +1132,7 @@ typedef struct
|
||||
YYPTRDIFF_T *yyes_capacity;]])])[
|
||||
yysymbol_type_t yytoken;]b4_locations_if([[
|
||||
YYLTYPE *yylloc;]])[
|
||||
} yyparse_context_t;
|
||||
} yypcontext_t;
|
||||
|
||||
/* Put in YYARG at most YYARGN of the expected tokens given the
|
||||
current YYCTX, and return the number of tokens stored in YYARG. If
|
||||
@@ -1144,7 +1144,7 @@ static int
|
||||
yypstate_expected_tokens (yypstate *yyps,
|
||||
yysymbol_type_t yyarg[], int yyargn)]], [[
|
||||
static int
|
||||
yyexpected_tokens (const yyparse_context_t *yyctx,
|
||||
yyexpected_tokens (const yypcontext_t *yyctx,
|
||||
yysymbol_type_t yyarg[], int yyargn)]])[
|
||||
{
|
||||
/* Actual size of YYARG. */
|
||||
@@ -1200,7 +1200,7 @@ yyexpected_tokens (const yyparse_context_t *yyctx,
|
||||
]b4_push_if([[
|
||||
/* Similar to the previous function. */
|
||||
static int
|
||||
yyexpected_tokens (const yyparse_context_t *yyctx,
|
||||
yyexpected_tokens (const yypcontext_t *yyctx,
|
||||
yysymbol_type_t yyarg[], int yyargn)
|
||||
{
|
||||
return yypstate_expected_tokens (yyctx->yyps, yyarg, yyargn);
|
||||
@@ -1211,27 +1211,27 @@ yyexpected_tokens (const yyparse_context_t *yyctx,
|
||||
[custom],
|
||||
[[/* The token type of the lookahead of this context. */
|
||||
static yysymbol_type_t
|
||||
yyparse_context_token (const yyparse_context_t *yyctx) YY_ATTRIBUTE_UNUSED;
|
||||
yypcontext_token (const yypcontext_t *yyctx) YY_ATTRIBUTE_UNUSED;
|
||||
|
||||
static yysymbol_type_t
|
||||
yyparse_context_token (const yyparse_context_t *yyctx)
|
||||
yypcontext_token (const yypcontext_t *yyctx)
|
||||
{
|
||||
return yyctx->yytoken;
|
||||
}
|
||||
|
||||
]b4_locations_if([[/* The location of the lookahead of this context. */
|
||||
static YYLTYPE *
|
||||
yyparse_context_location (const yyparse_context_t *yyctx) YY_ATTRIBUTE_UNUSED;
|
||||
yypcontext_location (const yypcontext_t *yyctx) YY_ATTRIBUTE_UNUSED;
|
||||
|
||||
static YYLTYPE *
|
||||
yyparse_context_location (const yyparse_context_t *yyctx)
|
||||
yypcontext_location (const yypcontext_t *yyctx)
|
||||
{
|
||||
return yyctx->yylloc;
|
||||
}]])[
|
||||
|
||||
/* User defined function to report a syntax error. */
|
||||
static int
|
||||
yyreport_syntax_error (const yyparse_context_t *yyctx]b4_user_formals[);]],
|
||||
yyreport_syntax_error (const yypcontext_t *yyctx]b4_user_formals[);]],
|
||||
[detailed\|verbose],
|
||||
[[#ifndef yystrlen
|
||||
# if defined __GLIBC__ && defined _STRING_H
|
||||
@@ -1323,7 +1323,7 @@ yytnamerr (char *yyres, const char *yystr)
|
||||
]])[
|
||||
|
||||
static int
|
||||
yysyntax_error_arguments (const yyparse_context_t *yyctx,
|
||||
yysyntax_error_arguments (const yypcontext_t *yyctx,
|
||||
yysymbol_type_t yyarg[], int yyargn)
|
||||
{
|
||||
/* Actual size of YYARG. */
|
||||
@@ -1384,7 +1384,7 @@ yysyntax_error_arguments (const yyparse_context_t *yyctx,
|
||||
yy_lac returned YYNOMEM]])[. */
|
||||
static int
|
||||
yysyntax_error (YYPTRDIFF_T *yymsg_alloc, char **yymsg,
|
||||
const yyparse_context_t *yyctx)
|
||||
const yypcontext_t *yyctx)
|
||||
{
|
||||
enum { YYARGS_MAX = 5 };
|
||||
/* Internationalized format string. */
|
||||
@@ -1906,7 +1906,7 @@ yyerrlab:
|
||||
]b4_parse_error_case(
|
||||
[custom],
|
||||
[[ {
|
||||
yyparse_context_t yyctx
|
||||
yypcontext_t yyctx
|
||||
= {]b4_push_if([[yyps]], [[yyssp]b4_lac_if([[, yyesa, &yyes, &yyes_capacity]])])[, yytoken]b4_locations_if([[, &yylloc]])[};]b4_lac_if([[
|
||||
if (yychar != YYEMPTY)
|
||||
YY_LAC_ESTABLISH;]])[
|
||||
@@ -1917,7 +1917,7 @@ yyerrlab:
|
||||
[simple],
|
||||
[[ yyerror (]b4_yyerror_args[YY_("syntax error"));]],
|
||||
[[ {
|
||||
yyparse_context_t yyctx
|
||||
yypcontext_t yyctx
|
||||
= {]b4_push_if([[yyps]], [[yyssp]b4_lac_if([[, yyesa, &yyes, &yyes_capacity]])])[, yytoken]b4_locations_if([[, &yylloc]])[};
|
||||
char const *yymsgp = YY_("syntax error");
|
||||
int yysyntax_error_status;]b4_lac_if([[
|
||||
|
||||
@@ -7396,19 +7396,19 @@ Declarations}), then the parser no longer passes syntax error messages to
|
||||
@code{yyerror}, rather it leaves that task to the user by calling the
|
||||
@code{yyreport_syntax_error} function.
|
||||
|
||||
@deftypefun int yyreport_syntax_error (@code{const yyparse_context_t *}@var{ctx})
|
||||
@deftypefun int yyreport_syntax_error (@code{const yypcontext_t *}@var{ctx})
|
||||
Report a syntax error to the user. Return 0 on success, 2 on memory
|
||||
exhaustion. Whether it uses @code{yyerror} is up to the user.
|
||||
@end deftypefun
|
||||
|
||||
Use the following functions to build the error message.
|
||||
|
||||
@deftypefun {YYLTYPE *} yyparse_context_location (@code{const yyparse_context_t *}@var{ctx})
|
||||
@deftypefun {YYLTYPE *} yypcontext_location (@code{const yypcontext_t *}@var{ctx})
|
||||
The location of the syntax error.
|
||||
@end deftypefun
|
||||
|
||||
|
||||
@deftypefun int yysyntax_error_arguments (@code{const yyparse_context_t *}ctx, @code{int} @var{argv}@code{[]}, @code{int} @var{argc})
|
||||
@deftypefun int yysyntax_error_arguments (@code{const yypcontext_t *}ctx, @code{int} @var{argv}@code{[]}, @code{int} @var{argc})
|
||||
Fill @var{argv} with first the internal number of the token that caused the
|
||||
error, then the internal numbers of the expected tokens. Never put more
|
||||
than @var{argc} elements into @var{argv}, and on success return the
|
||||
@@ -7428,7 +7428,7 @@ A custom syntax error function looks as follows.
|
||||
|
||||
@example
|
||||
int
|
||||
yyreport_syntax_error (const yyparse_context_t *ctx)
|
||||
yyreport_syntax_error (const yypcontext_t *ctx)
|
||||
@{
|
||||
enum @{ ARGMAX = 10 @};
|
||||
int arg[ARGMAX];
|
||||
|
||||
@@ -282,10 +282,10 @@ yylex (const char **line, YYSTYPE *yylval, YYLTYPE *yylloc)
|
||||
`---------*/
|
||||
|
||||
int
|
||||
yyreport_syntax_error (const yyparse_context_t *ctx)
|
||||
yyreport_syntax_error (const yypcontext_t *ctx)
|
||||
{
|
||||
int res = 0;
|
||||
YY_LOCATION_PRINT (stderr, *yyparse_context_location (ctx));
|
||||
YY_LOCATION_PRINT (stderr, *yypcontext_location (ctx));
|
||||
fprintf (stderr, ": syntax error");
|
||||
{
|
||||
enum { TOKENMAX = 10 };
|
||||
@@ -300,7 +300,7 @@ yyreport_syntax_error (const yyparse_context_t *ctx)
|
||||
i == 0 ? ": expected" : " or", yysymbol_name (expected[i]));
|
||||
}
|
||||
{
|
||||
yysymbol_type_t lookahead = yyparse_context_token (ctx);
|
||||
yysymbol_type_t lookahead = yypcontext_token (ctx);
|
||||
if (lookahead != YYEMPTY)
|
||||
fprintf (stderr, " before %s", yysymbol_name (lookahead));
|
||||
}
|
||||
|
||||
@@ -1592,7 +1592,7 @@ typedef struct
|
||||
YYPTRDIFF_T *yyes_capacity;
|
||||
yysymbol_type_t yytoken;
|
||||
YYLTYPE *yylloc;
|
||||
} yyparse_context_t;
|
||||
} yypcontext_t;
|
||||
|
||||
/* Put in YYARG at most YYARGN of the expected tokens given the
|
||||
current YYCTX, and return the number of tokens stored in YYARG. If
|
||||
@@ -1601,7 +1601,7 @@ typedef struct
|
||||
Return 0 if there are more than YYARGN expected tokens, yet fill
|
||||
YYARG up to YYARGN. */
|
||||
static int
|
||||
yyexpected_tokens (const yyparse_context_t *yyctx,
|
||||
yyexpected_tokens (const yypcontext_t *yyctx,
|
||||
yysymbol_type_t yyarg[], int yyargn)
|
||||
{
|
||||
/* Actual size of YYARG. */
|
||||
@@ -1635,27 +1635,27 @@ yyexpected_tokens (const yyparse_context_t *yyctx,
|
||||
|
||||
/* The token type of the lookahead of this context. */
|
||||
static yysymbol_type_t
|
||||
yyparse_context_token (const yyparse_context_t *yyctx) YY_ATTRIBUTE_UNUSED;
|
||||
yypcontext_token (const yypcontext_t *yyctx) YY_ATTRIBUTE_UNUSED;
|
||||
|
||||
static yysymbol_type_t
|
||||
yyparse_context_token (const yyparse_context_t *yyctx)
|
||||
yypcontext_token (const yypcontext_t *yyctx)
|
||||
{
|
||||
return yyctx->yytoken;
|
||||
}
|
||||
|
||||
/* The location of the lookahead of this context. */
|
||||
static YYLTYPE *
|
||||
yyparse_context_location (const yyparse_context_t *yyctx) YY_ATTRIBUTE_UNUSED;
|
||||
yypcontext_location (const yypcontext_t *yyctx) YY_ATTRIBUTE_UNUSED;
|
||||
|
||||
static YYLTYPE *
|
||||
yyparse_context_location (const yyparse_context_t *yyctx)
|
||||
yypcontext_location (const yypcontext_t *yyctx)
|
||||
{
|
||||
return yyctx->yylloc;
|
||||
}
|
||||
|
||||
/* User defined function to report a syntax error. */
|
||||
static int
|
||||
yyreport_syntax_error (const yyparse_context_t *yyctx);
|
||||
yyreport_syntax_error (const yypcontext_t *yyctx);
|
||||
|
||||
/*-----------------------------------------------.
|
||||
| Release the memory associated to this symbol. |
|
||||
@@ -2630,7 +2630,7 @@ yyerrlab:
|
||||
{
|
||||
++yynerrs;
|
||||
{
|
||||
yyparse_context_t yyctx
|
||||
yypcontext_t yyctx
|
||||
= {yyssp, yyesa, &yyes, &yyes_capacity, yytoken, &yylloc};
|
||||
if (yychar != YYEMPTY)
|
||||
YY_LAC_ESTABLISH;
|
||||
@@ -2798,7 +2798,7 @@ yyreturn:
|
||||
|
||||
|
||||
int
|
||||
yyreport_syntax_error (const yyparse_context_t *ctx)
|
||||
yyreport_syntax_error (const yypcontext_t *ctx)
|
||||
{
|
||||
int res = 0;
|
||||
/* Arguments of format: reported tokens (one for the "unexpected",
|
||||
@@ -2806,7 +2806,7 @@ yyreport_syntax_error (const yyparse_context_t *ctx)
|
||||
enum { ARGS_MAX = 5 };
|
||||
const char *argv[ARGS_MAX];
|
||||
int argc = 0;
|
||||
yysymbol_type_t unexpected = yyparse_context_token (ctx);
|
||||
yysymbol_type_t unexpected = yypcontext_token (ctx);
|
||||
if (unexpected != YYSYMBOL_YYEMPTY)
|
||||
{
|
||||
argv[argc++] = yysymbol_name (unexpected);
|
||||
@@ -2818,7 +2818,7 @@ yyreport_syntax_error (const yyparse_context_t *ctx)
|
||||
for (int i = 0; i < nexpected; ++i)
|
||||
argv[argc++] = yysymbol_name (expected[i]);
|
||||
}
|
||||
syntax_error (*yyparse_context_location (ctx), argc, argv);
|
||||
syntax_error (*yypcontext_location (ctx), argc, argv);
|
||||
return res;
|
||||
}
|
||||
|
||||
|
||||
@@ -799,7 +799,7 @@ epilogue.opt:
|
||||
%%
|
||||
|
||||
int
|
||||
yyreport_syntax_error (const yyparse_context_t *ctx)
|
||||
yyreport_syntax_error (const yypcontext_t *ctx)
|
||||
{
|
||||
int res = 0;
|
||||
/* Arguments of format: reported tokens (one for the "unexpected",
|
||||
@@ -807,7 +807,7 @@ yyreport_syntax_error (const yyparse_context_t *ctx)
|
||||
enum { ARGS_MAX = 5 };
|
||||
const char *argv[ARGS_MAX];
|
||||
int argc = 0;
|
||||
yysymbol_type_t unexpected = yyparse_context_token (ctx);
|
||||
yysymbol_type_t unexpected = yypcontext_token (ctx);
|
||||
if (unexpected != YYSYMBOL_YYEMPTY)
|
||||
{
|
||||
argv[argc++] = yysymbol_name (unexpected);
|
||||
@@ -819,7 +819,7 @@ yyreport_syntax_error (const yyparse_context_t *ctx)
|
||||
for (int i = 0; i < nexpected; ++i)
|
||||
argv[argc++] = yysymbol_name (expected[i]);
|
||||
}
|
||||
syntax_error (*yyparse_context_location (ctx), argc, argv);
|
||||
syntax_error (*yypcontext_location (ctx), argc, argv);
|
||||
return res;
|
||||
}
|
||||
|
||||
|
||||
@@ -622,18 +622,18 @@ location_print (FILE *yyo, ]AT_YYLTYPE[ const * const yylocp)
|
||||
|
||||
]AT_ERROR_CUSTOM_IF([[
|
||||
int
|
||||
yyreport_syntax_error (const yyparse_context_t *ctx]AT_PARAM_IF([, AT_PARSE_PARAMS])[)
|
||||
yyreport_syntax_error (const yypcontext_t *ctx]AT_PARAM_IF([, AT_PARSE_PARAMS])[)
|
||||
{
|
||||
int res = 0;]AT_PARAM_IF([m4_bpatsubst(m4_defn([AT_PARSE_PARAMS]),
|
||||
[[^,]+[^A-Za-z_0-9]\([A-Za-z_][A-Za-z_0-9]*\),* *], [
|
||||
YYUSE (\1);])])[]m4_bmatch(m4_defn([AT_PARSE_PARAMS]), [nerrs],[[
|
||||
++global_nerrs;
|
||||
++*nerrs;]])[]AT_LOCATION_IF([[
|
||||
LOCATION_PRINT (stderr, *yyparse_context_location (ctx));
|
||||
LOCATION_PRINT (stderr, *yypcontext_location (ctx));
|
||||
fprintf (stderr, ": ");]])[
|
||||
fprintf (stderr, "syntax error");
|
||||
{
|
||||
yysymbol_type_t la = yyparse_context_token (ctx);
|
||||
yysymbol_type_t la = yypcontext_token (ctx);
|
||||
if (la != YYEMPTY)
|
||||
fprintf (stderr, " on token [%s]", yysymbol_name (la));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user