From: drh Date: Wed, 18 Jul 2007 18:16:29 +0000 (+0000) Subject: Additional diagnostics added to the "out" file generated by lemon. (CVS 4160) X-Git-Tag: version-3.4.1~10 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=e927818455ebb5b914b66458b444386e0c175206;p=thirdparty%2Fsqlite.git Additional diagnostics added to the "out" file generated by lemon. (CVS 4160) FossilOrigin-Name: 7ef2aaf72a8a953df7a763dd94657bb4ff05294f --- diff --git a/manifest b/manifest index 894fd4fc5e..998a0299ac 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -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 @@ -441,7 +441,7 @@ F test/where5.test fdf66f96d29a064b63eb543e28da4dfdccd81ad2 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 @@ -517,7 +517,7 @@ F www/tclsqlite.tcl 8be95ee6dba05eabcd27a9d91331c803f2ce2130 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 diff --git a/manifest.uuid b/manifest.uuid index d2dc1a918f..176c17a2e8 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -4daadf659afe6b2524e1b37347247f233a211950 \ No newline at end of file +7ef2aaf72a8a953df7a763dd94657bb4ff05294f \ No newline at end of file diff --git a/tool/lemon.c b/tool/lemon.c index 3acd9e5365..6cfe7315d1 100644 --- a/tool/lemon.c +++ b/tool/lemon.c @@ -11,6 +11,7 @@ #include #include #include +#include #ifndef __WIN32__ # if defined(_WIN32) || defined(WIN32) @@ -27,20 +28,10 @@ #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(); @@ -332,7 +323,7 @@ void Configtable_clear(/* int(*)(struct config *) */); */ /* Allocate a new parser action */ -struct action *Action_new(){ +static struct action *Action_new(void){ static struct action *freelist = 0; struct action *new; @@ -352,11 +343,14 @@ struct action *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; @@ -367,10 +361,11 @@ struct action *ap2; } /* 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; } @@ -556,17 +551,6 @@ int acttab_insert(acttab *p){ 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 @@ -970,7 +954,7 @@ struct lemon *lemp; 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){ @@ -1560,12 +1544,12 @@ char **argv; ** 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 ){ @@ -1612,11 +1596,11 @@ int offset; ** 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]; @@ -2856,7 +2840,6 @@ struct lemon *lemp; fp = file_open(lemp,".out","wb"); if( fp==0 ) return; - fprintf(fp," \b"); for(i=0; instate; i++){ stp = lemp->sorted[i]; fprintf(fp,"State %d:\n",stp->statenum); @@ -2886,6 +2869,27 @@ struct lemon *lemp; } fprintf(fp,"\n"); } + fprintf(fp, "----------------------------------------------------\n"); + fprintf(fp, "Symbols:\n"); + for(i=0; insymbol; 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, " "); + } + for(j=0; jnterminal; j++){ + if( sp->firstset && SetFind(sp->firstset, j) ){ + fprintf(fp, " %s", lemp->symbols[j]->name); + } + } + } + fprintf(fp, "\n"); + } fclose(fp); return; }