SQLite Forum

lemon cannot shift-reduce errors
Login
Assertion fault repro case:

> ~~~~
%token_prefix TOKEN_
start ::= top.
top ::= .
top ::= top error.
top ::= top topdef.
topdef ::= ONE.
topdef ::= TWO THREE.
%code {
  #include <stdlib.h>
  #include <string.h>
  int main(int argc, char **argv){
    int i;
    yyParser x;
    ParseInit(&x);
    ParseTrace(stdout, "parser: ");
    for(i=1; i<argc; i++){
      if( strcmp(argv[i],"one")==0 )        Parse(&x, TOKEN_ONE, 0);
      else if( strcmp(argv[i],"two")==0 )   Parse(&x, TOKEN_TWO, 0);
      else if( strcmp(argv[i],"three")==0 ) Parse(&x, TOKEN_THREE, 0);
      else {
        fprintf(stderr, "unknown token: \"%s\"\n", argv[i]);
        exit(1);
      }
    }
    Parse(&x, 0, 0);
    ParseFinalize(&x);
    return 0;
  }
}
~~~~

If the file above is named "test1.y" then compile and run as follows:

>    ./lemon test1.y && gcc test1.c && ./a.out three