/ Check-in [b43ac330]
Login

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

Overview
Comment:Removed %expect directive, on drh's advice.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | lemon-update-2010
Files: files | file ages | folders
SHA1: b43ac3309e77dc8ea2952bf62da6eaad5aef6653
User & Date: icculus 2010-02-16 16:09:03
Context
2010-02-17
05:40
Removed unused variables. check-in: ca570a02 user: icculus tags: lemon-update-2010
2010-02-16
16:09
Removed %expect directive, on drh's advice. check-in: b43ac330 user: icculus tags: lemon-update-2010
16:07
Patched to compile. Accidentally removed va_list declaration. check-in: 673d470c user: icculus tags: lemon-update-2010
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to tool/lemon.c.

   293    293     char *extracode;         /* Code appended to the generated file */
   294    294     char *tokendest;         /* Code to execute to destroy token data */
   295    295     char *vardest;           /* Code for the default non-terminal destructor */
   296    296     char *filename;          /* Name of the input file */
   297    297     char *outname;           /* Name of the current output file */
   298    298     char *tokenprefix;       /* A prefix added to token names in the .h file */
   299    299     int nconflict;           /* Number of parsing conflicts */
   300         -  int nexpected;           /* Number of expected parsing conflicts */
   301    300     int tablesize;           /* Size of the parse tables */
   302    301     int basisflag;           /* Print only basis configurations */
   303    302     int has_fallback;        /* True if any %fallback is seen in the grammar */
   304    303     int nolinenosflag;       /* True if #line statements should not be printed */
   305    304     char *argv0;             /* Name of the program */
   306    305   };
   307    306   
................................................................................
  1433   1432     }
  1434   1433     if( OptNArgs()!=1 ){
  1435   1434       fprintf(stderr,"Exactly one filename argument is required.\n");
  1436   1435       exit(1);
  1437   1436     }
  1438   1437     memset(&lem, 0, sizeof(lem));
  1439   1438     lem.errorcnt = 0;
  1440         -  lem.nexpected = -1;
  1441   1439   
  1442   1440     /* Initialize the machine */
  1443   1441     Strsafe_init();
  1444   1442     Symbol_init();
  1445   1443     State_init();
  1446   1444     lem.argv0 = argv[0];
  1447   1445     lem.filename = OptArg(0);
................................................................................
  1518   1516     }
  1519   1517     if( statistics ){
  1520   1518       printf("Parser statistics: %d terminals, %d nonterminals, %d rules\n",
  1521   1519         lem.nterminal, lem.nsymbol - lem.nterminal, lem.nrule);
  1522   1520       printf("                   %d states, %d parser table entries, %d conflicts\n",
  1523   1521         lem.nstate, lem.tablesize, lem.nconflict);
  1524   1522     }
  1525         -  if( lem.nexpected < 0 ) {
  1526         -    lem.nexpected = 0;  /* grammar didn't have an %expect declaration. */
  1527         -  }
  1528         -  if( lem.nconflict != lem.nexpected ){
  1529         -    fprintf(stderr,"%d parsing conflicts (%d expected).\n",lem.nconflict,lem.nexpected);
         1523  +  if( lem.nconflict > 0 ){
         1524  +    fprintf(stderr,"%d parsing conflicts.\n",lem.nconflict);
  1530   1525     }
  1531   1526   
  1532   1527     /* return 0 on success, 1 on failure. */
  1533         -  exitcode = ((lem.errorcnt > 0) || (lem.nconflict != lem.nexpected)) ? 1 : 0;
         1528  +  exitcode = ((lem.errorcnt > 0) || (lem.nconflict > 0)) ? 1 : 0;
  1534   1529     successful_exit = (exitcode == 0);
  1535   1530     exit(exitcode);
  1536   1531     return (exitcode);
  1537   1532   }
  1538   1533   /******************** From the file "msort.c" *******************************/
  1539   1534   /*
  1540   1535   ** A generic merge-sort program.
................................................................................
  1952   1947     PRECEDENCE_MARK_1,
  1953   1948     PRECEDENCE_MARK_2,
  1954   1949     RESYNC_AFTER_RULE_ERROR,
  1955   1950     RESYNC_AFTER_DECL_ERROR,
  1956   1951     WAITING_FOR_DESTRUCTOR_SYMBOL,
  1957   1952     WAITING_FOR_DATATYPE_SYMBOL,
  1958   1953     WAITING_FOR_FALLBACK_ID,
  1959         -  WAITING_FOR_EXPECT_VALUE,
  1960   1954     WAITING_FOR_WILDCARD_ID
  1961   1955   };
  1962   1956   struct pstate {
  1963   1957     char *filename;       /* Name of the input file */
  1964   1958     int tokenlineno;      /* Linenumber at which current token starts */
  1965   1959     int errorcnt;         /* Number of errors so far */
  1966   1960     char *tokenstart;     /* Text of current token */
................................................................................
  2268   2262   	}else if( strcmp(x,"type")==0 ){
  2269   2263             psp->state = WAITING_FOR_DATATYPE_SYMBOL;
  2270   2264           }else if( strcmp(x,"fallback")==0 ){
  2271   2265             psp->fallback = 0;
  2272   2266             psp->state = WAITING_FOR_FALLBACK_ID;
  2273   2267           }else if( strcmp(x,"wildcard")==0 ){
  2274   2268             psp->state = WAITING_FOR_WILDCARD_ID;
  2275         -        }else if( strcmp(x,"expect")==0 ){
  2276         -          if (psp->gp->nexpected >= 0) {
  2277         -            ErrorMsg(psp->filename,psp->tokenlineno, "Multiple %expect declarations.");
  2278         -            psp->errorcnt++;
  2279         -            psp->state = RESYNC_AFTER_DECL_ERROR;
  2280         -          } else {
  2281         -            psp->state = WAITING_FOR_EXPECT_VALUE;
  2282         -          }
  2283   2269           }else{
  2284   2270             ErrorMsg(psp->filename,psp->tokenlineno,
  2285   2271               "Unknown declaration keyword: \"%%%s\".",x);
  2286   2272             psp->errorcnt++;
  2287   2273             psp->state = RESYNC_AFTER_DECL_ERROR;
  2288   2274   	}
  2289   2275         }else{
................................................................................
  2303   2289           struct symbol *sp = Symbol_new(x);
  2304   2290           psp->declargslot = &sp->destructor;
  2305   2291           psp->decllinenoslot = &sp->destLineno;
  2306   2292           psp->insertLineMacro = 1;
  2307   2293           psp->state = WAITING_FOR_DECL_ARG;
  2308   2294         }
  2309   2295         break;
  2310         -    case WAITING_FOR_EXPECT_VALUE:
  2311         -        psp->gp->nexpected = (int) strtol(x, &endptr, 10);
  2312         -        if( (*endptr != '\0') || (endptr == x) ) {
  2313         -          ErrorMsg(psp->filename,psp->tokenlineno,
  2314         -            "Integer expected after %%expect keyword");
  2315         -          psp->errorcnt++;
  2316         -        } else if (psp->gp->nexpected < 0) {
  2317         -          ErrorMsg(psp->filename,psp->tokenlineno,
  2318         -            "Integer can't be negative after %%expect keyword");
  2319         -          psp->errorcnt++;
  2320         -        }
  2321         -        psp->state = WAITING_FOR_DECL_OR_RULE;
  2322         -        break;
  2323   2296       case WAITING_FOR_DATATYPE_SYMBOL:
  2324   2297         if( !isalpha(x[0]) ){
  2325   2298           ErrorMsg(psp->filename,psp->tokenlineno,
  2326   2299             "Symbol name missing after %destructor keyword");
  2327   2300           psp->errorcnt++;
  2328   2301           psp->state = RESYNC_AFTER_DECL_ERROR;
  2329   2302         }else{