mirror of
https://git.savannah.gnu.org/git/bison.git
synced 2026-03-18 16:53:02 +00:00
* src/bison.simple (YYSTACK_FREE): Use `do {;} while (0)' as empty
if body instead of `;' to pacify GCC's warnings.
This commit is contained in:
@@ -693,7 +693,7 @@ arrange for it to call @code{yyparse} or the parser will never run.
|
|||||||
@xref{Interface, ,Parser C-Language Interface}.
|
@xref{Interface, ,Parser C-Language Interface}.
|
||||||
|
|
||||||
Aside from the token type names and the symbols in the actions you
|
Aside from the token type names and the symbols in the actions you
|
||||||
write, all variable and function names used in the Bison parser file
|
write, all symbols defined in the Bison parser file itself
|
||||||
begin with @samp{yy} or @samp{YY}. This includes interface functions
|
begin with @samp{yy} or @samp{YY}. This includes interface functions
|
||||||
such as the lexical analyzer function @code{yylex}, the error reporting
|
such as the lexical analyzer function @code{yylex}, the error reporting
|
||||||
function @code{yyerror} and the parser function @code{yyparse} itself.
|
function @code{yyerror} and the parser function @code{yyparse} itself.
|
||||||
@@ -702,6 +702,14 @@ Therefore, you should avoid using C identifiers starting with @samp{yy}
|
|||||||
or @samp{YY} in the Bison grammar file except for the ones defined in
|
or @samp{YY} in the Bison grammar file except for the ones defined in
|
||||||
this manual.
|
this manual.
|
||||||
|
|
||||||
|
In some cases the Bison parser file includes system headers, and in
|
||||||
|
those cases your code should respect the identifiers reserved by those
|
||||||
|
headers. On some non-@sc{gnu} hosts, @code{<alloca.h>},
|
||||||
|
@code{<stddef.h>}, and @code{<stdlib.h>} are included as needed to
|
||||||
|
declare memory allocators and related types. On all hosts,
|
||||||
|
@code{<stdio.h>} is included if you define @code{YYDEBUG}
|
||||||
|
(@pxref{Debugging, ,Debugging Your Parser}).
|
||||||
|
|
||||||
@node Stages
|
@node Stages
|
||||||
@section Stages in Using Bison
|
@section Stages in Using Bison
|
||||||
@cindex stages in using Bison
|
@cindex stages in using Bison
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
@set UPDATED 27 November 2001
|
@set UPDATED 30 November 2001
|
||||||
@set UPDATED-MONTH November 2001
|
@set UPDATED-MONTH November 2001
|
||||||
@set EDITION 1.30f
|
@set EDITION 1.30f
|
||||||
@set VERSION 1.30f
|
@set VERSION 1.30f
|
||||||
|
|||||||
352
src/bison.simple
352
src/bison.simple
@@ -28,104 +28,114 @@
|
|||||||
It was written by Richard Stallman by simplifying the hairy parser
|
It was written by Richard Stallman by simplifying the hairy parser
|
||||||
used when %semantic_parser is specified. */
|
used when %semantic_parser is specified. */
|
||||||
|
|
||||||
#ifndef YYSTACK_USE_ALLOCA
|
/* All symbols defined below should begin with yy or YY, to avoid
|
||||||
# ifdef alloca
|
infringing on user name space. This should be done even for local
|
||||||
# define YYSTACK_USE_ALLOCA 1
|
variables, as they might otherwise be expanded by user macros.
|
||||||
# else /* alloca not defined */
|
There are some unavoidable exceptions within include files to
|
||||||
# ifdef __GNUC__
|
define necessary C library symbols; they are noted "INFRINGES ON
|
||||||
# define YYSTACK_USE_ALLOCA 1
|
USER NAME SPACE" below. */
|
||||||
# define alloca __builtin_alloca
|
|
||||||
# else /* not GNU C. */
|
#if ! defined (yyoverflow) || defined (YYERROR_VERBOSE)
|
||||||
# if (!defined (__STDC__) && defined (sparc)) || defined (__sparc__) || defined (__sparc) || defined (__sgi) || (defined (__sun) && defined (__i386))
|
|
||||||
# define YYSTACK_USE_ALLOCA 1
|
/* The parser invokes alloca or malloc; define the necessary symbols. */
|
||||||
# include <alloca.h>
|
|
||||||
# else /* not sparc */
|
# if YYSTACK_USE_ALLOCA
|
||||||
/* We think this test detects Watcom and Microsoft C. */
|
# define YYSTACK_ALLOC alloca
|
||||||
/* This used to test MSDOS, but that is a bad idea since that
|
# define YYSIZE_T size_t
|
||||||
symbol is in the user namespace. */
|
# else
|
||||||
# if (defined (_MSDOS) || defined (_MSDOS_)) && !defined (__TURBOC__)
|
# ifndef YYSTACK_USE_ALLOCA
|
||||||
# if 0
|
# if defined (alloca) || defined (_ALLOCA_H)
|
||||||
/* No need for malloc.h, which pollutes the namespace; instead,
|
# define YYSTACK_ALLOC alloca
|
||||||
just don't use alloca. */
|
# define YYSIZE_T size_t
|
||||||
# include <malloc.h>
|
# else
|
||||||
|
# if defined (__GNUC__) || defined (_AIX) || defined (__hpux)
|
||||||
|
# define YYSTACK_ALLOC __builtin_alloca
|
||||||
|
# endif
|
||||||
|
# ifndef __GNUC__
|
||||||
|
# ifdef _AIX
|
||||||
|
# pragma alloca
|
||||||
# endif
|
# endif
|
||||||
# else /* not MSDOS, or __TURBOC__ */
|
# if defined (__sgi) || defined (__sparc__) || defined (__sparc) || defined (__sun)
|
||||||
# if defined(_AIX)
|
# include <alloca.h> /* INFRINGES ON USER NAME SPACE */
|
||||||
/* I don't know what this was needed for, but it pollutes the
|
# define YYSTACK_ALLOC alloca
|
||||||
namespace. So I turned it off. rms, 2 May 1997. */
|
# define YYSIZE_T size_t
|
||||||
/* #include <malloc.h> */
|
# endif
|
||||||
#pragma alloca
|
# endif
|
||||||
# define YYSTACK_USE_ALLOCA 1
|
# endif
|
||||||
# else /* not MSDOS, or __TURBOC__, or _AIX */
|
# endif
|
||||||
# if 0
|
# endif
|
||||||
/* haible@ilog.fr says this works for HPUX 9.05 and up, and on
|
|
||||||
HPUX 10. Eventually we can turn this on. */
|
|
||||||
# ifdef __hpux
|
|
||||||
# define YYSTACK_USE_ALLOCA 1
|
|
||||||
# define alloca __builtin_alloca
|
|
||||||
# endif /* __hpux */
|
|
||||||
# endif
|
|
||||||
# endif /* not _AIX */
|
|
||||||
# endif /* not MSDOS, or __TURBOC__ */
|
|
||||||
# endif /* not sparc */
|
|
||||||
# endif /* not GNU C */
|
|
||||||
# endif /* alloca not defined */
|
|
||||||
#endif /* YYSTACK_USE_ALLOCA not defined */
|
|
||||||
|
|
||||||
#ifndef YYSTACK_USE_ALLOCA
|
# ifdef YYSTACK_ALLOC
|
||||||
# define YYSTACK_USE_ALLOCA 0
|
/* Pacify GCC's `empty if-body' warning. */
|
||||||
#endif
|
# define YYSTACK_FREE(Ptr) do { /* empty */; } while (0)
|
||||||
|
# else
|
||||||
#if YYSTACK_USE_ALLOCA
|
# define YYSTACK_ALLOC malloc
|
||||||
# define YYSTACK_ALLOC alloca
|
# define YYSTACK_FREE(Ptr) free (Ptr)
|
||||||
/* Pacify GCC's `empty if-body' warning. */
|
# if defined (__STDC__) || defined (__cplusplus)
|
||||||
# define YYSTACK_FREE(Ptr) do { /* empty */; } while (0)
|
# include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
|
||||||
#else
|
# define YYSIZE_T size_t
|
||||||
# define YYSTACK_ALLOC malloc
|
# endif
|
||||||
# define YYSTACK_FREE(Ptr) free (Ptr)
|
# endif
|
||||||
#endif
|
|
||||||
|
|
||||||
/* A type that is properly aligned for any stack member. */
|
/* A type that is properly aligned for any stack member. */
|
||||||
union yyalloc
|
union yyalloc
|
||||||
{
|
{
|
||||||
short yys;
|
short yys;
|
||||||
YYSTYPE yyv;
|
YYSTYPE yyv;
|
||||||
#if YYLSP_NEEDED
|
# if YYLSP_NEEDED
|
||||||
YYLTYPE yyl;
|
YYLTYPE yyl;
|
||||||
#endif
|
# endif
|
||||||
};
|
};
|
||||||
|
|
||||||
/* The size of the maximum gap between one aligned stack and the next. */
|
/* The size of the maximum gap between one aligned stack and the next. */
|
||||||
#define YYSTACK_GAP_MAX (sizeof (union yyalloc) - 1)
|
# define YYSTACK_GAP_MAX (sizeof (union yyalloc) - 1)
|
||||||
|
|
||||||
/* The size of an array large to enough to hold all stacks, each with
|
/* The size of an array large to enough to hold all stacks, each with
|
||||||
N elements. */
|
N elements. */
|
||||||
#if YYLSP_NEEDED
|
# if YYLSP_NEEDED
|
||||||
# define YYSTACK_BYTES(N) \
|
# define YYSTACK_BYTES(N) \
|
||||||
((N) * (sizeof (short) + sizeof (YYSTYPE) + sizeof (YYLTYPE)) \
|
((N) * (sizeof (short) + sizeof (YYSTYPE) + sizeof (YYLTYPE)) \
|
||||||
+ 2 * YYSTACK_GAP_MAX)
|
+ 2 * YYSTACK_GAP_MAX)
|
||||||
#else
|
# else
|
||||||
# define YYSTACK_BYTES(N) \
|
# define YYSTACK_BYTES(N) \
|
||||||
((N) * (sizeof (short) + sizeof (YYSTYPE)) \
|
((N) * (sizeof (short) + sizeof (YYSTYPE)) \
|
||||||
+ YYSTACK_GAP_MAX)
|
+ YYSTACK_GAP_MAX)
|
||||||
#endif
|
# endif
|
||||||
|
|
||||||
/* Relocate the TYPE STACK from its old location to the new one. The
|
/* Relocate the TYPE STACK from its old location to the new one. The
|
||||||
local variables SIZE and YYSTACKSIZE give the old and new number of
|
local variables YYSIZE and YYSTACKSIZE give the old and new number of
|
||||||
elements in the stack, and YYPTR gives the new location of the
|
elements in the stack, and YYPTR gives the new location of the
|
||||||
stack. Advance YYPTR to a properly aligned location for the next
|
stack. Advance YYPTR to a properly aligned location for the next
|
||||||
stack. */
|
stack. */
|
||||||
#define YYSTACK_RELOCATE(Type, Stack) \
|
# define YYSTACK_RELOCATE(Type, Stack) \
|
||||||
do \
|
do \
|
||||||
{ \
|
{ \
|
||||||
size_t yynewbytes; \
|
YYSIZE_T yynewbytes; \
|
||||||
__yy_memcpy (yyptr, (char *) (Stack), size * sizeof (Type)); \
|
yymemcpy (yyptr, (char *) (Stack), \
|
||||||
(Stack) = (Type *) yyptr; \
|
yysize * (YYSIZE_T) sizeof (Type)); \
|
||||||
yynewbytes = yystacksize * sizeof (Type) + YYSTACK_GAP_MAX; \
|
(Stack) = (Type *) yyptr; \
|
||||||
yynewbytes -= yynewbytes % sizeof (union yyalloc); \
|
yynewbytes = yystacksize * sizeof (Type) + YYSTACK_GAP_MAX; \
|
||||||
yyptr += yynewbytes; \
|
yynewbytes -= yynewbytes % sizeof (union yyalloc); \
|
||||||
} \
|
yyptr += yynewbytes; \
|
||||||
while (0)
|
} \
|
||||||
|
while (0)
|
||||||
|
|
||||||
|
#endif /* ! defined (yyoverflow) || defined (YYERROR_VERBOSE) */
|
||||||
|
|
||||||
|
|
||||||
|
#if ! defined (YYSIZE_T) && defined (__SIZE_TYPE__)
|
||||||
|
# define YYSIZE_T __SIZE_TYPE__
|
||||||
|
#endif
|
||||||
|
#if ! defined (YYSIZE_T) && defined (size_t)
|
||||||
|
# define YYSIZE_T size_t
|
||||||
|
#endif
|
||||||
|
#if ! defined (YYSIZE_T) && (defined (__STDC__) || defined (__cplusplus))
|
||||||
|
# include <stddef.h> /* INFRINGES ON USER NAME SPACE */
|
||||||
|
# define YYSIZE_T size_t
|
||||||
|
#endif
|
||||||
|
#if ! defined (YYSIZE_T)
|
||||||
|
# define YYSIZE_T unsigned int
|
||||||
|
#endif
|
||||||
|
|
||||||
#define yyerrok (yyerrstatus = 0)
|
#define yyerrok (yyerrstatus = 0)
|
||||||
#define yyclearin (yychar = YYEMPTY)
|
#define yyclearin (yychar = YYEMPTY)
|
||||||
@@ -197,6 +207,7 @@ while (0)
|
|||||||
|
|
||||||
/* Enable debugging if requested. */
|
/* Enable debugging if requested. */
|
||||||
#if YYDEBUG
|
#if YYDEBUG
|
||||||
|
# include <stdio.h>
|
||||||
# define YYDPRINTF(Args) \
|
# define YYDPRINTF(Args) \
|
||||||
do { \
|
do { \
|
||||||
if (yydebug) \
|
if (yydebug) \
|
||||||
@@ -231,30 +242,83 @@ int yydebug;
|
|||||||
# define YYMAXDEPTH 10000
|
# define YYMAXDEPTH 10000
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if __GNUC__ > 1 /* GNU C and GNU C++ define this. */
|
#if ! defined (yyoverflow) && ! defined (yymemcpy)
|
||||||
# define __yy_memcpy(To, From, Count) __builtin_memcpy (To, From, Count)
|
# if __GNUC__ > 1 /* GNU C and GNU C++ define this. */
|
||||||
#else /* not GNU C or C++ */
|
# define yymemcpy __builtin_memcpy
|
||||||
|
# else /* not GNU C or C++ */
|
||||||
|
|
||||||
/* This is the most reliable way to avoid incompatibilities
|
/* This is the most reliable way to avoid incompatibilities
|
||||||
in available built-in functions on various systems. */
|
in available built-in functions on various systems. */
|
||||||
static void
|
static void
|
||||||
# ifndef __cplusplus
|
# if defined (__STDC__) || defined (__cplusplus)
|
||||||
__yy_memcpy (to, from, count)
|
yymemcpy (char *yyto, const char *yyfrom, YYSIZE_T yycount)
|
||||||
char *to;
|
# else
|
||||||
const char *from;
|
yymemcpy (yyto, yyfrom, yycount)
|
||||||
size_t count;
|
char *yyto;
|
||||||
# else /* __cplusplus */
|
const char *yyfrom;
|
||||||
__yy_memcpy (char *to, const char *from, size_t count)
|
YYSIZE_T yycount;
|
||||||
# endif
|
# endif
|
||||||
{
|
{
|
||||||
register const char *f = from;
|
register const char *yyf = yyfrom;
|
||||||
register char *t = to;
|
register char *yyt = yyto;
|
||||||
register size_t i = count;
|
register YYSIZE_T yyi = yycount;
|
||||||
|
|
||||||
while (i-- != 0)
|
while (yyi-- != 0)
|
||||||
*t++ = *f++;
|
*yyt++ = *yyf++;
|
||||||
}
|
}
|
||||||
|
# endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef YYERROR_VERBOSE
|
||||||
|
|
||||||
|
# ifndef yystrlen
|
||||||
|
# if defined (__GLIBC__) && defined (_STRING_H)
|
||||||
|
# define yystrlen strlen
|
||||||
|
# else
|
||||||
|
/* Return the length of YYSTR. */
|
||||||
|
static YYSIZE_T
|
||||||
|
# if defined (__STDC__) || defined (__cplusplus)
|
||||||
|
yystrlen (const char *yystr)
|
||||||
|
# else
|
||||||
|
yystrlen (yystr)
|
||||||
|
const char *yystr;
|
||||||
|
# endif
|
||||||
|
{
|
||||||
|
register const char *yys = yystr;
|
||||||
|
|
||||||
|
while (*yys++ != '\0')
|
||||||
|
continue;
|
||||||
|
|
||||||
|
return yys - yystr - 1;
|
||||||
|
}
|
||||||
|
# endif
|
||||||
|
# endif
|
||||||
|
|
||||||
|
# ifndef yystpcpy
|
||||||
|
# if defined (__GLIBC__) && defined (_STRING_H) && defined (_GNU_SOURCE)
|
||||||
|
# define yystpcpy stpcpy
|
||||||
|
# else
|
||||||
|
/* Copy YYSRC to YYDEST, returning the address of the terminating '\0' in
|
||||||
|
YYDEST. */
|
||||||
|
static char *
|
||||||
|
# ifndef __cplusplus
|
||||||
|
yystpcpy (yydest, yysrc)
|
||||||
|
char *yydest;
|
||||||
|
const char *yysrc;
|
||||||
|
# else
|
||||||
|
yystpcpy (char *yydest, const char *yysrc)
|
||||||
|
# endif
|
||||||
|
{
|
||||||
|
register char *yyd = yydest;
|
||||||
|
register const char *yys = yysrc;
|
||||||
|
|
||||||
|
while ((*yyd++ = *yys++) != '\0')
|
||||||
|
continue;
|
||||||
|
|
||||||
|
return yyd - 1;
|
||||||
|
}
|
||||||
|
# endif
|
||||||
|
# endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#line
|
#line
|
||||||
@@ -290,7 +354,7 @@ int yyparse (void);
|
|||||||
/* YY_DECL_VARIABLES -- depending whether we use a pure parser,
|
/* YY_DECL_VARIABLES -- depending whether we use a pure parser,
|
||||||
variables are global, or local to YYPARSE. */
|
variables are global, or local to YYPARSE. */
|
||||||
|
|
||||||
#define _YY_DECL_VARIABLES \
|
#define YY_DECL_NON_LSP_VARIABLES \
|
||||||
/* The lookahead symbol. */ \
|
/* The lookahead symbol. */ \
|
||||||
int yychar; \
|
int yychar; \
|
||||||
\
|
\
|
||||||
@@ -302,13 +366,13 @@ int yynerrs;
|
|||||||
|
|
||||||
#if YYLSP_NEEDED
|
#if YYLSP_NEEDED
|
||||||
# define YY_DECL_VARIABLES \
|
# define YY_DECL_VARIABLES \
|
||||||
_YY_DECL_VARIABLES \
|
YY_DECL_NON_LSP_VARIABLES \
|
||||||
\
|
\
|
||||||
/* Location data for the lookahead symbol. */ \
|
/* Location data for the lookahead symbol. */ \
|
||||||
YYLTYPE yylloc;
|
YYLTYPE yylloc;
|
||||||
#else
|
#else
|
||||||
# define YY_DECL_VARIABLES \
|
# define YY_DECL_VARIABLES \
|
||||||
_YY_DECL_VARIABLES
|
YY_DECL_NON_LSP_VARIABLES
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
@@ -366,15 +430,15 @@ yyparse (YYPARSE_PARAM_ARG)
|
|||||||
# define YYPOPSTACK (yyvsp--, yyssp--)
|
# define YYPOPSTACK (yyvsp--, yyssp--)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
size_t yystacksize = YYINITDEPTH;
|
YYSIZE_T yystacksize = YYINITDEPTH;
|
||||||
|
|
||||||
|
|
||||||
/* The variables used to return semantic value and location from the
|
/* The variables used to return semantic value and location from the
|
||||||
action routines. */
|
action routines. */
|
||||||
YYSTYPE yyval;
|
YYSTYPE yyval;
|
||||||
# if YYLSP_NEEDED
|
#if YYLSP_NEEDED
|
||||||
YYLTYPE yyloc;
|
YYLTYPE yyloc;
|
||||||
# endif
|
#endif
|
||||||
|
|
||||||
/* When reducing, the number of symbols on the RHS of the reduced
|
/* When reducing, the number of symbols on the RHS of the reduced
|
||||||
rule. */
|
rule. */
|
||||||
@@ -414,7 +478,7 @@ yyparse (YYPARSE_PARAM_ARG)
|
|||||||
if (yyssp >= yyss + yystacksize - 1)
|
if (yyssp >= yyss + yystacksize - 1)
|
||||||
{
|
{
|
||||||
/* Get the current used size of the three stacks, in elements. */
|
/* Get the current used size of the three stacks, in elements. */
|
||||||
size_t size = yyssp - yyss + 1;
|
YYSIZE_T yysize = yyssp - yyss + 1;
|
||||||
|
|
||||||
#ifdef yyoverflow
|
#ifdef yyoverflow
|
||||||
{
|
{
|
||||||
@@ -431,15 +495,15 @@ yyparse (YYPARSE_PARAM_ARG)
|
|||||||
/* This used to be a conditional around just the two extra args,
|
/* This used to be a conditional around just the two extra args,
|
||||||
but that might be undefined if yyoverflow is a macro. */
|
but that might be undefined if yyoverflow is a macro. */
|
||||||
yyoverflow ("parser stack overflow",
|
yyoverflow ("parser stack overflow",
|
||||||
&yyss1, size * sizeof (*yyssp),
|
&yyss1, yysize * sizeof (*yyssp),
|
||||||
&yyvs1, size * sizeof (*yyvsp),
|
&yyvs1, yysize * sizeof (*yyvsp),
|
||||||
&yyls1, size * sizeof (*yylsp),
|
&yyls1, yysize * sizeof (*yylsp),
|
||||||
&yystacksize);
|
&yystacksize);
|
||||||
yyls = yyls1;
|
yyls = yyls1;
|
||||||
# else
|
# else
|
||||||
yyoverflow ("parser stack overflow",
|
yyoverflow ("parser stack overflow",
|
||||||
&yyss1, size * sizeof (*yyssp),
|
&yyss1, yysize * sizeof (*yyssp),
|
||||||
&yyvs1, size * sizeof (*yyvsp),
|
&yyvs1, yysize * sizeof (*yyvsp),
|
||||||
&yystacksize);
|
&yystacksize);
|
||||||
# endif
|
# endif
|
||||||
yyss = yyss1;
|
yyss = yyss1;
|
||||||
@@ -469,10 +533,10 @@ yyparse (YYPARSE_PARAM_ARG)
|
|||||||
}
|
}
|
||||||
#endif /* no yyoverflow */
|
#endif /* no yyoverflow */
|
||||||
|
|
||||||
yyssp = yyss + size - 1;
|
yyssp = yyss + yysize - 1;
|
||||||
yyvsp = yyvs + size - 1;
|
yyvsp = yyvs + yysize - 1;
|
||||||
#if YYLSP_NEEDED
|
#if YYLSP_NEEDED
|
||||||
yylsp = yyls + size - 1;
|
yylsp = yyls + yysize - 1;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
YYDPRINTF ((stderr, "Stack size increased to %lu\n",
|
YYDPRINTF ((stderr, "Stack size increased to %lu\n",
|
||||||
@@ -628,14 +692,14 @@ yyreduce:
|
|||||||
are defined only if `YYDEBUG' is set. */
|
are defined only if `YYDEBUG' is set. */
|
||||||
if (yydebug)
|
if (yydebug)
|
||||||
{
|
{
|
||||||
int i;
|
int yyi;
|
||||||
|
|
||||||
fprintf (stderr, "Reducing via rule %d (line %d), ",
|
fprintf (stderr, "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 (i = yyprhs[yyn]; yyrhs[i] > 0; i++)
|
for (yyi = yyprhs[yyn]; yyrhs[yyi] > 0; yyi++)
|
||||||
fprintf (stderr, "%s ", yytname[yyrhs[i]]);
|
fprintf (stderr, "%s ", yytname[yyrhs[yyi]]);
|
||||||
fprintf (stderr, " -> %s\n", yytname[yyr1[yyn]]);
|
fprintf (stderr, " -> %s\n", yytname[yyr1[yyn]]);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
@@ -651,10 +715,10 @@ yyreduce:
|
|||||||
#if YYDEBUG
|
#if YYDEBUG
|
||||||
if (yydebug)
|
if (yydebug)
|
||||||
{
|
{
|
||||||
short *ssp1 = yyss - 1;
|
short *yyssp1 = yyss - 1;
|
||||||
fprintf (stderr, "state stack now");
|
fprintf (stderr, "state stack now");
|
||||||
while (ssp1 != yyssp)
|
while (yyssp1 != yyssp)
|
||||||
fprintf (stderr, " %d", *++ssp1);
|
fprintf (stderr, " %d", *++yyssp1);
|
||||||
fprintf (stderr, "\n");
|
fprintf (stderr, "\n");
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
@@ -693,39 +757,41 @@ yyerrlab:
|
|||||||
|
|
||||||
if (yyn > YYFLAG && yyn < YYLAST)
|
if (yyn > YYFLAG && yyn < YYLAST)
|
||||||
{
|
{
|
||||||
size_t size = 0;
|
YYSIZE_T yysize = 0;
|
||||||
char *msg;
|
char *yymsg;
|
||||||
int x, count;
|
int yyx, yycount;
|
||||||
|
|
||||||
count = 0;
|
yycount = 0;
|
||||||
/* Start X at -YYN if negative to avoid negative indexes in
|
/* Start YYX at -YYN if negative to avoid negative indexes in
|
||||||
YYCHECK. */
|
YYCHECK. */
|
||||||
for (x = yyn < 0 ? -yyn : 0;
|
for (yyx = yyn < 0 ? -yyn : 0;
|
||||||
x < (int) (sizeof (yytname) / sizeof (char *)); x++)
|
yyx < (int) (sizeof (yytname) / sizeof (char *)); yyx++)
|
||||||
if (yycheck[x + yyn] == x)
|
if (yycheck[yyx + yyn] == yyx)
|
||||||
size += strlen (yytname[x]) + 15, count++;
|
yysize += yystrlen (yytname[yyx]) + 15, yycount++;
|
||||||
size += strlen ("parse error, unexpected ") + 1;
|
yysize += yystrlen ("parse error, unexpected ") + 1;
|
||||||
size += strlen (yytname[YYTRANSLATE (yychar)]);
|
yysize += yystrlen (yytname[YYTRANSLATE (yychar)]);
|
||||||
msg = (char *) malloc (size);
|
yymsg = (char *) YYSTACK_ALLOC (yysize);
|
||||||
if (msg != 0)
|
if (yymsg != 0)
|
||||||
{
|
{
|
||||||
strcpy (msg, "parse error, unexpected ");
|
char *yyp = yystpcpy (yymsg, "parse error, unexpected ");
|
||||||
strcat (msg, yytname[YYTRANSLATE (yychar)]);
|
yyp = yystpcpy (yyp, yytname[YYTRANSLATE (yychar)]);
|
||||||
|
|
||||||
if (count < 5)
|
if (yycount < 5)
|
||||||
{
|
{
|
||||||
count = 0;
|
yycount = 0;
|
||||||
for (x = yyn < 0 ? -yyn : 0;
|
for (yyx = yyn < 0 ? -yyn : 0;
|
||||||
x < (int) (sizeof (yytname) / sizeof (char *)); x++)
|
yyx < (int) (sizeof (yytname) / sizeof (char *));
|
||||||
if (yycheck[x + yyn] == x)
|
yyx++)
|
||||||
|
if (yycheck[yyx + yyn] == yyx)
|
||||||
{
|
{
|
||||||
strcat (msg, count == 0 ? ", expecting " : " or ");
|
const char *yyq = ! yycount ? ", expecting " : " or ";
|
||||||
strcat (msg, yytname[x]);
|
yyp = yystpcpy (yyp, yyq);
|
||||||
count++;
|
yyp = yystpcpy (yyp, yytname[yyx]);
|
||||||
|
yycount++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
yyerror (msg);
|
yyerror (yymsg);
|
||||||
free (msg);
|
YYSTACK_FREE (yymsg);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
yyerror ("parse error; also virtual memory exhausted");
|
yyerror ("parse error; also virtual memory exhausted");
|
||||||
@@ -794,10 +860,10 @@ yyerrpop:
|
|||||||
#if YYDEBUG
|
#if YYDEBUG
|
||||||
if (yydebug)
|
if (yydebug)
|
||||||
{
|
{
|
||||||
short *ssp1 = yyss - 1;
|
short *yyssp1 = yyss - 1;
|
||||||
fprintf (stderr, "Error: state stack now");
|
fprintf (stderr, "Error: state stack now");
|
||||||
while (ssp1 != yyssp)
|
while (yyssp1 != yyssp)
|
||||||
fprintf (stderr, " %d", *++ssp1);
|
fprintf (stderr, " %d", *++yyssp1);
|
||||||
fprintf (stderr, "\n");
|
fprintf (stderr, "\n");
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
Reference in New Issue
Block a user