X-Git-Url: https://git.saurik.com/bison.git/blobdiff_plain/fd51e5ffa20459b0a44e04cf83b09fd1b5e5b5c0..b85810aec0e5172c813b1cdd511bfce8a0cd4b4f:/src/bison.simple?ds=sidebyside diff --git a/src/bison.simple b/src/bison.simple index 0e6be055..59ff145b 100644 --- a/src/bison.simple +++ b/src/bison.simple @@ -1,10 +1,11 @@ +%%{section} %%{output-prefix} %%{output-infix} %%".c" /* -*- C -*- */ -/* A Bison parser, made from %%filename - by GNU bison %%version. */ +/* A Bison parser, made from %%{filename} + by GNU bison %%{version}. */ /* Skeleton output parser for bison, - Copyright 1984, 1989, 1990, 2000, 2001 Free Software Foundation, Inc. + Copyright 1984, 1989, 1990, 2000, 2001, 2002 Free Software Foundation, Inc. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -31,92 +32,47 @@ It was written by Richard Stallman by simplifying the hairy parser used when %semantic_parser is specified. */ -#define YYBISON 1 /* Identify Bison output. */ -#define YYPURE %%pure /* Identify pure parsers. */ +/* Identify Bison output. */ +#define YYBISON 1 -#include +/* Pure parsers. */ +#define YYPURE %%{pure} -/* If name_prefix is specify substitute the variables and functions +/* Using locations. */ +#define YYLSP_NEEDED %%{locations-flag} + +/* If NAME_PREFIX is specified substitute the variables and functions names. */ -#define yyparse %%prefix##parse -#define yylex %%prefix##lex -#define yyerror %%prefix##error -#define yylval %%prefix##lval -#define yychar %%prefix##char -#define yydebug %%prefix##debug -#define yynerrs %%prefix##nerrs +#define yyparse %%{prefix}parse +#define yylex %%{prefix}lex +#define yyerror %%{prefix}error +#define yylval %%{prefix}lval +#define yychar %%{prefix}char +#define yydebug %%{prefix}debug +#define yynerrs %%{prefix}nerrs +#if YYLSP_NEEDED +# define yylloc %%{prefix}lloc +#endif -/* Copy the user declarations. */ -#line %%input-line "%%filename" -%%prologue -#line %%line "%%skeleton" -#ifndef __cplusplus -# ifndef __STDC__ -# define const -# endif -#endif +/* Copy the user declarations. */ +%%{prologue} -#ifndef YYSTACK_USE_ALLOCA -# ifdef alloca -# define YYSTACK_USE_ALLOCA 1 -# else /* alloca not defined */ -# ifdef __GNUC__ -# define YYSTACK_USE_ALLOCA 1 -# define alloca __builtin_alloca -# else /* not GNU C. */ -# if (!defined (__STDC__) && defined (sparc)) || defined (__sparc__) || defined (__sparc) || defined (__sgi) || (defined (__sun) && defined (__i386)) -# define YYSTACK_USE_ALLOCA 1 -# include -# else /* not sparc */ - /* We think this test detects Watcom and Microsoft C. */ - /* This used to test MSDOS, but that is a bad idea since that - symbol is in the user namespace. */ -# if (defined (_MSDOS) || defined (_MSDOS_)) && !defined (__TURBOC__) -# if 0 - /* No need for malloc.h, which pollutes the namespace; instead, - just don't use alloca. */ -# include -# endif -# else /* not MSDOS, or __TURBOC__ */ -# if defined(_AIX) - /* I don't know what this was needed for, but it pollutes the - namespace. So I turned it off. rms, 2 May 1997. */ - /* #include */ - #pragma alloca -# define YYSTACK_USE_ALLOCA 1 -# else /* not MSDOS, or __TURBOC__, or _AIX */ -# if 0 - /* 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 -# define YYSTACK_USE_ALLOCA 0 +/* Enabling traces. */ +#ifndef YYDEBUG +# define YYDEBUG %%{debug} #endif -#if YYSTACK_USE_ALLOCA -# define YYSTACK_ALLOC alloca -/* Pacify GCC's `empty if-body' warning. */ -# define YYSTACK_FREE(Ptr) do { /* empty */; } while (0) +/* Enabling verbose error messages. */ +#ifdef YYERROR_VERBOSE +# undef YYERROR_VERBOSE +# define YYERROR_VERBOSE 1 #else -# define YYSTACK_ALLOC malloc -# define YYSTACK_FREE(Ptr) free (Ptr) +# define YYERROR_VERBOSE %%{error-verbose} #endif -#line %%input-line "%%filename" #ifndef YYSTYPE -typedef %%stype yystype; +typedef %%{stype} yystype; # define YYSTYPE yystype #endif @@ -128,127 +84,179 @@ typedef struct yyltype int last_line; int last_column; } yyltype; -# define YYLTYPE %%ltype +# define YYLTYPE %%{ltype} +#endif + +/* Line %%{skeleton-line} of %%{skeleton}. */ +#line %%{line} "%%{parser-file-name}" + +/* All symbols defined below should begin with yy or YY, to avoid + infringing on user name space. This should be done even for local + variables, as they might otherwise be expanded by user macros. + There are some unavoidable exceptions within include files to + define necessary library symbols; they are noted "INFRINGES ON + USER NAME SPACE" below. */ + +#ifdef __cplusplus +# define YYSTD(x) std::x +#else +# define YYSTD(x) x #endif -#line %%line "%%skeleton" +#if ! defined (yyoverflow) || defined (YYERROR_VERBOSE) + +/* The parser invokes alloca or malloc; define the necessary symbols. */ + +# if YYSTACK_USE_ALLOCA +# define YYSTACK_ALLOC alloca +# define YYSIZE_T YYSTD (size_t) +# else +# ifndef YYSTACK_USE_ALLOCA +# if defined (alloca) || defined (_ALLOCA_H) +# define YYSTACK_ALLOC alloca +# define YYSIZE_T YYSTD (size_t) +# else +# ifdef __GNUC__ +# define YYSTACK_ALLOC __builtin_alloca +# endif +# endif +# endif +# endif + +# ifdef YYSTACK_ALLOC + /* Pacify GCC's `empty if-body' warning. */ +# define YYSTACK_FREE(Ptr) do { /* empty */; } while (0) +# else +# ifdef __cplusplus +# include /* INFRINGES ON USER NAME SPACE */ +# define YYSIZE_T std::size_t +# else +# ifdef __STDC__ +# include /* INFRINGES ON USER NAME SPACE */ +# define YYSIZE_T size_t +# endif +# endif +# define YYSTACK_ALLOC YYSTD (malloc) +# define YYSTACK_FREE YYSTD (free) +# endif + /* A type that is properly aligned for any stack member. */ union yyalloc { - short yys; - YYSTYPE yyv; -#if YYLSP_NEEDED - YYLTYPE yyl; -#endif + short yyss; + YYSTYPE yyvs; +# if YYLSP_NEEDED + YYLTYPE yyls; +# endif }; /* 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 N elements. */ -#if YYLSP_NEEDED -# define YYSTACK_BYTES(N) \ +# if YYLSP_NEEDED +# define YYSTACK_BYTES(N) \ ((N) * (sizeof (short) + sizeof (YYSTYPE) + sizeof (YYLTYPE)) \ + 2 * YYSTACK_GAP_MAX) -#else -# define YYSTACK_BYTES(N) \ +# else +# define YYSTACK_BYTES(N) \ ((N) * (sizeof (short) + sizeof (YYSTYPE)) \ + YYSTACK_GAP_MAX) -#endif +# endif /* 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 stack. Advance YYPTR to a properly aligned location for the next stack. */ -#define YYSTACK_RELOCATE(Type, Stack) \ -do \ - { \ - size_t yynewbytes; \ - __yy_memcpy (yyptr, (char *) (Stack), size * sizeof (Type)); \ - (Stack) = (Type *) yyptr; \ - yynewbytes = yystacksize * sizeof (Type) + YYSTACK_GAP_MAX; \ - yynewbytes -= yynewbytes % sizeof (union yyalloc); \ - yyptr += yynewbytes; \ - } \ -while (0) - -#ifndef YYDEBUG -# define YYDEBUG %%debug -#endif - -#ifdef YYERROR_VERBOSE -# undef YYERROR_VERBOSE -#endif - -#define YYERROR_VERBOSE %%error-verbose +# define YYSTACK_RELOCATE(Type, Stack) \ + do \ + { \ + YYSIZE_T yynewbytes; \ + yymemcpy ((char *) yyptr, (char *) (Stack), \ + yysize * (YYSIZE_T) sizeof (Type)); \ + Stack = &yyptr->Stack; \ + yynewbytes = yystacksize * sizeof (Type) + YYSTACK_GAP_MAX; \ + yyptr += yynewbytes / sizeof (*yyptr); \ + } \ + while (0) + +#endif /* ! defined (yyoverflow) || YYERROR_VERBOSE */ /* Tokens. */ -%%tokendef - -#define YYFINAL %%final -#define YYFLAG %%flag -#define YYNTBASE %%ntbase -#define YYLAST %%last - -#define YYNTOKENS %%ntokens -#define YYNNTS %%nnts -#define YYNRULES %%nrules -#define YYNSTATES %%nstates -#define YYMAXUTOK %%maxtok - -/* YYTRANSLATE(YYLEX) -- Bison token number corresponding to YYLEX. */ -#define YYTRANSLATE(x) ((unsigned)(x) <= %%maxtok ? yytranslate[x] : %%nsym) - -/* YYTRANSLATE[YYLEX] -- Bison token number corresponding to YYLEX. */ +%%{tokendef} + +/* YYFINAL -- State number of the termination state. */ +#define YYFINAL %%{final} +#define YYFLAG %%{flag} +#define YYLAST %%{last} + +/* YYNTOKENS -- Number of terminals. */ +#define YYNTOKENS %%{ntokens} +/* YYNNTS -- Number of nonterminals. */ +#define YYNNTS %%{nnts} +/* YYNRULES -- Number of rules. */ +#define YYNRULES %%{nrules} +/* YYNRULES -- Number of states. */ +#define YYNSTATES %%{nstates} +#define YYMAXUTOK %%{maxtok} + +/* YYTRANSLATE(YYLEX) -- Bison symbol number corresponding to YYLEX. */ +#define YYTRANSLATE(x) ((unsigned)(x) <= %%{maxtok} ? yytranslate[x] : %%{nsym}) + +/* YYTRANSLATE[YYLEX] -- Bison symbol number corresponding to YYLEX. */ static const char yytranslate[] = { - %%translate + %%{translate} }; #if YYDEBUG +/* YYPRHS[YYN] -- Index of the first RHS symbol of rule number YYN in + YYRHS. */ static const short yyprhs[] = { - %%prhs + %%{prhs} }; +/* YYRHS -- A `-1'-separated list of the rules' RHS. */ static const short yyrhs[] = { - %%rhs + %%{rhs} }; /* YYRLINE[YYN] -- source line where rule number YYN was defined. */ static const short yyrline[] = { - %%rline + %%{rline} }; #endif -#if YYDEBUG || YYERROR_VERBOSE -/* YYTNME[TOKEN_NUM] -- String name of the token TOKEN_NUM. */ +#if (YYDEBUG) || YYERROR_VERBOSE +/* YYTNME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM. + First, the terminals, then, starting at YYNTOKENS, nonterminals. */ static const char *const yytname[] = { - %%tname + %%{tname} }; #endif /* YYTOKNUM[YYN] -- Index in YYTNAME corresponding to YYLEX. */ static const short yytoknum[] = { - %%toknum + %%{toknum} }; /* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */ static const short yyr1[] = { - %%r1 + %%{r1} }; /* YYR2[YYN] -- Number of symbols composing right hand side of rule YYN. */ static const short yyr2[] = { - %%r2 + %%{r2} }; /* YYDEFACT[S] -- default rule to reduce with in state S when YYTABLE @@ -256,34 +264,63 @@ static const short yyr2[] = error. */ static const short yydefact[] = { - %%defact + %%{defact} }; +/* YYPGOTO[NTERM-NUM]. */ static const short yydefgoto[] = { - %%defgoto + %%{defgoto} }; +/* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing + STATE-NUM. */ static const short yypact[] = { - %%pact + %%{pact} }; +/* YYPGOTO[NTERM-NUM]. */ static const short yypgoto[] = { - %%pgoto + %%{pgoto} }; +/* YYTABLE[YYPACT[STATE-NUM]]. What to do in state STATE-NUM. If + positive, shift that token. If negative, reduce the rule which + number is the opposite. If zero, do what YYDEFACT says. */ static const short yytable[] = { - %%table + %%{table} }; static const short yycheck[] = { - %%check + %%{check} }; + +#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) +# ifdef __cplusplus +# include /* INFRINGES ON USER NAME SPACE */ +# define YYSIZE_T std::size_t +# else +# ifdef __STDC__ +# include /* INFRINGES ON USER NAME SPACE */ +# define YYSIZE_T size_t +# endif +# endif +#endif +#if ! defined (YYSIZE_T) +# define YYSIZE_T unsigned int +#endif + #define yyerrok (yyerrstatus = 0) #define yyclearin (yychar = YYEMPTY) #define YYEMPTY -2 @@ -306,14 +343,14 @@ do \ if (yychar == YYEMPTY && yylen == 1) \ { \ yychar = (Token); \ - yylval = (Value); \ + yylval = (Value); \ yychar1 = YYTRANSLATE (yychar); \ YYPOPSTACK; \ goto yybackup; \ } \ else \ { \ - yyerror ("syntax error: cannot back up"); \ + yyerror ("syntax error: cannot back up"); \ YYERROR; \ } \ while (0) @@ -334,9 +371,6 @@ while (0) Current.last_column = Rhs[N].last_column; #endif -/* Definition of YYLSP_NEEDED. */ -#define YYLSP_NEEDED %%locations-flag - /* YYLEX -- calling `yylex' with the right arguments. */ #if YYPURE @@ -359,10 +393,20 @@ while (0) /* Enable debugging if requested. */ #if YYDEBUG + +# ifndef YYFPRINTF +# ifdef __cplusplus +# include /* INFRINGES ON USER NAME SPACE */ +# else +# include /* INFRINGES ON USER NAME SPACE */ +# endif +# define YYFPRINTF YYSTD (fprintf) +# endif + # define YYDPRINTF(Args) \ do { \ if (yydebug) \ - fprintf Args; \ + YYFPRINTF Args; \ } while (0) /* Nonzero means print parse trace. [The following comment makes no sense to me. Could someone clarify it? --akim] Since this is @@ -375,7 +419,7 @@ int yydebug; /* YYINITDEPTH -- initial size of the parser's stacks. */ #ifndef YYINITDEPTH -# define YYINITDEPTH %%initdepth +# define YYINITDEPTH %%{initdepth} #endif /* YYMAXDEPTH -- maximum size the stacks can grow to (effective only @@ -390,39 +434,92 @@ int yydebug; #endif #ifndef YYMAXDEPTH -# define YYMAXDEPTH %%maxdepth +# define YYMAXDEPTH %%{maxdepth} #endif -#if __GNUC__ > 1 /* GNU C and GNU C++ define this. */ -# define __yy_memcpy(To, From, Count) __builtin_memcpy (To, From, Count) -#else /* not GNU C or C++ */ +#if ! defined (yyoverflow) && ! defined (yymemcpy) +# if __GNUC__ > 1 /* GNU C and GNU C++ define this. */ +# define yymemcpy __builtin_memcpy +# else /* not GNU C or C++ */ /* This is the most reliable way to avoid incompatibilities in available built-in functions on various systems. */ static void -# ifndef __cplusplus -__yy_memcpy (to, from, count) - char *to; - const char *from; - size_t count; -# else /* __cplusplus */ -__yy_memcpy (char *to, const char *from, size_t count) -# endif +# if defined (__STDC__) || defined (__cplusplus) +yymemcpy (char *yyto, const char *yyfrom, YYSIZE_T yycount) +# else +yymemcpy (yyto, yyfrom, yycount) + char *yyto; + const char *yyfrom; + YYSIZE_T yycount; +# endif { - register const char *f = from; - register char *t = to; - register size_t i = count; + register const char *yyf = yyfrom; + register char *yyt = yyto; + register YYSIZE_T yyi = yycount; - while (i-- != 0) - *t++ = *f++; + while (yyi-- != 0) + *yyt++ = *yyf++; } +# endif #endif - +#if YYERROR_VERBOSE -#line %%line "%%skeleton" +# 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 * +# if defined (__STDC__) || defined (__cplusplus) +yystpcpy (char *yydest, const char *yysrc) +# else +yystpcpy (yydest, yysrc) + 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 /* !YYERROR_VERBOSE */ + + /* The user can define YYPARSE_PARAM as the name of an argument to be passed into yyparse. The argument should have type void *. @@ -455,7 +552,7 @@ int yyparse (void); /* YY_DECL_VARIABLES -- depending whether we use a pure parser, variables are global, or local to YYPARSE. */ -#define _YY_DECL_VARIABLES \ +#define YY_DECL_NON_LSP_VARIABLES \ /* The lookahead symbol. */ \ int yychar; \ \ @@ -467,13 +564,13 @@ int yynerrs; #if YYLSP_NEEDED # define YY_DECL_VARIABLES \ -_YY_DECL_VARIABLES \ +YY_DECL_NON_LSP_VARIABLES \ \ /* Location data for the lookahead symbol. */ \ YYLTYPE yylloc; #else # define YY_DECL_VARIABLES \ -_YY_DECL_VARIABLES +YY_DECL_NON_LSP_VARIABLES #endif /* If nonreentrant, generate the variables here. */ @@ -530,14 +627,14 @@ yyparse (YYPARSE_PARAM_ARG) # define YYPOPSTACK (yyvsp--, yyssp--) #endif - size_t yystacksize = YYINITDEPTH; + YYSIZE_T yystacksize = YYINITDEPTH; /* The variables used to return semantic value and location from the action routines. */ YYSTYPE yyval; -# if YYLSP_NEEDED +#if YYLSP_NEEDED YYLTYPE yyloc; -# endif +#endif /* When reducing, the number of symbols on the RHS of the reduced rule. */ @@ -577,7 +674,7 @@ yyparse (YYPARSE_PARAM_ARG) if (yyssp >= yyss + yystacksize - 1) { /* 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 { @@ -594,15 +691,15 @@ yyparse (YYPARSE_PARAM_ARG) /* This used to be a conditional around just the two extra args, but that might be undefined if yyoverflow is a macro. */ yyoverflow ("parser stack overflow", - &yyss1, size * sizeof (*yyssp), - &yyvs1, size * sizeof (*yyvsp), - &yyls1, size * sizeof (*yylsp), + &yyss1, yysize * sizeof (*yyssp), + &yyvs1, yysize * sizeof (*yyvsp), + &yyls1, yysize * sizeof (*yylsp), &yystacksize); yyls = yyls1; # else yyoverflow ("parser stack overflow", - &yyss1, size * sizeof (*yyssp), - &yyvs1, size * sizeof (*yyvsp), + &yyss1, yysize * sizeof (*yyssp), + &yyvs1, yysize * sizeof (*yyvsp), &yystacksize); # endif yyss = yyss1; @@ -618,7 +715,8 @@ yyparse (YYPARSE_PARAM_ARG) { short *yyss1 = yyss; - char *yyptr = (char *) YYSTACK_ALLOC (YYSTACK_BYTES (yystacksize)); + union yyalloc *yyptr = + (union yyalloc *) YYSTACK_ALLOC (YYSTACK_BYTES (yystacksize)); if (! yyptr) goto yyoverflowlab; YYSTACK_RELOCATE (short, yyss); @@ -632,10 +730,10 @@ yyparse (YYPARSE_PARAM_ARG) } #endif /* no yyoverflow */ - yyssp = yyss + size - 1; - yyvsp = yyvs + size - 1; + yyssp = yyss + yysize - 1; + yyvsp = yyvs + yysize - 1; #if YYLSP_NEEDED - yylsp = yyls + size - 1; + yylsp = yyls + yysize - 1; #endif YYDPRINTF ((stderr, "Stack size increased to %lu\n", @@ -693,13 +791,14 @@ yybackup: which are defined only if `YYDEBUG' is set. */ if (yydebug) { - fprintf (stderr, "Next token is %d (%s", yychar, yytname[yychar1]); + YYFPRINTF (stderr, "Next token is %d (%s", + yychar, yytname[yychar1]); /* Give the individual parser a way to print the precise meaning of a token, for further debugging info. */ # ifdef YYPRINT YYPRINT (stderr, yychar, yylval); # endif - fprintf (stderr, ")\n"); + YYFPRINTF (stderr, ")\n"); } #endif } @@ -731,7 +830,8 @@ yybackup: YYACCEPT; /* Shift the lookahead token. */ - YYDPRINTF ((stderr, "Shifting token %d (%s), ", yychar, yytname[yychar1])); + YYDPRINTF ((stderr, "Shifting token %d (%s), ", + yychar, yytname[yychar1])); /* Discard the token being shifted unless it is eof. */ if (yychar != YYEOF) @@ -790,22 +890,24 @@ yyreduce: are defined only if `YYDEBUG' is set. */ if (yydebug) { - int i; + int yyi; - fprintf (stderr, "Reducing via rule %d (line %d), ", - yyn, yyrline[yyn]); + YYFPRINTF (stderr, "Reducing via rule %d (line %d), ", + yyn - 1, yyrline[yyn]); /* Print the symbols being reduced, and their result. */ - for (i = yyprhs[yyn]; yyrhs[i] > 0; i++) - fprintf (stderr, "%s ", yytname[yyrhs[i]]); - fprintf (stderr, " -> %s\n", yytname[yyr1[yyn]]); + for (yyi = yyprhs[yyn]; yyrhs[yyi] >= 0; yyi++) + YYFPRINTF (stderr, "%s ", yytname[yyrhs[yyi]]); + YYFPRINTF (stderr, " -> %s\n", yytname[yyr1[yyn]]); } #endif switch (yyn) { - %%action + %%{actions} } -#line %%line "%%skeleton" + +/* Line %%{skeleton-line} of %%{skeleton}. */ +#line %%{line} "%%{parser-file-name}" yyvsp -= yylen; yyssp -= yylen; @@ -816,11 +918,11 @@ yyreduce: #if YYDEBUG if (yydebug) { - short *ssp1 = yyss - 1; - fprintf (stderr, "state stack now"); - while (ssp1 != yyssp) - fprintf (stderr, " %d", *++ssp1); - fprintf (stderr, "\n"); + short *yyssp1 = yyss - 1; + YYFPRINTF (stderr, "state stack now"); + while (yyssp1 != yyssp) + YYFPRINTF (stderr, " %d", *++yyssp1); + YYFPRINTF (stderr, "\n"); } #endif @@ -835,11 +937,11 @@ yyreduce: yyn = yyr1[yyn]; - yystate = yypgoto[yyn - YYNTBASE] + *yyssp; + yystate = yypgoto[yyn - YYNTOKENS] + *yyssp; if (yystate >= 0 && yystate <= YYLAST && yycheck[yystate] == *yyssp) yystate = yytable[yystate]; else - yystate = yydefgoto[yyn - YYNTBASE]; + yystate = yydefgoto[yyn - YYNTOKENS]; goto yynewstate; @@ -858,42 +960,44 @@ yyerrlab: if (yyn > YYFLAG && yyn < YYLAST) { - size_t size = 0; - char *msg; - int x, count; + YYSIZE_T yysize = 0; + char *yymsg; + int yyx, yycount; - count = 0; - /* Start X at -YYN if negative to avoid negative indexes in + yycount = 0; + /* Start YYX at -YYN if negative to avoid negative indexes in YYCHECK. */ - for (x = yyn < 0 ? -yyn : 0; - x < (int) (sizeof (yytname) / sizeof (char *)); x++) - if (yycheck[x + yyn] == x) - size += strlen (yytname[x]) + 15, count++; - size += strlen ("parse error, unexpected ") + 1; - size += strlen (yytname[YYTRANSLATE (yychar)]); - msg = (char *) malloc (size); - if (msg != 0) + for (yyx = yyn < 0 ? -yyn : 0; + yyx < (int) (sizeof (yytname) / sizeof (char *)); yyx++) + if (yycheck[yyx + yyn] == yyx) + yysize += yystrlen (yytname[yyx]) + 15, yycount++; + yysize += yystrlen ("parse error, unexpected ") + 1; + yysize += yystrlen (yytname[YYTRANSLATE (yychar)]); + yymsg = (char *) YYSTACK_ALLOC (yysize); + if (yymsg != 0) { - strcpy (msg, "parse error, unexpected "); - strcat (msg, yytname[YYTRANSLATE (yychar)]); + char *yyp = yystpcpy (yymsg, "parse error, unexpected "); + yyp = yystpcpy (yyp, yytname[YYTRANSLATE (yychar)]); - if (count < 5) + if (yycount < 5) { - count = 0; - for (x = yyn < 0 ? -yyn : 0; - x < (int) (sizeof (yytname) / sizeof (char *)); x++) - if (yycheck[x + yyn] == x) + yycount = 0; + for (yyx = yyn < 0 ? -yyn : 0; + yyx < (int) (sizeof (yytname) / sizeof (char *)); + yyx++) + if (yycheck[yyx + yyn] == yyx) { - strcat (msg, count == 0 ? ", expecting " : " or "); - strcat (msg, yytname[x]); - count++; + const char *yyq = ! yycount ? ", expecting " : " or "; + yyp = yystpcpy (yyp, yyq); + yyp = yystpcpy (yyp, yytname[yyx]); + yycount++; } } - yyerror (msg); - free (msg); - } - else - yyerror ("parse error; also virtual memory exhausted"); + yyerror (yymsg); + YYSTACK_FREE (yymsg); + } + else + yyerror ("parse error; also virtual memory exhausted"); } else #endif /* YYERROR_VERBOSE */ @@ -959,11 +1063,11 @@ yyerrpop: #if YYDEBUG if (yydebug) { - short *ssp1 = yyss - 1; - fprintf (stderr, "Error: state stack now"); - while (ssp1 != yyssp) - fprintf (stderr, " %d", *++ssp1); - fprintf (stderr, "\n"); + short *yyssp1 = yyss - 1; + YYFPRINTF (stderr, "Error: state stack now"); + while (yyssp1 != yyssp) + YYFPRINTF (stderr, " %d", *++yyssp1); + YYFPRINTF (stderr, "\n"); } #endif @@ -1034,5 +1138,4 @@ yyreturn: return yyresult; } -#line %%input-line "%%filename" -%%epilogue +%%{epilogue}