/[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.3 by hilfinger, Fri Jun 28 22:42:58 2002 UTC revision 1.4 by akim, Sun Jun 30 17:35:06 2002 UTC
# Line 197  static YYLTYPE yyloc_default; Line 197  static YYLTYPE yyloc_default;
197  #  define yyfalse 0  #  define yyfalse 0
198  #endif  #endif
199    
200  #if ! defined (yy__GNUC__)  /*-----------------.
201  #  define inline  | GCC extensions.  |
202    `-----------------*/
203    
204    #ifndef __attribute__
205    /* This feature is available in gcc versions 2.5 and later.  */
206    # if !defined (__GNUC__) || __GNUC__ < 2 || \
207    (__GNUC__ == 2 && __GNUC_MINOR__ < 5) || __STRICT_ANSI__
208    #  define __attribute__(Spec) /* empty */
209    # endif
210    #endif
211    
212    #ifndef ATTRIBUTE_UNUSED
213    # define ATTRIBUTE_UNUSED __attribute__ ((__unused__))
214    #endif
215    
216    #if ! defined (__GNUC__)
217    # define inline
218  #endif  #endif
219    
220  /* YYFINAL -- State number of the termination state. */  /* YYFINAL -- State number of the termination state. */
# Line 259  static const char *const yytname[] = Line 275  static const char *const yytname[] =
275    ]b4_tname[    ]b4_tname[
276  };  };
277    
278  #define yytname_size (sizeof (yytname) / sizeof (yytname[0]))  #define yytname_size ((int) (sizeof (yytname) / sizeof (yytname[0])))
279  #endif  #endif
280    
281  /* YYR1[YYN] -- Symbol number of symbol that rule YYN derives.  */  /* YYR1[YYN] -- Symbol number of symbol that rule YYN derives.  */
# Line 428  do {                                           \ Line 444  do {                                           \
444     multiple parsers can coexist.  */     multiple parsers can coexist.  */
445  int yydebug;  int yydebug;
446  #else /* !YYDEBUG */  #else /* !YYDEBUG */
447  # define YYDPRINTF(Args)    /* Avoid empty `if' bodies.  */
448    # define YYDPRINTF(Args)  {}
449  #endif /* !YYDEBUG */  #endif /* !YYDEBUG */
450    
451  /* YYINITDEPTH -- initial size of the parser's stacks.  */  /* YYINITDEPTH -- initial size of the parser's stacks.  */
# Line 569  static YYRESULTTAG Line 586  static YYRESULTTAG
586  yyuserAction (yyRuleNum yyn, int yyrhslen, yyGLRStackItem* yyvsp,  yyuserAction (yyRuleNum yyn, int yyrhslen, yyGLRStackItem* yyvsp,
587                YYSTYPE* yyvalp, YYLTYPE* yylocp, yyGLRStack* yystack)                YYSTYPE* yyvalp, YYLTYPE* yylocp, yyGLRStack* yystack)
588  {  {
589      /* Avoid `unused' warnings in there are no $n. */
590      (void) yystack;
591    
592    if (yyrhslen == 0)    if (yyrhslen == 0)
593      {      {
594        *yyvalp = yyval_default;        *yyvalp = yyval_default;
# Line 624  static YYSTYPE Line 644  static YYSTYPE
644  yyuserMerge (int yyn, YYSTYPE* yy0, YYSTYPE* yy1)  yyuserMerge (int yyn, YYSTYPE* yy0, YYSTYPE* yy1)
645  {  {
646    YYSTYPE yyval = *yy0;    YYSTYPE yyval = *yy0;
647      /* `Use' the arguments. */
648      (void) yy0;
649      (void) yy1;
650    
651    switch (yyn)    switch (yyn)
652      {      {
653        b4_mergers        b4_mergers
# Line 720  yyhasResolvedValue (yyGLRState* yystate) Line 744  yyhasResolvedValue (yyGLRState* yystate)
744    return yystate->yyresolved;    return yystate->yyresolved;
745  }  }
746    
747  void yyaddDeferredAction (yyGLRStack* yystack, yyGLRState* yystate,  static void
748                            yyGLRState* yyrhs, yyRuleNum yyrule)  yyaddDeferredAction (yyGLRStack* yystack, yyGLRState* yystate,
749                         yyGLRState* yyrhs, yyRuleNum yyrule)
750  {  {
751    yySemanticOption* yynewItem;    yySemanticOption* yynewItem;
752    yynewItem = &yystack->yynextFree->yyoption;    yynewItem = &yystack->yynextFree->yyoption;
# Line 882  yyundeleteLastStack (yyGLRStack* yystack Line 907  yyundeleteLastStack (yyGLRStack* yystack
907  static inline void  static inline void
908  yyremoveDeletes (yyGLRStack* yystack)  yyremoveDeletes (yyGLRStack* yystack)
909  {  {
910    int yyi, yyj;    size_t yyi, yyj;
911    yyi = yyj = 0;    yyi = yyj = 0;
912    while (yyj < yystack->yytops.yysize)    while (yyj < yystack->yytops.yysize)
913      {      {
914        if (yystack->yytops.yystates[yyi] == NULL)        if (yystack->yytops.yystates[yyi] == NULL)
915          {          {
916            if (YYDEBUG && yyi == yyj)            if (yyi == yyj)
917              YYDPRINTF ((stderr, "Removing dead stacks.\n"));              YYDPRINTF ((stderr, "Removing dead stacks.\n"));
918            yystack->yytops.yysize -= 1;            yystack->yytops.yysize -= 1;
919          }          }
# Line 1022  yydoAction (yyGLRStack* yystack, int yyk Line 1047  yydoAction (yyGLRStack* yystack, int yyk
1047   *  added to the options for the existing state's semantic value.   *  added to the options for the existing state's semantic value.
1048   */   */
1049  static inline YYRESULTTAG  static inline YYRESULTTAG
1050  yyglrReduce (yyGLRStack* yystack, int yyk, yyRuleNum yyrule, bool yyforceEval)  yyglrReduce (yyGLRStack* yystack, size_t yyk, yyRuleNum yyrule,
1051                 bool yyforceEval)
1052  {  {
1053    int yyposn = yystack->yytops.yystates[yyk]->yyposn;    size_t yyposn = yystack->yytops.yystates[yyk]->yyposn;
1054    
1055    if (yyforceEval || yystack->yysplitPoint == NULL)    if (yyforceEval || yystack->yysplitPoint == NULL)
1056      {      {
# Line 1041  yyglrReduce (yyGLRStack* yystack, int yy Line 1067  yyglrReduce (yyGLRStack* yystack, int yy
1067      }      }
1068    else    else
1069      {      {
1070        int yyi, yyn;        size_t yyi;
1071          int yyn;
1072        yyGLRState* yys, *yys0 = yystack->yytops.yystates[yyk];        yyGLRState* yys, *yys0 = yystack->yytops.yystates[yyk];
1073        yyStateNum yynewLRState;        yyStateNum yynewLRState;
1074    
# Line 1153  yymergeOptionSets (yySemanticOption* yyy Line 1180  yymergeOptionSets (yySemanticOption* yyy
1180   *  parsing state; return 0 if no combination is possible,   *  parsing state; return 0 if no combination is possible,
1181   *  1 if user-mergeable, 2 if Y0 is preferred, 3 if Y1 is preferred. */   *  1 if user-mergeable, 2 if Y0 is preferred, 3 if Y1 is preferred. */
1182  static int  static int
1183  yypreference (yySemanticOption* yyy0, yySemanticOption* yyy1)  yypreference (yySemanticOption* y0, yySemanticOption* y1)
1184  {  {
1185    yyRuleNum yyr0 = yyy0->yyrule, yyr1 = yyy1->yyrule;    yyRuleNum r0 = y0->yyrule, r1 = y1->yyrule;
1186    int yyp0 = yydprec[yyr0], yyp1 = yydprec[yyr1];    int p0 = yydprec[r0], p1 = yydprec[r1];
1187    
1188    if (yyp0 == yyp1)    if (p0 == p1)
1189      {      {
1190        if (yymerger[yyr0] == 0 || yymerger[yyr0] != yymerger[yyr1])        if (yymerger[r0] == 0 || yymerger[r0] != yymerger[r1])
1191          return 0;          return 0;
1192        else        else
1193          return 1;          return 1;
1194      }      }
1195    if (yyp0 == 0 || yyp1 == 0)    if (p0 == 0 || p1 == 0)
1196      return 0;      return 0;
1197    if (yyp0 < yyp1)    if (p0 < p1)
1198      return 3;      return 3;
1199    if (yyp0 > yyp1)    if (p0 > p1)
1200      return 2;      return 2;
1201    return 0;    return 0;
1202  }  }
# Line 1269  static void Line 1296  static void
1296  yyreportAmbiguity (yySemanticOption* yyx0, yySemanticOption* yyx1,  yyreportAmbiguity (yySemanticOption* yyx0, yySemanticOption* yyx1,
1297                     yyGLRStack* yystack)                     yyGLRStack* yystack)
1298  {  {
1299      /* `Unused' warnings.  */
1300      (void) yyx0;
1301      (void) yyx1;
1302    
1303  #if YYDEBUG  #if YYDEBUG
1304    YYFPRINTF (stderr, "Ambiguity detected.\n");    YYFPRINTF (stderr, "Ambiguity detected.\n");
1305    YYFPRINTF (stderr, "Option 1,\n");    YYFPRINTF (stderr, "Option 1,\n");
# Line 1453  yyprocessOneStack (yyGLRStack* yystack, Line 1484  yyprocessOneStack (yyGLRStack* yystack,
1484  static void  static void
1485  yyreportParseError (yyGLRStack* yystack, YYSTYPE* yylvalp, YYLTYPE* yyllocp)  yyreportParseError (yyGLRStack* yystack, YYSTYPE* yylvalp, YYLTYPE* yyllocp)
1486  {  {
1487    yySymbol* const yytokenp = yystack->yytokenp;    /* `Unused' warnings. */
1488      (void) yylvalp;
1489      (void) yyllocp;
1490    
1491    if (yystack->yyerrState == 0)    if (yystack->yyerrState == 0)
1492      {      {
1493  #if YYERROR_VERBOSE  #if YYERROR_VERBOSE
1494          yySymbol* const yytokenp = yystack->yytokenp;
1495        int yyn, yyx, yycount, yysize;        int yyn, yyx, yycount, yysize;
1496        char* yyprefix;        const char* yyprefix;
1497        char* yyp;        char* yyp;
1498        char* yymsg;        char* yymsg;
1499        yyn = yypact[yystack->yytops.yystates[0]->yylrState];        yyn = yypact[yystack->yytops.yystates[0]->yylrState];
# Line 1510  static void Line 1544  static void
1544  yyrecoverParseError (yyGLRStack* yystack, YYSTYPE* yylvalp, YYLTYPE* yyllocp)  yyrecoverParseError (yyGLRStack* yystack, YYSTYPE* yylvalp, YYLTYPE* yyllocp)
1545  {  {
1546    yySymbol* const yytokenp = yystack->yytokenp;    yySymbol* const yytokenp = yystack->yytokenp;
1547    int yyk, yyj;    size_t yyk;
1548      int yyj;
1549    
1550    if (yystack->yyerrState == 0)    if (yystack->yyerrState == 0)
1551      yystack->yyerrState = 3;      yystack->yyerrState = 3;
# Line 1717  yyparse (YYPARSE_PARAM_ARG) Line 1752  yyparse (YYPARSE_PARAM_ARG)
1752  }  }
1753    
1754  /* DEBUGGING ONLY */  /* DEBUGGING ONLY */
1755    static void yypstack (yyGLRStack* yystack, int yyk) ATTRIBUTE_UNUSED;
1756    static void yypdumpstack (yyGLRStack* yystack) ATTRIBUTE_UNUSED;
1757    
1758  void  static void
1759  yypstates (yyGLRState* yyst)  yypstates (yyGLRState* yyst)
1760  {  {
1761    void yy_yypstack (yyGLRState* yys)    static void
1762      yy_yypstack (yyGLRState* yys)
1763      {      {
1764        if (yys->yypred == NULL)        if (yys->yypred == NULL)
1765          fprintf (stderr, "%d@%d", yys->yylrState, yys->yyposn);          fprintf (stderr, "%d@%d", yys->yylrState, yys->yyposn);
# Line 1739  yypstates (yyGLRState* yyst) Line 1777  yypstates (yyGLRState* yyst)
1777    fprintf (stderr, "\n");    fprintf (stderr, "\n");
1778  }  }
1779    
1780  void  static void
1781  yypstack (yyGLRStack* yystack, int yyk)  yypstack (yyGLRStack* yystack, int yyk)
1782  {  {
1783    yypstates (yystack->yytops.yystates[yyk]);    yypstates (yystack->yytops.yystates[yyk]);
# Line 1749  yypstack (yyGLRStack* yystack, int yyk) Line 1787  yypstack (yyGLRStack* yystack, int yyk)
1787      ((YYX) == NULL ? -1 : (yyGLRStackItem*) (YYX) - yystack->yyitems)      ((YYX) == NULL ? -1 : (yyGLRStackItem*) (YYX) - yystack->yyitems)
1788    
1789    
1790  void  static void
1791  yypdumpstack (yyGLRStack* yystack)  yypdumpstack (yyGLRStack* yystack)
1792  {  {
1793    yyGLRStackItem* yyp;    yyGLRStackItem* yyp;
1794    int yyi;    size_t yyi;
1795    for (yyp = yystack->yyitems; yyp < yystack->yynextFree; yyp += 1)    for (yyp = yystack->yyitems; yyp < yystack->yynextFree; yyp += 1)
1796      {      {
1797        fprintf (stderr, "%3d. ", yyp - yystack->yyitems);        fprintf (stderr, "%3d. ", yyp - yystack->yyitems);

Legend:
Removed from v.1.3  
changed lines
  Added in v.1.4

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