The test case can be simplified to:

bug.lemon:
---

%include {
#include <stdio.h>
#include <stdlib.h>
#include <assert.h>
#include "bug.h"
}
%code {
        int main(void) {

        void *pParser;

        pParser = ParseAlloc(malloc);
        if (!pParser) {
            printf("out of memory\n");
            exit(1);
        }

        ParseTrace(stderr, "Debug: ");

        Parse(pParser, X, 0);
        Parse(pParser, 0, 0);
        ParseFree(pParser, free);
        return 0;
        }
}


main ::= decls.
decls ::= . 
decls ::= decls decl.

decl ::= X

—

which generates this code:

      default:
      /* (0) main ::= decls */ yytestcase(yyruleno==0);
      /* (1) decls ::= (OPTIMIZED OUT) */ assert(yyruleno!=1);
        break;

I believe the issue is line 4164 which should be … = LEMON_TRUE.  Currently, 
when i=0, all rules will erroneously be optimized out.

  4157    /* Mark rules that are actually used for reduce actions after all
  4158    ** optimizations have been applied
  4159    */
  4160    for(rp=lemp->rule; rp; rp=rp->next) rp->doesReduce = LEMON_FALSE;
  4161    for(i=0; i<lemp->nxstate; i++){
  4162      for(ap=lemp->sorted[i]->ap; ap; ap=ap->next){
  4163        if( ap->type==REDUCE || ap->type==SHIFTREDUCE ){
  4164          ap->x.rp->doesReduce = i;
  4165        }
  4166      }
  4167    }

Kelvin Sherlock

_______________________________________________
sqlite-users mailing list
sqlite-users@mailinglists.sqlite.org
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to