corrected; sometimes lookahead would fail

This commit is contained in:
ceriel 1988-04-22 14:02:43 +00:00
parent adaa19c807
commit b948e4b59d
2 changed files with 8 additions and 6 deletions

View file

@ -171,7 +171,8 @@ if (Debug)
SAVEST; SAVEST;
mincost = costlimit-totalcost+1; mincost = costlimit-totalcost+1;
for(i=0;i<npos;i++) { for(i=0;i<npos;i++) {
t=codegen(&coderules[pos[i]],ply,FALSE,mincost,0); t=codegen(&coderules[pos[i]],ply,FALSE,
costlimit<MAXINT?mincost:MAXINT,0);
#ifndef NDEBUG #ifndef NDEBUG
if (Debug) if (Debug)
fprintf(stderr,"mincost %u,cost %u,pos %d\n",mincost,t,i); fprintf(stderr,"mincost %u,cost %u,pos %d\n",mincost,t,i);
@ -343,7 +344,7 @@ if(Debug>1) { fprintf(stderr,"Next tuple %d,%d,%d,%d\n",
if (Debug > 1) fprintf(stderr, "cost after coercions: %u\n", t); if (Debug > 1) fprintf(stderr, "cost after coercions: %u\n", t);
#endif #endif
if (t<mincost) if (t<mincost)
t += codegen(codep,ply,FALSE,mincost-t,0); t += codegen(codep,ply,FALSE,mincost<MAXINT?mincost-t:MAXINT,0);
if (t<mincost) { if (t<mincost) {
mincost = t; mincost = t;
besttup = tup; besttup = tup;
@ -522,7 +523,7 @@ if (Debug > 1) fprintf(stderr, "cost after coercions: %u\n", t);
erasereg(pos2[j]); erasereg(pos2[j]);
} }
if (t<mincost) if (t<mincost)
t += codegen(codep,ply,FALSE,mincost-t,0); t += codegen(codep,ply,FALSE,mincost<MAXINT?mincost-t:MAXINT,0);
if (t<mincost) { if (t<mincost) {
mincost=t; mincost=t;
decision=pos2[j]; decision=pos2[j];

View file

@ -196,7 +196,8 @@ if (Debug)
SAVEST; SAVEST;
mincost = costlimit-totalcost+1; mincost = costlimit-totalcost+1;
for(i=0;i<npos;i++) { for(i=0;i<npos;i++) {
t=codegen(&coderules[pos[i]],ply,FALSE,mincost,0); t=codegen(&coderules[pos[i]],ply,FALSE,
costlimit<MAXINT?mincost:MAXINT,0);
#ifndef NDEBUG #ifndef NDEBUG
if (Debug) if (Debug)
fprintf(stderr,"mincost %u,cost %u,pos %d\n",mincost,t,i); fprintf(stderr,"mincost %u,cost %u,pos %d\n",mincost,t,i);
@ -405,7 +406,7 @@ if (Debug > 1) fprintf(stderr, "cost after coercions: %u\n", t);
if (Debug>2) if (Debug>2)
fprintf(stderr,"Continuing match after coercions\n"); fprintf(stderr,"Continuing match after coercions\n");
#endif #endif
t += codegen(codep,ply,FALSE,mincost-t,0); t += codegen(codep,ply,FALSE,mincost<MAXINT?mincost-t:MAXINT,0);
} }
if ( t<mincost && tokpatlen<=stackheight ) { if ( t<mincost && tokpatlen<=stackheight ) {
mincost = t; mincost = t;
@ -633,7 +634,7 @@ normalfailed: if (stackpad!=tokpatlen) {
erasereg(pos2[j]); erasereg(pos2[j]);
} }
if (t<mincost) if (t<mincost)
t += codegen(codep,ply,FALSE,mincost-t,0); t += codegen(codep,ply,FALSE,mincost<MAXINT?mincost-t:MAXINT,0);
if (t<mincost) { if (t<mincost) {
mincost=t; mincost=t;
decision=pos2[j]; decision=pos2[j];