-C Fix\sannoying\semacs\swarning\sabout\ssuspicious\sline.\s\sThe\schange\sremoves\na\sleading\sspace\s(emacs\swants\sMakefiles\sto\suse\sleading\stabs\sthere).\s(CVS\s4159)
-D 2007-07-17T17:22:04
+C Additional\sdiagnostics\sadded\sto\sthe\s"out"\sfile\sgenerated\sby\slemon.\s(CVS\s4160)
+D 2007-07-18T18:16:30
F Makefile.in 0c0e53720f658c7a551046442dd7afba0b72bfbe
F Makefile.linux-gcc 65241babba6faf1152bf86574477baab19190499
F README 9c4e2d6706bdcc3efdd773ce752a8cdab4f90028
F test/zeroblob.test c5096545085330b7886d2f977272a73d9fa7737e
F tool/diffdb.c 7524b1b5df217c20cd0431f6789851a4e0cb191b
F tool/fragck.tcl 5265a95126abcf6ab357f7efa544787e5963f439
-F tool/lemon.c c8c8b25ab1ac8156b3ad83ba4ea1bf00d5e07f5a
+F tool/lemon.c 995d20ec9f12aba4b3821c3a920bd69bb4839fde
F tool/lempar.c 8f998bf8d08e2123149c2cc5d0597cd5d5d1abdd
F tool/memleak.awk 4e7690a51bf3ed757e611273d43fe3f65b510133
F tool/memleak2.awk 9cc20c8e8f3c675efac71ea0721ee6874a1566e8
F www/vdbe.tcl 87a31ace769f20d3627a64fa1fade7fed47b90d0
F www/version3.tcl 890248cf7b70e60c383b0e84d77d5132b3ead42b
F www/whentouse.tcl fc46eae081251c3c181bd79c5faef8195d7991a5
-P 5ea43b2db1f0263c5f0ab76351bc9ca940d1428a
-R 30b03a27a6b10afde24cf5da7dbac081
-U shess
-Z 37f00f3ad3a5ab3875ad642718289614
+P 4daadf659afe6b2524e1b37347247f233a211950
+R 5d58fd77215d6d5adff31f6d536d8ece
+U drh
+Z cf03852661dc72cf4141c4def40720dd
#include <string.h>
#include <ctype.h>
#include <stdlib.h>
+#include <assert.h>
#ifndef __WIN32__
# if defined(_WIN32) || defined(WIN32)
#define MAXRHS 1000
#endif
-char *msort();
-extern void *malloc();
+static char *msort(char*,char**,int(*)(const char*,const char*));
-/******** From the file "action.h" *************************************/
-struct action *Action_new();
-struct action *Action_sort();
-
-/********* From the file "assert.h" ************************************/
-void myassert();
-#ifndef NDEBUG
-# define assert(X) if(!(X))myassert(__FILE__,__LINE__)
-#else
-# define assert(X)
-#endif
+static struct action *Action_new(void);
+static struct action *Action_sort(struct action *);
/********** From the file "build.h" ************************************/
void FindRulePrecedences();
*/
/* Allocate a new parser action */
-struct action *Action_new(){
+static struct action *Action_new(void){
static struct action *freelist = 0;
struct action *new;
return new;
}
-/* Compare two actions */
-static int actioncmp(ap1,ap2)
-struct action *ap1;
-struct action *ap2;
-{
+/* Compare two actions for sorting purposes. Return negative, zero, or
+** positive if the first action is less than, equal to, or greater than
+** the first
+*/
+static int actioncmp(
+ struct action *ap1,
+ struct action *ap2
+){
int rc;
rc = ap1->sp->index - ap2->sp->index;
if( rc==0 ) rc = (int)ap1->type - (int)ap2->type;
}
/* Sort parser actions */
-struct action *Action_sort(ap)
-struct action *ap;
-{
- ap = (struct action *)msort((char *)ap,(char **)&ap->next,actioncmp);
+static struct action *Action_sort(
+ struct action *ap
+){
+ ap = (struct action *)msort((char *)ap,(char **)&ap->next,
+ (int(*)(const char*,const char*))actioncmp);
return ap;
}
return i - p->mnLookahead;
}
-/********************** From the file "assert.c" ****************************/
-/*
-** A more efficient way of handling assertions.
-*/
-void myassert(file,line)
-char *file;
-int line;
-{
- fprintf(stderr,"Assertion failed on line %d of file \"%s\"\n",line,file);
- exit(1);
-}
/********************** From the file "build.c" *****************************/
/*
** Routines to construction the finite state machine for the LEMON
struct action *ap, *nap;
struct state *stp;
stp = lemp->sorted[i];
- assert( stp->ap );
+ /* assert( stp->ap ); */
stp->ap = Action_sort(stp->ap);
for(ap=stp->ap; ap && ap->next; ap=ap->next){
for(nap=ap->next; nap && nap->sp==ap->sp; nap=nap->next){
** The "next" pointers for elements in the lists a and b are
** changed.
*/
-static char *merge(a,b,cmp,offset)
-char *a;
-char *b;
-int (*cmp)();
-int offset;
-{
+static char *merge(
+ char *a,
+ char *b,
+ int (*cmp)(const char*,const char*),
+ int offset
+){
char *ptr, *head;
if( a==0 ){
** The "next" pointers for elements in list are changed.
*/
#define LISTSIZE 30
-char *msort(list,next,cmp)
-char *list;
-char **next;
-int (*cmp)();
-{
+static char *msort(
+ char *list,
+ char **next,
+ int (*cmp)(const char*,const char*)
+){
unsigned long offset;
char *ep;
char *set[LISTSIZE];
fp = file_open(lemp,".out","wb");
if( fp==0 ) return;
- fprintf(fp," \b");
for(i=0; i<lemp->nstate; i++){
stp = lemp->sorted[i];
fprintf(fp,"State %d:\n",stp->statenum);
}
fprintf(fp,"\n");
}
+ fprintf(fp, "----------------------------------------------------\n");
+ fprintf(fp, "Symbols:\n");
+ for(i=0; i<lemp->nsymbol; i++){
+ int j;
+ struct symbol *sp;
+
+ sp = lemp->symbols[i];
+ fprintf(fp, " %3d: %s", i, sp->name);
+ if( sp->type==NONTERMINAL ){
+ fprintf(fp, ":");
+ if( sp->lambda ){
+ fprintf(fp, " <lambda>");
+ }
+ for(j=0; j<lemp->nterminal; j++){
+ if( sp->firstset && SetFind(sp->firstset, j) ){
+ fprintf(fp, " %s", lemp->symbols[j]->name);
+ }
+ }
+ }
+ fprintf(fp, "\n");
+ }
fclose(fp);
return;
}