/[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.49 by eggert, Fri Jan 3 14:32:35 2003 UTC revision 1.50 by hilfinger, Wed Jan 29 23:37:15 2003 UTC
# Line 111  m4_define([b4_lhs_value], Line 111  m4_define([b4_lhs_value],
111  # Expansion of $<TYPE>NUM, where the current rule has RULE-LENGTH  # Expansion of $<TYPE>NUM, where the current rule has RULE-LENGTH
112  # symbols on RHS.  # symbols on RHS.
113  m4_define([b4_rhs_value],  m4_define([b4_rhs_value],
114  [yyvsp@{m4_eval([$2 - $1])@}.yystate.yysemantics.yysval[]m4_ifval([$3], [.$3])])  [yyvsp@{YYFILL (m4_eval([$2 - $1]))@}.yystate.yysemantics.yysval[]m4_ifval([$3], [.$3])])
115    
116    
117    
# Line 131  m4_define([b4_lhs_location], Line 131  m4_define([b4_lhs_location],
131  # Expansion of @NUM, where the current rule has RULE-LENGTH symbols  # Expansion of @NUM, where the current rule has RULE-LENGTH symbols
132  # on RHS.  # on RHS.
133  m4_define([b4_rhs_location],  m4_define([b4_rhs_location],
134  [yyvsp@{m4_eval([$2 - $1])@}.yystate.yyloc])  [yyvsp@{YYFILL (m4_eval([$2 - $1]))@}.yystate.yyloc])
   
135    
136  # We do want M4 expansion after # for CPP macros.  # We do want M4 expansion after # for CPP macros.
137  m4_changecom()  m4_changecom()
# Line 614  yytokenName (yySymbol yytoken) Line 613  yytokenName (yySymbol yytoken)
613  }  }
614  #endif  #endif
615    
616    /** Fill in YYVSP[YYLOW1 .. YYLOW0-1] from the chain of states starting
617     *  at YYVSP[YYLOW0].yystate.yypred.  Leaves YYVSP[YYLOW1].yystate.yypred
618     *  containing the pointer to the next state in the chain. Assumes
619     *  YYLOW1 < YYLOW0.  For convenience, returns YYLOW1. */
620    static int
621    yyfill (yyGLRStackItem* yyvsp, int yylow0, int yylow1)
622    {
623      yyGLRState* s;
624      int i;
625      s = yyvsp[yylow0].yystate.yypred;
626      for (i = yylow0-1; i >= yylow1; i -= 1)
627        {
628          if (! s->yyresolved)
629            abort ();
630          yyvsp[i].yystate.yyresolved = yytrue;
631          yyvsp[i].yystate.yysemantics.yysval = s->yysemantics.yysval;
632          yyvsp[i].yystate.yyloc = s->yyloc;
633          s = yyvsp[i].yystate.yypred = s->yypred;
634        }
635      return yylow1;
636    }
637    
638  /** Perform user action for rule number YYN, with RHS length YYRHSLEN,  /** Perform user action for rule number YYN, with RHS length YYRHSLEN,
639   *  and top stack item YYVSP.  YYLVALP points to place to put semantic   *  and top stack item YYVSP.  YYLVALP points to place to put semantic
640   *  value ($$), and yylocp points to place for location information   *  value ($$), and yylocp points to place for location information
# Line 624  yyuserAction (yyRuleNum yyn, int yyrhsle Line 645  yyuserAction (yyRuleNum yyn, int yyrhsle
645                YYSTYPE* yyvalp, YYLTYPE* yylocp, yyGLRStack* yystack                YYSTYPE* yyvalp, YYLTYPE* yylocp, yyGLRStack* yystack
646                ]b4_user_formals[)                ]b4_user_formals[)
647  {  {
648    /* Avoid `unused' warnings in there are no $n. */    int yynormal = (yystack->yysplitPoint == NULL);
649    (void) yystack;    int yylow;
650    
651    if (yyrhslen == 0)    if (yyrhslen == 0)
652      {      {
# Line 649  yyuserAction (yyRuleNum yyn, int yyrhsle Line 670  yyuserAction (yyRuleNum yyn, int yyrhsle
670  # define YYRECOVERING (yystack->yyerrState != 0)  # define YYRECOVERING (yystack->yyerrState != 0)
671  # undef yyclearin  # undef yyclearin
672  # define yyclearin (yychar = *(yystack->yytokenp) = YYEMPTY)  # define yyclearin (yychar = *(yystack->yytokenp) = YYEMPTY)
673    # undef YYFILL
674    # define YYFILL(N)                                                           \
675      ((yynormal || yylow <= (N)) ? (N) : (yylow = yyfill (yyvsp, yylow, N)))
676  # undef YYBACKUP  # undef YYBACKUP
677  # define YYBACKUP(Token, Value)                                              \  # define YYBACKUP(Token, Value)                                              \
678    do {                                                                       \    do {                                                                       \
# Line 657  yyuserAction (yyRuleNum yyn, int yyrhsle Line 681  yyuserAction (yyRuleNum yyn, int yyrhsle
681    } while (0)    } while (0)
682    
683  ]  ]
684       yylow = 1;
685     switch (yyn)     switch (yyn)
686       {       {
687         b4_actions         b4_actions
# Line 998  yyglrShift (yyGLRStack* yystack, int yyk Line 1023  yyglrShift (yyGLRStack* yystack, int yyk
1023      yyexpandGLRStack (yystack]b4_pure_args[);      yyexpandGLRStack (yystack]b4_pure_args[);
1024  }  }
1025    
1026  /** Shift to a new state on stack #K of STACK, to a new state  /** Shift stack #K of YYSTACK, to a new state corresponding to LR
1027   *  corresponding to LR state LRSTATE, at input position POSN, with   *  state YYLRSTATE, at input position YYPOSN, with the (unresolved)
1028   * the (unresolved) semantic value of RHS under the action for RULE. */   *  semantic value of YYRHS under the action for YYRULE. */
1029  static inline void  static inline void
1030  yyglrShiftDefer (yyGLRStack* yystack, int yyk, yyStateNum yylrState,  yyglrShiftDefer (yyGLRStack* yystack, int yyk, yyStateNum yylrState,
1031                   size_t yyposn, yyGLRState* rhs, yyRuleNum yyrule]b4_pure_formals[)                   size_t yyposn, yyGLRState* rhs, yyRuleNum yyrule]b4_pure_formals[)
# Line 1058  yydoAction (yyGLRStack* yystack, int yyk Line 1083  yydoAction (yyGLRStack* yystack, int yyk
1083      {      {
1084        int yyi;        int yyi;
1085        yyGLRState* yys;        yyGLRState* yys;
1086        yyGLRStackItem yyrhsVals[YYMAXRHS];        yyGLRStackItem yyrhsVals[YYMAXRHS+1];
1087        for (yyi = yynrhs-1, yys = yystack->yytops.yystates[yyk]; 0 <= yyi;        yys = yyrhsVals[YYMAXRHS].yystate.yypred = yystack->yytops.yystates[yyk];
1088             yyi -= 1, yys = yys->yypred)        for (yyi = 0; yyi < yynrhs; yyi += 1)
1089          {          {
1090            if (! yys->yypred)            yys = yys->yypred;
1091              if (yys == NULL)
1092              abort ();              abort ();
           yyrhsVals[yyi].yystate.yyresolved = yytrue;  
           yyrhsVals[yyi].yystate.yysemantics.yysval = yys->yysemantics.yysval;  
           yyrhsVals[yyi].yystate.yyloc = yys->yyloc;  
1093          }          }
1094        yyupdateSplit (yystack, yys);        yyupdateSplit (yystack, yys);
1095        yystack->yytops.yystates[yyk] = yys;        yystack->yytops.yystates[yyk] = yys;
# Line 1077  yydoAction (yyGLRStack* yystack, int yyk Line 1100  yydoAction (yyGLRStack* yystack, int yyk
1100          }          }
1101        else        else
1102          {          {
1103            *yyvalp = yyrhsVals[0].yystate.yysemantics.yysval;            *yyvalp = yyrhsVals[1].yystate.yysemantics.yysval;
1104            *yylocp = yyrhsVals[0].yystate.yyloc;            *yylocp = yyrhsVals[1].yystate.yyloc;
1105          }          }
1106        return yyuserAction (yyrule, yynrhs, yyrhsVals + (yynrhs-1),        return yyuserAction (yyrule, yynrhs, yyrhsVals + YYMAXRHS - 1,
1107                             yyvalp, yylocp, yystack]b4_user_args[);                             yyvalp, yylocp, yystack]b4_user_args[);
1108      }      }
1109  }  }
# Line 1152  yyglrReduce (yyGLRStack* yystack, size_t Line 1175  yyglrReduce (yyGLRStack* yystack, size_t
1175             0 < yyn; yyn -= 1)             0 < yyn; yyn -= 1)
1176          {          {
1177            yys = yys->yypred;            yys = yys->yypred;
1178            if (! yys)            if (yys == NULL)
1179              abort ();              abort ();
1180          }          }
1181        yyupdateSplit (yystack, yys);        yyupdateSplit (yystack, yys);
# Line 1289  yyresolveStates (yyGLRState* yys, int yy Line 1312  yyresolveStates (yyGLRState* yys, int yy
1312    YYRESULTTAG yyflag;    YYRESULTTAG yyflag;
1313    if (0 < yyn)    if (0 < yyn)
1314      {      {
1315        if (! yys->yypred)        if (yys->yypred == NULL)
1316          abort ();          abort ();
1317        yyflag = yyresolveStates (yys->yypred, yyn-1, yystack]b4_user_args[);        yyflag = yyresolveStates (yys->yypred, yyn-1, yystack]b4_user_args[);
1318        if (yyflag != yyok)        if (yyflag != yyok)
# Line 1311  static YYRESULTTAG Line 1334  static YYRESULTTAG
1334  yyresolveAction (yySemanticOption* yyopt, yyGLRStack* yystack,  yyresolveAction (yySemanticOption* yyopt, yyGLRStack* yystack,
1335                   YYSTYPE* yyvalp, YYLTYPE* yylocp]b4_user_formals[)                   YYSTYPE* yyvalp, YYLTYPE* yylocp]b4_user_formals[)
1336  {  {
1337    yyGLRStackItem yyrhsVals[YYMAXRHS];    yyGLRStackItem yyrhsVals[YYMAXRHS+1];
1338    int yynrhs, yyi;    int yynrhs;
   yyGLRState* yys;  
1339    
1340    yynrhs = yyrhsLength (yyopt->yyrule);    yynrhs = yyrhsLength (yyopt->yyrule);
1341    YYCHK (yyresolveStates (yyopt->yystate, yynrhs, yystack]b4_user_args[));    YYCHK (yyresolveStates (yyopt->yystate, yynrhs, yystack]b4_user_args[));
1342    for (yyi = yynrhs-1, yys = yyopt->yystate; 0 <= yyi;    yyrhsVals[YYMAXRHS].yystate.yypred = yyopt->yystate;
1343         yyi -= 1, yys = yys->yypred)    return yyuserAction (yyopt->yyrule, yynrhs, yyrhsVals + YYMAXRHS - 1,
     {  
       if (! yys->yypred)  
         abort ();  
       yyrhsVals[yyi].yystate.yyresolved = yytrue;  
       yyrhsVals[yyi].yystate.yysemantics.yysval = yys->yysemantics.yysval;  
       yyrhsVals[yyi].yystate.yyloc = yys->yyloc;  
     }  
   return yyuserAction (yyopt->yyrule, yynrhs, yyrhsVals + (yynrhs-1),  
1344                         yyvalp, yylocp, yystack]b4_user_args[);                         yyvalp, yylocp, yystack]b4_user_args[);
1345  }  }
1346    

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

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