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> |
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; |
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; |
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)); |
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) |
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; |
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; |
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); |