/[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.41 by eggert, Tue Nov 19 07:35:29 2002 UTC revision 1.42 by eggert, Thu Nov 21 05:11:29 2002 UTC
# Line 146  b4_copyright([Skeleton parser for GLR pa Line 146  b4_copyright([Skeleton parser for GLR pa
146  [  [
147  /* This is the parser code for GLR (Generalized LR) parser. */  /* This is the parser code for GLR (Generalized LR) parser. */
148    
 #include <assert.h>  
149  #include <stdio.h>  #include <stdio.h>
150  #include <stdlib.h>  #include <stdlib.h>
151  #include <string.h>  #include <string.h>
# Line 1038  yydoAction (yyGLRStack* yystack, int yyk Line 1037  yydoAction (yyGLRStack* yystack, int yyk
1037      {      {
1038        /* Standard special case: single stack. */        /* Standard special case: single stack. */
1039        yyGLRStackItem* rhs = (yyGLRStackItem*) yystack->yytops.yystates[yyk];        yyGLRStackItem* rhs = (yyGLRStackItem*) yystack->yytops.yystates[yyk];
1040        assert (yyk == 0);        if (yyk != 0)
1041            abort ();
1042        yystack->yynextFree -= yynrhs;        yystack->yynextFree -= yynrhs;
1043        yystack->yyspaceLeft += yynrhs;        yystack->yyspaceLeft += yynrhs;
1044        yystack->yytops.yystates[0] = & yystack->yynextFree[-1].yystate;        yystack->yytops.yystates[0] = & yystack->yynextFree[-1].yystate;
# Line 1063  yydoAction (yyGLRStack* yystack, int yyk Line 1063  yydoAction (yyGLRStack* yystack, int yyk
1063        for (yyi = yynrhs-1, yys = yystack->yytops.yystates[yyk]; 0 <= yyi;        for (yyi = yynrhs-1, yys = yystack->yytops.yystates[yyk]; 0 <= yyi;
1064             yyi -= 1, yys = yys->yypred)             yyi -= 1, yys = yys->yypred)
1065          {          {
1066            assert (yys->yypred != NULL);            if (! yys->yypred)
1067                abort ();
1068            yyrhsVals[yyi].yystate.yyresolved = yytrue;            yyrhsVals[yyi].yystate.yyresolved = yytrue;
1069            yyrhsVals[yyi].yystate.yysemantics.yysval = yys->yysemantics.yysval;            yyrhsVals[yyi].yystate.yysemantics.yysval = yys->yysemantics.yysval;
1070            yyrhsVals[yyi].yystate.yyloc = yys->yyloc;            yyrhsVals[yyi].yystate.yyloc = yys->yyloc;
# Line 1151  yyglrReduce (yyGLRStack* yystack, size_t Line 1152  yyglrReduce (yyGLRStack* yystack, size_t
1152             0 < yyn; yyn -= 1)             0 < yyn; yyn -= 1)
1153          {          {
1154            yys = yys->yypred;            yys = yys->yypred;
1155            assert (yys != NULL);            if (! yys)
1156                abort ();
1157          }          }
1158        yyupdateSplit (yystack, yys);        yyupdateSplit (yystack, yys);
1159        yynewLRState = yyLRgotoState (yys->yylrState, yylhsNonterm (yyrule));        yynewLRState = yyLRgotoState (yys->yylrState, yylhsNonterm (yyrule));
# Line 1188  yysplitStack (yyGLRStack* yystack, int y Line 1190  yysplitStack (yyGLRStack* yystack, int y
1190  {  {
1191    if (yystack->yysplitPoint == NULL)    if (yystack->yysplitPoint == NULL)
1192      {      {
1193        assert (yyk == 0);        if (yyk != 0)
1194            abort ();
1195        yystack->yysplitPoint = yystack->yytops.yystates[yyk];        yystack->yysplitPoint = yystack->yytops.yystates[yyk];
1196      }      }
1197    if (yystack->yytops.yysize >= yystack->yytops.yycapacity)    if (yystack->yytops.yysize >= yystack->yytops.yycapacity)
# Line 1286  yyresolveStates (yyGLRState* yys, int yy Line 1289  yyresolveStates (yyGLRState* yys, int yy
1289    YYRESULTTAG yyflag;    YYRESULTTAG yyflag;
1290    if (0 < yyn)    if (0 < yyn)
1291      {      {
1292        assert (yys->yypred != NULL);        if (! yys->yypred)
1293            abort ();
1294        yyflag = yyresolveStates (yys->yypred, yyn-1, yystack]b4_user_args[);        yyflag = yyresolveStates (yys->yypred, yyn-1, yystack]b4_user_args[);
1295        if (yyflag != yyok)        if (yyflag != yyok)
1296          return yyflag;          return yyflag;
# Line 1316  yyresolveAction (yySemanticOption* yyopt Line 1320  yyresolveAction (yySemanticOption* yyopt
1320    for (yyi = yynrhs-1, yys = yyopt->yystate; 0 <= yyi;    for (yyi = yynrhs-1, yys = yyopt->yystate; 0 <= yyi;
1321         yyi -= 1, yys = yys->yypred)         yyi -= 1, yys = yys->yypred)
1322      {      {
1323        assert (yys->yypred != NULL);        if (! yys->yypred)
1324            abort ();
1325        yyrhsVals[yyi].yystate.yyresolved = yytrue;        yyrhsVals[yyi].yystate.yyresolved = yytrue;
1326        yyrhsVals[yyi].yystate.yysemantics.yysval = yys->yysemantics.yysval;        yyrhsVals[yyi].yystate.yysemantics.yysval = yys->yysemantics.yysval;
1327        yyrhsVals[yyi].yystate.yyloc = yys->yyloc;        yyrhsVals[yyi].yystate.yyloc = yys->yyloc;
# Line 1508  yyprocessOneStack (yyGLRStack* yystack, Line 1513  yyprocessOneStack (yyGLRStack* yystack,
1513        yyStateNum yystate = yystack->yytops.yystates[yyk]->yylrState;        yyStateNum yystate = yystack->yytops.yystates[yyk]->yylrState;
1514        YYDPRINTF ((stderr, "Stack %d Entering state %d\n", yyk, yystate));        YYDPRINTF ((stderr, "Stack %d Entering state %d\n", yyk, yystate));
1515    
1516        assert (yystate != YYFINAL);        if (yystate == YYFINAL)
1517            abort ();
1518        if (yyisDefaultedState (yystate))        if (yyisDefaultedState (yystate))
1519          {          {
1520            yyrule = yydefaultAction (yystate);            yyrule = yydefaultAction (yystate);

Legend:
Removed from v.1.41  
changed lines
  Added in v.1.42

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