/[bison]/bison/src/bison.simple
ViewVC logotype

Diff of /bison/src/bison.simple

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.53.2.9 by akim, Fri Nov 30 11:11:08 2001 UTC revision 1.53.2.10 by akim, Fri Nov 30 13:14:10 2001 UTC
# Line 28  Line 28 
28     It was written by Richard Stallman by simplifying the hairy parser     It was written by Richard Stallman by simplifying the hairy parser
29     used when %semantic_parser is specified.  */     used when %semantic_parser is specified.  */
30    
31  #ifndef YYSTACK_USE_ALLOCA  /* All symbols defined below should begin with yy or YY, to avoid
32  # ifdef alloca     infringing on user name space.  This should be done even for local
33  #  define YYSTACK_USE_ALLOCA 1     variables, as they might otherwise be expanded by user macros.
34  # else /* alloca not defined */     There are some unavoidable exceptions within include files to
35  #  ifdef __GNUC__     define necessary C library symbols; they are noted "INFRINGES ON
36  #   define YYSTACK_USE_ALLOCA 1     USER NAME SPACE" below.  */
37  #   define alloca __builtin_alloca  
38  #  else /* not GNU C.  */  #if ! defined (yyoverflow) || defined (YYERROR_VERBOSE)
39  #   if (!defined (__STDC__) && defined (sparc)) || defined (__sparc__) || defined (__sparc) || defined (__sgi) || (defined (__sun) && defined (__i386))  
40  #    define YYSTACK_USE_ALLOCA 1  /* The parser invokes alloca or malloc; define the necessary symbols.  */
41  #    include <alloca.h>  
42  #   else /* not sparc */  # if YYSTACK_USE_ALLOCA
43       /* We think this test detects Watcom and Microsoft C.  */  #  define YYSTACK_ALLOC alloca
44       /* This used to test MSDOS, but that is a bad idea since that  #  define YYSIZE_T size_t
45          symbol is in the user namespace.  */  # else
46  #    if (defined (_MSDOS) || defined (_MSDOS_)) && !defined (__TURBOC__)  #  ifndef YYSTACK_USE_ALLOCA
47  #     if 0  #   if defined (alloca) || defined (_ALLOCA_H)
48         /* No need for malloc.h, which pollutes the namespace; instead,  #    define YYSTACK_ALLOC alloca
49            just don't use alloca.  */  #    define YYSIZE_T size_t
50  #      include <malloc.h>  #   else
51    #    if defined (__GNUC__) || defined (_AIX) || defined (__hpux)
52    #     define YYSTACK_ALLOC __builtin_alloca
53    #    endif
54    #    ifndef __GNUC__
55    #     ifdef _AIX
56     #     pragma alloca
57  #     endif  #     endif
58  #    else /* not MSDOS, or __TURBOC__ */  #     if defined (__sgi) || defined (__sparc__) || defined (__sparc) || defined (__sun)
59  #     if defined(_AIX)  #      include <alloca.h> /* INFRINGES ON USER NAME SPACE */
60         /* I don't know what this was needed for, but it pollutes the  #      define YYSTACK_ALLOC alloca
61            namespace.  So I turned it off.  rms, 2 May 1997.  */  #      define YYSIZE_T size_t
62         /* #include <malloc.h>  */  #     endif
63   #pragma alloca  #    endif
64  #      define YYSTACK_USE_ALLOCA 1  #   endif
65  #     else /* not MSDOS, or __TURBOC__, or _AIX */  #  endif
66  #      if 0  # endif
67          /* haible@ilog.fr says this works for HPUX 9.05 and up, and on  
68             HPUX 10.  Eventually we can turn this on.  */  # ifdef YYSTACK_ALLOC
69  #       ifdef __hpux     /* Pacify GCC's `empty if-body' warning. */
70  #        define YYSTACK_USE_ALLOCA 1  #  define YYSTACK_FREE(Ptr) do { /* empty */; } while (0)
71  #        define alloca __builtin_alloca  # else
72  #       endif /* __hpux */  #  define YYSTACK_ALLOC malloc
73  #      endif  #  define YYSTACK_FREE(Ptr) free (Ptr)
74  #     endif /* not _AIX */  #  if defined (__STDC__) || defined (__cplusplus)
75  #    endif /* not MSDOS, or __TURBOC__ */  #   include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
76  #   endif /* not sparc */  #   define YYSIZE_T size_t
77  #  endif /* not GNU C */  #  endif
78  # endif /* alloca not defined */  # endif
 #endif /* YYSTACK_USE_ALLOCA not defined */  
   
 #ifndef YYSTACK_USE_ALLOCA  
 # define YYSTACK_USE_ALLOCA 0  
 #endif  
   
 #if YYSTACK_USE_ALLOCA  
 # define YYSTACK_ALLOC alloca  
 /* Pacify GCC's `empty if-body' warning. */  
 # define YYSTACK_FREE(Ptr) do { /* empty */; } while (0)  
 #else  
 # define YYSTACK_ALLOC malloc  
 # define YYSTACK_FREE(Ptr) free (Ptr)  
 #endif  
79    
80  /* A type that is properly aligned for any stack member.  */  /* A type that is properly aligned for any stack member.  */
81  union yyalloc  union yyalloc
82  {  {
83    short yys;    short yys;
84    YYSTYPE yyv;    YYSTYPE yyv;
85  #if YYLSP_NEEDED  # if YYLSP_NEEDED
86    YYLTYPE yyl;    YYLTYPE yyl;
87  #endif  # endif
88  };  };
89    
90  /* 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.  */
91  #define YYSTACK_GAP_MAX (sizeof (union yyalloc) - 1)  # define YYSTACK_GAP_MAX (sizeof (union yyalloc) - 1)
92    
93  /* 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
94     N elements.  */     N elements.  */
95  #if YYLSP_NEEDED  # if YYLSP_NEEDED
96  # define YYSTACK_BYTES(N) \  #  define YYSTACK_BYTES(N) \
97      ((N) * (sizeof (short) + sizeof (YYSTYPE) + sizeof (YYLTYPE))       \       ((N) * (sizeof (short) + sizeof (YYSTYPE) + sizeof (YYLTYPE))      \
98       + 2 * YYSTACK_GAP_MAX)        + 2 * YYSTACK_GAP_MAX)
99  #else  # else
100  # define YYSTACK_BYTES(N) \  #  define YYSTACK_BYTES(N) \
101      ((N) * (sizeof (short) + sizeof (YYSTYPE))                          \       ((N) * (sizeof (short) + sizeof (YYSTYPE))                         \
102       + YYSTACK_GAP_MAX)        + YYSTACK_GAP_MAX)
103  #endif  # endif
104    
105  /* 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
106     local variables SIZE and YYSTACKSIZE give the old and new number of     local variables YYSIZE and YYSTACKSIZE give the old and new number of
107     elements in the stack, and YYPTR gives the new location of the     elements in the stack, and YYPTR gives the new location of the
108     stack.  Advance YYPTR to a properly aligned location for the next     stack.  Advance YYPTR to a properly aligned location for the next
109     stack.  */     stack.  */
110  #define YYSTACK_RELOCATE(Type, Stack)                                   \  # define YYSTACK_RELOCATE(Type, Stack)                                  \
111  do                                                                      \      do                                                                  \
112    {                                                                     \        {                                                                 \
113      size_t yynewbytes;                                                  \          YYSIZE_T yynewbytes;                                            \
114      __yy_memcpy (yyptr, (char *) (Stack), size * sizeof (Type));        \          yymemcpy (yyptr, (char *) (Stack),                              \
115      (Stack) = (Type *) yyptr;                                           \                    yysize * (YYSIZE_T) sizeof (Type));                   \
116      yynewbytes = yystacksize * sizeof (Type) + YYSTACK_GAP_MAX;         \          (Stack) = (Type *) yyptr;                                       \
117      yynewbytes -= yynewbytes % sizeof (union yyalloc);                  \          yynewbytes = yystacksize * sizeof (Type) + YYSTACK_GAP_MAX;     \
118      yyptr += yynewbytes;                                                \          yynewbytes -= yynewbytes % sizeof (union yyalloc);              \
119    }                                                                     \          yyptr += yynewbytes;                                            \
120  while (0)        }                                                                 \
121        while (0)
122    
123    #endif /* ! defined (yyoverflow) || defined (YYERROR_VERBOSE) */
124    
125    
126    #if ! defined (YYSIZE_T) && defined (__SIZE_TYPE__)
127    # define YYSIZE_T __SIZE_TYPE__
128    #endif
129    #if ! defined (YYSIZE_T) && defined (size_t)
130    # define YYSIZE_T size_t
131    #endif
132    #if ! defined (YYSIZE_T) && (defined (__STDC__) || defined (__cplusplus))
133    # include <stddef.h> /* INFRINGES ON USER NAME SPACE */
134    # define YYSIZE_T size_t
135    #endif
136    #if ! defined (YYSIZE_T)
137    # define YYSIZE_T unsigned int
138    #endif
139    
140  #define yyerrok         (yyerrstatus = 0)  #define yyerrok         (yyerrstatus = 0)
141  #define yyclearin       (yychar = YYEMPTY)  #define yyclearin       (yychar = YYEMPTY)
# Line 197  while (0) Line 207  while (0)
207    
208  /* Enable debugging if requested.  */  /* Enable debugging if requested.  */
209  #if YYDEBUG  #if YYDEBUG
210    # include <stdio.h>
211  # define YYDPRINTF(Args)                        \  # define YYDPRINTF(Args)                        \
212  do {                                            \  do {                                            \
213    if (yydebug)                                  \    if (yydebug)                                  \
# Line 231  int yydebug; Line 242  int yydebug;
242  # define YYMAXDEPTH 10000  # define YYMAXDEPTH 10000
243  #endif  #endif
244    
245  #if __GNUC__ > 1                /* GNU C and GNU C++ define this.  */  #if ! defined (yyoverflow) && ! defined (yymemcpy)
246  # define __yy_memcpy(To, From, Count)   __builtin_memcpy (To, From, Count)  # if __GNUC__ > 1               /* GNU C and GNU C++ define this.  */
247  #else                           /* not GNU C or C++ */  #  define yymemcpy __builtin_memcpy
248    # else                          /* not GNU C or C++ */
249    
250  /* This is the most reliable way to avoid incompatibilities  /* This is the most reliable way to avoid incompatibilities
251     in available built-in functions on various systems.  */     in available built-in functions on various systems.  */
252  static void  static void
253  # ifndef __cplusplus  #  if defined (__STDC__) || defined (__cplusplus)
254  __yy_memcpy (to, from, count)  yymemcpy (char *yyto, const char *yyfrom, YYSIZE_T yycount)
255       char *to;  #  else
256       const char *from;  yymemcpy (yyto, yyfrom, yycount)
257       size_t count;       char *yyto;
258  # else /* __cplusplus */       const char *yyfrom;
259  __yy_memcpy (char *to, const char *from, size_t count)       YYSIZE_T yycount;
260    #  endif
261    {
262      register const char *yyf = yyfrom;
263      register char *yyt = yyto;
264      register YYSIZE_T yyi = yycount;
265    
266      while (yyi-- != 0)
267        *yyt++ = *yyf++;
268    }
269  # endif  # endif
270    #endif
271    
272    #ifdef YYERROR_VERBOSE
273    
274    # ifndef yystrlen
275    #  if defined (__GLIBC__) && defined (_STRING_H)
276    #   define yystrlen strlen
277    #  else
278    /* Return the length of YYSTR.  */
279    static YYSIZE_T
280    #   if defined (__STDC__) || defined (__cplusplus)
281    yystrlen (const char *yystr)
282    #   else
283    yystrlen (yystr)
284         const char *yystr;
285    #   endif
286  {  {
287    register const char *f = from;    register const char *yys = yystr;
   register char *t = to;  
   register size_t i = count;  
288    
289    while (i-- != 0)    while (*yys++ != '\0')
290      *t++ = *f++;      continue;
291    
292      return yys - yystr - 1;
293  }  }
294    #  endif
295    # endif
296    
297    # ifndef yystpcpy
298    #  if defined (__GLIBC__) && defined (_STRING_H) && defined (_GNU_SOURCE)
299    #   define yystpcpy stpcpy
300    #  else
301    /* Copy YYSRC to YYDEST, returning the address of the terminating '\0' in
302       YYDEST.  */
303    static char *
304    #   ifndef __cplusplus
305    yystpcpy (yydest, yysrc)
306         char *yydest;
307         const char *yysrc;
308    #   else
309    yystpcpy (char *yydest, const char *yysrc)
310    #   endif
311    {
312      register char *yyd = yydest;
313      register const char *yys = yysrc;
314    
315      while ((*yyd++ = *yys++) != '\0')
316        continue;
317    
318      return yyd - 1;
319    }
320    #  endif
321    # endif
322  #endif  #endif
323    
324  #line  #line
# Line 290  int yyparse (void); Line 354  int yyparse (void);
354  /* YY_DECL_VARIABLES -- depending whether we use a pure parser,  /* YY_DECL_VARIABLES -- depending whether we use a pure parser,
355     variables are global, or local to YYPARSE.  */     variables are global, or local to YYPARSE.  */
356    
357  #define _YY_DECL_VARIABLES                              \  #define YY_DECL_NON_LSP_VARIABLES                       \
358  /* The lookahead symbol.  */                            \  /* The lookahead symbol.  */                            \
359  int yychar;                                             \  int yychar;                                             \
360                                                          \                                                          \
# Line 302  int yynerrs; Line 366  int yynerrs;
366    
367  #if YYLSP_NEEDED  #if YYLSP_NEEDED
368  # define YY_DECL_VARIABLES                      \  # define YY_DECL_VARIABLES                      \
369  _YY_DECL_VARIABLES                              \  YY_DECL_NON_LSP_VARIABLES                       \
370                                                  \                                                  \
371  /* Location data for the lookahead symbol.  */  \  /* Location data for the lookahead symbol.  */  \
372  YYLTYPE yylloc;  YYLTYPE yylloc;
373  #else  #else
374  # define YY_DECL_VARIABLES                      \  # define YY_DECL_VARIABLES                      \
375  _YY_DECL_VARIABLES  YY_DECL_NON_LSP_VARIABLES
376  #endif  #endif
377    
378    
# Line 366  yyparse (YYPARSE_PARAM_ARG) Line 430  yyparse (YYPARSE_PARAM_ARG)
430  # define YYPOPSTACK   (yyvsp--, yyssp--)  # define YYPOPSTACK   (yyvsp--, yyssp--)
431  #endif  #endif
432    
433    size_t yystacksize = YYINITDEPTH;    YYSIZE_T yystacksize = YYINITDEPTH;
434    
435    
436    /* The variables used to return semantic value and location from the    /* The variables used to return semantic value and location from the
437       action routines.  */       action routines.  */
438    YYSTYPE yyval;    YYSTYPE yyval;
439  # if YYLSP_NEEDED  #if YYLSP_NEEDED
440    YYLTYPE yyloc;    YYLTYPE yyloc;
441  # endif  #endif
442    
443    /* When reducing, the number of symbols on the RHS of the reduced    /* When reducing, the number of symbols on the RHS of the reduced
444       rule. */       rule. */
# Line 414  yyparse (YYPARSE_PARAM_ARG) Line 478  yyparse (YYPARSE_PARAM_ARG)
478    if (yyssp >= yyss + yystacksize - 1)    if (yyssp >= yyss + yystacksize - 1)
479      {      {
480        /* Get the current used size of the three stacks, in elements.  */        /* Get the current used size of the three stacks, in elements.  */
481        size_t size = yyssp - yyss + 1;        YYSIZE_T yysize = yyssp - yyss + 1;
482    
483  #ifdef yyoverflow  #ifdef yyoverflow
484        {        {
# Line 431  yyparse (YYPARSE_PARAM_ARG) Line 495  yyparse (YYPARSE_PARAM_ARG)
495          /* This used to be a conditional around just the two extra args,          /* This used to be a conditional around just the two extra args,
496             but that might be undefined if yyoverflow is a macro.  */             but that might be undefined if yyoverflow is a macro.  */
497          yyoverflow ("parser stack overflow",          yyoverflow ("parser stack overflow",
498                      &yyss1, size * sizeof (*yyssp),                      &yyss1, yysize * sizeof (*yyssp),
499                      &yyvs1, size * sizeof (*yyvsp),                      &yyvs1, yysize * sizeof (*yyvsp),
500                      &yyls1, size * sizeof (*yylsp),                      &yyls1, yysize * sizeof (*yylsp),
501                      &yystacksize);                      &yystacksize);
502          yyls = yyls1;          yyls = yyls1;
503  # else  # else
504          yyoverflow ("parser stack overflow",          yyoverflow ("parser stack overflow",
505                      &yyss1, size * sizeof (*yyssp),                      &yyss1, yysize * sizeof (*yyssp),
506                      &yyvs1, size * sizeof (*yyvsp),                      &yyvs1, yysize * sizeof (*yyvsp),
507                      &yystacksize);                      &yystacksize);
508  # endif  # endif
509          yyss = yyss1;          yyss = yyss1;
# Line 469  yyparse (YYPARSE_PARAM_ARG) Line 533  yyparse (YYPARSE_PARAM_ARG)
533        }        }
534  #endif /* no yyoverflow */  #endif /* no yyoverflow */
535    
536        yyssp = yyss + size - 1;        yyssp = yyss + yysize - 1;
537        yyvsp = yyvs + size - 1;        yyvsp = yyvs + yysize - 1;
538  #if YYLSP_NEEDED  #if YYLSP_NEEDED
539        yylsp = yyls + size - 1;        yylsp = yyls + yysize - 1;
540  #endif  #endif
541    
542        YYDPRINTF ((stderr, "Stack size increased to %lu\n",        YYDPRINTF ((stderr, "Stack size increased to %lu\n",
# Line 628  yyreduce: Line 692  yyreduce:
692       are defined only if `YYDEBUG' is set.  */       are defined only if `YYDEBUG' is set.  */
693    if (yydebug)    if (yydebug)
694      {      {
695        int i;        int yyi;
696    
697        fprintf (stderr, "Reducing via rule %d (line %d), ",        fprintf (stderr, "Reducing via rule %d (line %d), ",
698                 yyn, yyrline[yyn]);                 yyn, yyrline[yyn]);
699    
700        /* Print the symbols being reduced, and their result.  */        /* Print the symbols being reduced, and their result.  */
701        for (i = yyprhs[yyn]; yyrhs[i] > 0; i++)        for (yyi = yyprhs[yyn]; yyrhs[yyi] > 0; yyi++)
702          fprintf (stderr, "%s ", yytname[yyrhs[i]]);          fprintf (stderr, "%s ", yytname[yyrhs[yyi]]);
703        fprintf (stderr, " -> %s\n", yytname[yyr1[yyn]]);        fprintf (stderr, " -> %s\n", yytname[yyr1[yyn]]);
704      }      }
705  #endif  #endif
# Line 651  yyreduce: Line 715  yyreduce:
715  #if YYDEBUG  #if YYDEBUG
716    if (yydebug)    if (yydebug)
717      {      {
718        short *ssp1 = yyss - 1;        short *yyssp1 = yyss - 1;
719        fprintf (stderr, "state stack now");        fprintf (stderr, "state stack now");
720        while (ssp1 != yyssp)        while (yyssp1 != yyssp)
721          fprintf (stderr, " %d", *++ssp1);          fprintf (stderr, " %d", *++yyssp1);
722        fprintf (stderr, "\n");        fprintf (stderr, "\n");
723      }      }
724  #endif  #endif
# Line 693  yyerrlab: Line 757  yyerrlab:
757    
758        if (yyn > YYFLAG && yyn < YYLAST)        if (yyn > YYFLAG && yyn < YYLAST)
759          {          {
760            size_t size = 0;            YYSIZE_T yysize = 0;
761            char *msg;            char *yymsg;
762            int x, count;            int yyx, yycount;
763    
764            count = 0;            yycount = 0;
765            /* Start X at -YYN if negative to avoid negative indexes in            /* Start YYX at -YYN if negative to avoid negative indexes in
766               YYCHECK.  */               YYCHECK.  */
767            for (x = yyn < 0 ? -yyn : 0;            for (yyx = yyn < 0 ? -yyn : 0;
768                 x < (int) (sizeof (yytname) / sizeof (char *)); x++)                 yyx < (int) (sizeof (yytname) / sizeof (char *)); yyx++)
769              if (yycheck[x + yyn] == x)              if (yycheck[yyx + yyn] == yyx)
770                size += strlen (yytname[x]) + 15, count++;                yysize += yystrlen (yytname[yyx]) + 15, yycount++;
771            size += strlen ("parse error, unexpected ") + 1;            yysize += yystrlen ("parse error, unexpected ") + 1;
772            size += strlen (yytname[YYTRANSLATE (yychar)]);            yysize += yystrlen (yytname[YYTRANSLATE (yychar)]);
773            msg = (char *) malloc (size);            yymsg = (char *) YYSTACK_ALLOC (yysize);
774            if (msg != 0)            if (yymsg != 0)
775              {              {
776                strcpy (msg, "parse error, unexpected ");                char *yyp = yystpcpy (yymsg, "parse error, unexpected ");
777                strcat (msg, yytname[YYTRANSLATE (yychar)]);                yyp = yystpcpy (yyp, yytname[YYTRANSLATE (yychar)]);
778    
779                if (count < 5)                if (yycount < 5)
780                  {                  {
781                    count = 0;                    yycount = 0;
782                    for (x = yyn < 0 ? -yyn : 0;                    for (yyx = yyn < 0 ? -yyn : 0;
783                         x < (int) (sizeof (yytname) / sizeof (char *)); x++)                         yyx < (int) (sizeof (yytname) / sizeof (char *));
784                      if (yycheck[x + yyn] == x)                         yyx++)
785                        if (yycheck[yyx + yyn] == yyx)
786                        {                        {
787                          strcat (msg, count == 0 ? ", expecting " : " or ");                          const char *yyq = ! yycount ? ", expecting " : " or ";
788                          strcat (msg, yytname[x]);                          yyp = yystpcpy (yyp, yyq);
789                          count++;                          yyp = yystpcpy (yyp, yytname[yyx]);
790                            yycount++;
791                        }                        }
792                  }                  }
793                yyerror (msg);                yyerror (yymsg);
794                free (msg);                YYSTACK_FREE (yymsg);
795              }              }
796            else            else
797              yyerror ("parse error; also virtual memory exhausted");              yyerror ("parse error; also virtual memory exhausted");
# Line 794  yyerrpop: Line 860  yyerrpop:
860  #if YYDEBUG  #if YYDEBUG
861    if (yydebug)    if (yydebug)
862      {      {
863        short *ssp1 = yyss - 1;        short *yyssp1 = yyss - 1;
864        fprintf (stderr, "Error: state stack now");        fprintf (stderr, "Error: state stack now");
865        while (ssp1 != yyssp)        while (yyssp1 != yyssp)
866          fprintf (stderr, " %d", *++ssp1);          fprintf (stderr, " %d", *++yyssp1);
867        fprintf (stderr, "\n");        fprintf (stderr, "\n");
868      }      }
869  #endif  #endif

Legend:
Removed from v.1.53.2.9  
changed lines
  Added in v.1.53.2.10

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26