mirror of
https://git.savannah.gnu.org/git/bison.git
synced 2026-03-20 17:53:02 +00:00
(const): Do not define; that is now config.h's job.
(YYSIZE_T, YYSTACK_ALLOC, YYSTACK_FREE): Do not infringe on the global user namespace when using C++. (YYFPRINTF, YYSTDERR): New macros, needed for the above. All uses of `fprintf' and `stderr' changed.
This commit is contained in:
100
src/bison.simple
100
src/bison.simple
@@ -82,17 +82,11 @@ typedef struct yyltype
|
|||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
|
||||||
#ifndef __cplusplus
|
|
||||||
# ifndef __STDC__
|
|
||||||
# define const
|
|
||||||
# endif
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* All symbols defined below should begin with yy or YY, to avoid
|
/* All symbols defined below should begin with yy or YY, to avoid
|
||||||
infringing on user name space. This should be done even for local
|
infringing on user name space. This should be done even for local
|
||||||
variables, as they might otherwise be expanded by user macros.
|
variables, as they might otherwise be expanded by user macros.
|
||||||
There are some unavoidable exceptions within include files to
|
There are some unavoidable exceptions within include files to
|
||||||
define necessary C library symbols; they are noted "INFRINGES ON
|
define necessary library symbols; they are noted "INFRINGES ON
|
||||||
USER NAME SPACE" below. */
|
USER NAME SPACE" below. */
|
||||||
|
|
||||||
#if ! defined (yyoverflow) || YYERROR_VERBOSE
|
#if ! defined (yyoverflow) || YYERROR_VERBOSE
|
||||||
@@ -129,11 +123,18 @@ typedef struct yyltype
|
|||||||
/* Pacify GCC's `empty if-body' warning. */
|
/* Pacify GCC's `empty if-body' warning. */
|
||||||
# define YYSTACK_FREE(Ptr) do { /* empty */; } while (0)
|
# define YYSTACK_FREE(Ptr) do { /* empty */; } while (0)
|
||||||
# else
|
# else
|
||||||
# define YYSTACK_ALLOC malloc
|
# ifdef __cplusplus
|
||||||
# define YYSTACK_FREE(Ptr) free (Ptr)
|
# include <cstdlib> /* INFRINGES ON USER NAME SPACE */
|
||||||
# if defined (__STDC__) || defined (__cplusplus)
|
# define YYSIZE_T std::size_t
|
||||||
# include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
|
# define YYSTACK_ALLOC std::malloc
|
||||||
# define YYSIZE_T size_t
|
# define YYSTACK_FREE std::free
|
||||||
|
# else
|
||||||
|
# ifdef __STDC__
|
||||||
|
# include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
|
||||||
|
# define YYSIZE_T size_t
|
||||||
|
# endif
|
||||||
|
# define YYSTACK_ALLOC malloc
|
||||||
|
# define YYSTACK_FREE free
|
||||||
# endif
|
# endif
|
||||||
# endif
|
# endif
|
||||||
|
|
||||||
@@ -288,9 +289,16 @@ static const short yycheck[] =
|
|||||||
#if ! defined (YYSIZE_T) && defined (size_t)
|
#if ! defined (YYSIZE_T) && defined (size_t)
|
||||||
# define YYSIZE_T size_t
|
# define YYSIZE_T size_t
|
||||||
#endif
|
#endif
|
||||||
#if ! defined (YYSIZE_T) && (defined (__STDC__) || defined (__cplusplus))
|
#if ! defined (YYSIZE_T)
|
||||||
# include <stddef.h> /* INFRINGES ON USER NAME SPACE */
|
# ifdef __cplusplus
|
||||||
# define YYSIZE_T size_t
|
# include <cstddef> /* INFRINGES ON USER NAME SPACE */
|
||||||
|
# define YYSIZE_T std::size_t
|
||||||
|
# else
|
||||||
|
# ifdef __STDC__
|
||||||
|
# include <stddef.h> /* INFRINGES ON USER NAME SPACE */
|
||||||
|
# define YYSIZE_T size_t
|
||||||
|
# endif
|
||||||
|
# endif
|
||||||
#endif
|
#endif
|
||||||
#if ! defined (YYSIZE_T)
|
#if ! defined (YYSIZE_T)
|
||||||
# define YYSIZE_T unsigned int
|
# define YYSIZE_T unsigned int
|
||||||
@@ -368,11 +376,23 @@ while (0)
|
|||||||
|
|
||||||
/* Enable debugging if requested. */
|
/* Enable debugging if requested. */
|
||||||
#if YYDEBUG
|
#if YYDEBUG
|
||||||
# include <stdio.h>
|
|
||||||
|
# ifndef YYFPRINTF
|
||||||
|
# ifdef __cplusplus
|
||||||
|
# include <cstdio.h> /* INFRINGES ON USER NAME SPACE */
|
||||||
|
# define YYFPRINTF std::fprintf
|
||||||
|
# define YYSTDERR std::stderr
|
||||||
|
# else
|
||||||
|
# include <stdio.h> /* INFRINGES ON USER NAME SPACE */
|
||||||
|
# define YYFPRINTF fprintf
|
||||||
|
# define YYSTDERR stderr
|
||||||
|
# endif
|
||||||
|
# endif
|
||||||
|
|
||||||
# define YYDPRINTF(Args) \
|
# define YYDPRINTF(Args) \
|
||||||
do { \
|
do { \
|
||||||
if (yydebug) \
|
if (yydebug) \
|
||||||
fprintf Args; \
|
YYFPRINTF Args; \
|
||||||
} while (0)
|
} while (0)
|
||||||
/* Nonzero means print parse trace. [The following comment makes no
|
/* Nonzero means print parse trace. [The following comment makes no
|
||||||
sense to me. Could someone clarify it? --akim] Since this is
|
sense to me. Could someone clarify it? --akim] Since this is
|
||||||
@@ -608,7 +628,7 @@ yyparse (YYPARSE_PARAM_ARG)
|
|||||||
rule. */
|
rule. */
|
||||||
int yylen;
|
int yylen;
|
||||||
|
|
||||||
YYDPRINTF ((stderr, "Starting parse\n"));
|
YYDPRINTF ((YYSTDERR, "Starting parse\n"));
|
||||||
|
|
||||||
yystate = 0;
|
yystate = 0;
|
||||||
yyerrstatus = 0;
|
yyerrstatus = 0;
|
||||||
@@ -704,14 +724,14 @@ yyparse (YYPARSE_PARAM_ARG)
|
|||||||
yylsp = yyls + yysize - 1;
|
yylsp = yyls + yysize - 1;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
YYDPRINTF ((stderr, "Stack size increased to %lu\n",
|
YYDPRINTF ((YYSTDERR, "Stack size increased to %lu\n",
|
||||||
(unsigned long int) yystacksize));
|
(unsigned long int) yystacksize));
|
||||||
|
|
||||||
if (yyssp >= yyss + yystacksize - 1)
|
if (yyssp >= yyss + yystacksize - 1)
|
||||||
YYABORT;
|
YYABORT;
|
||||||
}
|
}
|
||||||
|
|
||||||
YYDPRINTF ((stderr, "Entering state %d\n", yystate));
|
YYDPRINTF ((YYSTDERR, "Entering state %d\n", yystate));
|
||||||
|
|
||||||
goto yybackup;
|
goto yybackup;
|
||||||
|
|
||||||
@@ -737,7 +757,7 @@ yybackup:
|
|||||||
|
|
||||||
if (yychar == YYEMPTY)
|
if (yychar == YYEMPTY)
|
||||||
{
|
{
|
||||||
YYDPRINTF ((stderr, "Reading a token: "));
|
YYDPRINTF ((YYSTDERR, "Reading a token: "));
|
||||||
yychar = YYLEX;
|
yychar = YYLEX;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -748,7 +768,7 @@ yybackup:
|
|||||||
yychar1 = 0;
|
yychar1 = 0;
|
||||||
yychar = YYEOF; /* Don't call YYLEX any more. */
|
yychar = YYEOF; /* Don't call YYLEX any more. */
|
||||||
|
|
||||||
YYDPRINTF ((stderr, "Now at end of input.\n"));
|
YYDPRINTF ((YYSTDERR, "Now at end of input.\n"));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -759,13 +779,14 @@ yybackup:
|
|||||||
which are defined only if `YYDEBUG' is set. */
|
which are defined only if `YYDEBUG' is set. */
|
||||||
if (yydebug)
|
if (yydebug)
|
||||||
{
|
{
|
||||||
fprintf (stderr, "Next token is %d (%s", yychar, yytname[yychar1]);
|
YYFPRINTF (YYSTDERR, "Next token is %d (%s",
|
||||||
|
yychar, yytname[yychar1]);
|
||||||
/* Give the individual parser a way to print the precise
|
/* Give the individual parser a way to print the precise
|
||||||
meaning of a token, for further debugging info. */
|
meaning of a token, for further debugging info. */
|
||||||
# ifdef YYPRINT
|
# ifdef YYPRINT
|
||||||
YYPRINT (stderr, yychar, yylval);
|
YYPRINT (YYSTDERR, yychar, yylval);
|
||||||
# endif
|
# endif
|
||||||
fprintf (stderr, ")\n");
|
YYFPRINTF (YYSTDERR, ")\n");
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
@@ -797,7 +818,8 @@ yybackup:
|
|||||||
YYACCEPT;
|
YYACCEPT;
|
||||||
|
|
||||||
/* Shift the lookahead token. */
|
/* Shift the lookahead token. */
|
||||||
YYDPRINTF ((stderr, "Shifting token %d (%s), ", yychar, yytname[yychar1]));
|
YYDPRINTF ((YYSTDERR, "Shifting token %d (%s), ",
|
||||||
|
yychar, yytname[yychar1]));
|
||||||
|
|
||||||
/* Discard the token being shifted unless it is eof. */
|
/* Discard the token being shifted unless it is eof. */
|
||||||
if (yychar != YYEOF)
|
if (yychar != YYEOF)
|
||||||
@@ -858,13 +880,13 @@ yyreduce:
|
|||||||
{
|
{
|
||||||
int yyi;
|
int yyi;
|
||||||
|
|
||||||
fprintf (stderr, "Reducing via rule %d (line %d), ",
|
YYFPRINTF (YYSTDERR, "Reducing via rule %d (line %d), ",
|
||||||
yyn, yyrline[yyn]);
|
yyn, yyrline[yyn]);
|
||||||
|
|
||||||
/* Print the symbols being reduced, and their result. */
|
/* Print the symbols being reduced, and their result. */
|
||||||
for (yyi = yyprhs[yyn]; yyrhs[yyi] > 0; yyi++)
|
for (yyi = yyprhs[yyn]; yyrhs[yyi] > 0; yyi++)
|
||||||
fprintf (stderr, "%s ", yytname[yyrhs[yyi]]);
|
YYFPRINTF (YYSTDERR, "%s ", yytname[yyrhs[yyi]]);
|
||||||
fprintf (stderr, " -> %s\n", yytname[yyr1[yyn]]);
|
YYFPRINTF (YYSTDERR, " -> %s\n", yytname[yyr1[yyn]]);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
switch (yyn)
|
switch (yyn)
|
||||||
@@ -883,10 +905,10 @@ yyreduce:
|
|||||||
if (yydebug)
|
if (yydebug)
|
||||||
{
|
{
|
||||||
short *yyssp1 = yyss - 1;
|
short *yyssp1 = yyss - 1;
|
||||||
fprintf (stderr, "state stack now");
|
YYFPRINTF (YYSTDERR, "state stack now");
|
||||||
while (yyssp1 != yyssp)
|
while (yyssp1 != yyssp)
|
||||||
fprintf (stderr, " %d", *++yyssp1);
|
YYFPRINTF (YYSTDERR, " %d", *++yyssp1);
|
||||||
fprintf (stderr, "\n");
|
YYFPRINTF (YYSTDERR, "\n");
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@@ -964,7 +986,7 @@ yyerrlab:
|
|||||||
yyerror ("parse error; also virtual memory exhausted");
|
yyerror ("parse error; also virtual memory exhausted");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
#endif /* defined (YYERROR_VERBOSE) */
|
#endif /* YYERROR_VERBOSE */
|
||||||
yyerror ("parse error");
|
yyerror ("parse error");
|
||||||
}
|
}
|
||||||
goto yyerrlab1;
|
goto yyerrlab1;
|
||||||
@@ -982,7 +1004,7 @@ yyerrlab1:
|
|||||||
/* Return failure if at end of input. */
|
/* Return failure if at end of input. */
|
||||||
if (yychar == YYEOF)
|
if (yychar == YYEOF)
|
||||||
YYABORT;
|
YYABORT;
|
||||||
YYDPRINTF ((stderr, "Discarding token %d (%s).\n",
|
YYDPRINTF ((YYSTDERR, "Discarding token %d (%s).\n",
|
||||||
yychar, yytname[yychar1]));
|
yychar, yytname[yychar1]));
|
||||||
yychar = YYEMPTY;
|
yychar = YYEMPTY;
|
||||||
}
|
}
|
||||||
@@ -1028,10 +1050,10 @@ yyerrpop:
|
|||||||
if (yydebug)
|
if (yydebug)
|
||||||
{
|
{
|
||||||
short *yyssp1 = yyss - 1;
|
short *yyssp1 = yyss - 1;
|
||||||
fprintf (stderr, "Error: state stack now");
|
YYFPRINTF (YYSTDERR, "Error: state stack now");
|
||||||
while (yyssp1 != yyssp)
|
while (yyssp1 != yyssp)
|
||||||
fprintf (stderr, " %d", *++yyssp1);
|
YYFPRINTF (YYSTDERR, " %d", *++yyssp1);
|
||||||
fprintf (stderr, "\n");
|
YYFPRINTF (YYSTDERR, "\n");
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@@ -1061,7 +1083,7 @@ yyerrhandle:
|
|||||||
if (yyn == YYFINAL)
|
if (yyn == YYFINAL)
|
||||||
YYACCEPT;
|
YYACCEPT;
|
||||||
|
|
||||||
YYDPRINTF ((stderr, "Shifting error token, "));
|
YYDPRINTF ((YYSTDERR, "Shifting error token, "));
|
||||||
|
|
||||||
*++yyvsp = yylval;
|
*++yyvsp = yylval;
|
||||||
#if YYLSP_NEEDED
|
#if YYLSP_NEEDED
|
||||||
|
|||||||
Reference in New Issue
Block a user