/[bison]/bison/data/glr.c
ViewVC logotype

Diff of /bison/data/glr.c

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

revision 1.50 by hilfinger, Wed Jan 29 23:37:15 2003 UTC revision 1.51 by eggert, Thu Feb 13 07:14:29 2003 UTC
# Line 297  static const char *const yytname[] = Line 297  static const char *const yytname[] =
297  {  {
298    ]b4_tname[    ]b4_tname[
299  };  };
   
 #define yytname_size ((int) (sizeof (yytname) / sizeof (yytname[0])))  
300  #endif  #endif
301    
302  /* YYR1[YYN] -- Symbol number of symbol that rule YYN derives.  */  /* YYR1[YYN] -- Symbol number of symbol that rule YYN derives.  */
# Line 1598  yyreportSyntaxError (yyGLRStack* yystack Line 1596  yyreportSyntaxError (yyGLRStack* yystack
1596      {      {
1597  #if YYERROR_VERBOSE  #if YYERROR_VERBOSE
1598        yySymbol* const yytokenp = yystack->yytokenp;        yySymbol* const yytokenp = yystack->yytokenp;
1599        int yyn, yyx, yycount;        int yyn;
       size_t yysize;  
1600        const char* yyprefix;        const char* yyprefix;
       char* yyp;  
       char* yymsg;  
1601        yyn = yypact[yystack->yytops.yystates[0]->yylrState];        yyn = yypact[yystack->yytops.yystates[0]->yylrState];
1602        if (YYPACT_NINF < yyn && yyn < YYLAST)        if (YYPACT_NINF < yyn && yyn < YYLAST)
1603          {          {
1604            yycount = 0;            size_t yysize = 0;
1605              char* yymsg;
1606              int yyx;
1607    
1608            /* Start YYX at -YYN if negative to avoid negative indexes in            /* Start YYX at -YYN if negative to avoid negative indexes in
1609               YYCHECK.  */               YYCHECK.  */
1610            yysize = sizeof ("syntax error, unexpected ")            int yyxbase = yyn < 0 ? -yyn : 0;
1611              + strlen (yytokenName (*yytokenp));  
1612              /* Stay within bounds of both yycheck and yytname.  */
1613              int yychecklim = YYLAST - yyn;
1614              int yynsyms = sizeof (yytname) / sizeof (yytname[0]);
1615              int yyxlim = yychecklim < yynsyms ? yychecklim : yynsyms;
1616              int yycount = 0;
1617    
1618            yyprefix = ", expecting ";            yyprefix = ", expecting ";
1619            for (yyx = yyn < 0 ? -yyn : 0; yyx < yytname_size && yycount <= 5;            for (yyx = yyxbase; yyx < yyxlim && yycount < 5; yyx += 1)
                yyx += 1)  
1620              if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR)              if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR)
1621                yysize += strlen (yytokenName (yyx)) + strlen (yyprefix),                {
1622                  yycount += 1, yyprefix = " or ";                  yysize += strlen (yytokenName (yyx)) + strlen (yyprefix);
1623            yymsg = yyp = (char*) malloc (yysize);                  yycount += 1;
1624            sprintf (yyp, "syntax error, unexpected %s",                  if (yycount == 5)
                    yytokenName (*yytokenp));  
           yyp += strlen (yyp);  
           if (yycount < 5)  
             {  
               yyprefix = ", expecting ";  
               for (yyx = yyn < 0 ? -yyn : 0; yyx < yytname_size; yyx += 1)  
                 if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR)  
1625                    {                    {
1626                      sprintf (yyp, "%s%s", yyprefix, yytokenName (yyx));                      yysize = 0;
1627                      yyp += strlen (yyp);                      break;
                     yyprefix = " or ";  
1628                    }                    }
1629                    yyprefix = " or ";
1630                  }
1631              yysize += (sizeof ("syntax error, unexpected ")
1632                         + strlen (yytokenName (*yytokenp)));
1633              yymsg = (char*) malloc (yysize);
1634              if (yymsg != 0)
1635                {
1636                  char* yyp = yymsg;
1637                  sprintf (yyp, "syntax error, unexpected %s",
1638                           yytokenName (*yytokenp));
1639                  yyp += strlen (yyp);
1640                  if (yycount < 5)
1641                    {
1642                      yyprefix = ", expecting ";
1643                      for (yyx = yyxbase; yyx < yyxlim; yyx += 1)
1644                        if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR)
1645                          {
1646                            sprintf (yyp, "%s%s", yyprefix, yytokenName (yyx));
1647                            yyp += strlen (yyp);
1648                            yyprefix = " or ";
1649                          }
1650                    }
1651                  yyerror (]b4_lyyerror_args[yymsg);
1652                  free (yymsg);
1653              }              }
1654            yyerror (]b4_lyyerror_args[yymsg);            else
1655            free (yymsg);              yyerror (]b4_lyyerror_args["syntax error; also virtual memory exhausted");
1656          }          }
1657        else        else
1658  #endif  #endif /* YYERROR_VERBOSE */
1659          yyerror (]b4_lyyerror_args["syntax error");          yyerror (]b4_lyyerror_args["syntax error");
1660        yynerrs += 1;        yynerrs += 1;
1661      }      }

Legend:
Removed from v.1.50  
changed lines
  Added in v.1.51

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