SQLite

Check-in [9dce465087]
Login

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Change the coverage measurement logic in the lemon-generated parser so that it only checks for coverage of state/lookahead pairs that are valid syntax. It turns out that some states are unreachable if the lookahead is not valid syntax, because the states are only reachable through a shift following a reduce, and the reduce does not happen if the lookahead is a syntax error.
Downloads: Tarball | ZIP archive
Timelines: family | ancestors | descendants | both | lemon-improvements
Files: files | file ages | folders
SHA3-256: 9dce46508772bd0f9e940c4d44933154044bb58c1b3511dd0143287bf795dd6b
User & Date: drh 2017-12-27 17:14:50.938
Context
2017-12-27
17:36
The previous check-in had an error in the coverage reporting logic. (Closed-Leaf check-in: ec9b19eb65 user: drh tags: lemon-improvements)
17:14
Change the coverage measurement logic in the lemon-generated parser so that it only checks for coverage of state/lookahead pairs that are valid syntax. It turns out that some states are unreachable if the lookahead is not valid syntax, because the states are only reachable through a shift following a reduce, and the reduce does not happen if the lookahead is a syntax error. (check-in: 9dce465087 user: drh tags: lemon-improvements)
16:13
In the lemon-generated parser, do not report the End-of-input character and the wildcard character as missed coverage. (check-in: 3fe964873d user: drh tags: lemon-improvements)
Changes
Unified Diff Ignore Whitespace Patch
Changes to tool/lempar.c.
463
464
465
466
467
468
469

470


471
472
473
474
475
476
477

478
479
480
481
482

483
484
485
486
487
488
489
490
*/
#if defined(YYCOVERAGE)
static unsigned char yycoverage[YYNSTATE][YYNTOKEN];
#endif

/*
** Write into out a description of every state/lookahead combination that

** has not previously been seen by the parser.  Return the number of 


** missed state/lookahead combinations.
*/
#if defined(YYCOVERAGE)
int ParseCoverage(FILE *out){
  int i, j;
  int nMissed = 0;
  for(i=0; i<YYNSTATE; i++){

    for(j=1; j<YYNTOKEN; j++){
      if( j==YYWILDCARD ) continue;
      if( !yycoverage[i][j] ) nMissed++;
      if( out ){
        fprintf(out,"State %d lookahead %s %s\n",

           i, yyTokenName[j], yycoverage[i][j] ? "ok" : "missed");
      }
    }
  }
  return nMissed;
}
#endif








>
|
>
>
|



|

|
>
|
|
|

|
>
|







463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
*/
#if defined(YYCOVERAGE)
static unsigned char yycoverage[YYNSTATE][YYNTOKEN];
#endif

/*
** Write into out a description of every state/lookahead combination that
**
**   (1)  has not been used by the parser, and
**   (2)  is not a syntax error.
**
** Return the number of missed state/lookahead combinations.
*/
#if defined(YYCOVERAGE)
int ParseCoverage(FILE *out){
  int stateno, iLookAhead, i;
  int nMissed = 0;
  for(stateno=0; stateno<YYNSTATE; stateno++){
    i = yy_shift_ofst[stateno];
    for(iLookAhead=0; iLookAhead<YYNTOKEN; iLookAhead++){
      if( yy_lookahead[i]!=iLookAhead ) continue;
      if( yycoverage[stateno][iLookAhead]==0 ) nMissed++;
      if( out ){
        fprintf(out,"State %d lookahead %s %s\n", stateno,
                yyTokenName[iLookAhead],
                yycoverage[stateno][iLookAhead] ? "ok" : "missed");
      }
    }
  }
  return nMissed;
}
#endif

502
503
504
505
506
507
508

509

510
511
512
513
514
515
516
517
518
  if( stateno>YY_MAX_SHIFT ) return stateno;
  assert( stateno <= YY_SHIFT_COUNT );
#if defined(YYCOVERAGE)
  yycoverage[stateno][iLookAhead] = 1;
#endif
  do{
    i = yy_shift_ofst[stateno];

    assert( iLookAhead!=YYNOCODE );

    i += iLookAhead;
    assert( i>=0 && i<sizeof(yy_lookahead)/sizeof(yy_lookahead[0]) );
    if( yy_lookahead[i]!=iLookAhead ){
#ifdef YYFALLBACK
      YYCODETYPE iFallback;            /* Fallback token */
      if( iLookAhead<sizeof(yyFallback)/sizeof(yyFallback[0])
             && (iFallback = yyFallback[iLookAhead])!=0 ){
#ifndef NDEBUG
        if( yyTraceFILE ){







>

>

<







507
508
509
510
511
512
513
514
515
516
517

518
519
520
521
522
523
524
  if( stateno>YY_MAX_SHIFT ) return stateno;
  assert( stateno <= YY_SHIFT_COUNT );
#if defined(YYCOVERAGE)
  yycoverage[stateno][iLookAhead] = 1;
#endif
  do{
    i = yy_shift_ofst[stateno];
    assert( i>=0 && i+YYNTOKEN<=sizeof(yy_lookahead)/sizeof(yy_lookahead[0]) );
    assert( iLookAhead!=YYNOCODE );
    assert( iLookAhead < YYNTOKEN );
    i += iLookAhead;

    if( yy_lookahead[i]!=iLookAhead ){
#ifdef YYFALLBACK
      YYCODETYPE iFallback;            /* Fallback token */
      if( iLookAhead<sizeof(yyFallback)/sizeof(yyFallback[0])
             && (iFallback = yyFallback[iLookAhead])!=0 ){
#ifndef NDEBUG
        if( yyTraceFILE ){