1
0
mirror of https://github.com/sqlite/sqlite.git synced 2025-07-30 19:03:16 +03:00

Enhance LEMON to track which symbols actually carry semantic content.

Output the list of symbols that do not carry content at the end of the
report, but do not (yet) do anything else with the information.

FossilOrigin-Name: dcf2bafc159179859b91ffea3a4ebd70b5ca6de9e1d515eaf9afde8cfff26c6c
This commit is contained in:
drh
2018-04-21 20:24:19 +00:00
parent 42d181604c
commit 539e741e50
3 changed files with 33 additions and 9 deletions

View File

@ -1,5 +1,5 @@
C A\sfew\smore\stests\sfor\supsert.
D 2018-04-21T14:11:18.088
C Enhance\sLEMON\sto\strack\swhich\ssymbols\sactually\scarry\ssemantic\scontent.\nOutput\sthe\slist\sof\ssymbols\sthat\sdo\snot\scarry\scontent\sat\sthe\send\sof\sthe\nreport,\sbut\sdo\snot\s(yet)\sdo\sanything\selse\swith\sthe\sinformation.
D 2018-04-21T20:24:19.958
F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1
F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea
F Makefile.in 5ce9343cba9c189046f1afe6d2bcc1f68079439febc05267b98aec6ecc752439
@ -1644,7 +1644,7 @@ F tool/genfkey.README cf68fddd4643bbe3ff8e31b8b6d8b0a1b85e20f4
F tool/genfkey.test 4196a8928b78f51d54ef58e99e99401ab2f0a7e5
F tool/getlock.c f4c39b651370156cae979501a7b156bdba50e7ce
F tool/kvtest-speed.sh 4761a9c4b3530907562314d7757995787f7aef8f
F tool/lemon.c 735516a0aac3aeebc548b5db2acdda7a518e8d7f642b8debb0f46b01cd6ce5af
F tool/lemon.c 33892e2a243865f73e6c6e7cecce3c6eb4bb95db4a3d9d86d146c8064feb92fd
F tool/lempar.c 8ce83cbec62cba95819760de2ebab98a1b0d00861af5876bd456a29e1158229d
F tool/libvers.c caafc3b689638a1d88d44bc5f526c2278760d9b9
F tool/loadfts.c c3c64e4d5e90e8ba41159232c2189dba4be7b862
@ -1725,7 +1725,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93
F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc
F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e
F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0
P be47a6f5262a43f477700579512fe7112a0872faedcbbe5c3383d13a08af6440
R 3d53f1674a09601b7b69d45626b4c7ca
U dan
Z 2cb81c69429d6672e5a93f24af655a26
P b78005b6d41640203c163ffde4faf9336f11f47f42e8b7fe10b95415bbaed028
R bdad1972dfc51eb7c1aa0a96e8529d8a
U drh
Z c5d80323466004edd7fb02f443feea52

View File

@ -1 +1 @@
b78005b6d41640203c163ffde4faf9336f11f47f42e8b7fe10b95415bbaed028
dcf2bafc159179859b91ffea3a4ebd70b5ca6de9e1d515eaf9afde8cfff26c6c

View File

@ -270,6 +270,8 @@ struct symbol {
int dtnum; /* The data type number. In the parser, the value
** stack is a union. The .yy%d element of this
** union is the correct data type for this object */
int bContent; /* True if this symbol ever carries content - if
** it is ever more than just syntax */
/* The following fields are used by MULTITERMINALs only */
int nsubsym; /* Number of constituent symbols in the MULTI */
struct symbol **subsym; /* Array of constituent symbols */
@ -2377,6 +2379,7 @@ to follow the previous rule.");
for(i=0; i<psp->nrhs; i++){
rp->rhs[i] = psp->rhs[i];
rp->rhsalias[i] = psp->alias[i];
if( rp->rhsalias[i]!=0 ){ rp->rhs[i]->bContent = 1; }
}
rp->lhs = psp->lhs;
rp->lhsalias = psp->lhsalias;
@ -3282,7 +3285,7 @@ int PrintAction(
/* Generate the "*.out" log file */
void ReportOutput(struct lemon *lemp)
{
int i;
int i, n;
struct state *stp;
struct config *cfp;
struct action *ap;
@ -3322,6 +3325,7 @@ void ReportOutput(struct lemon *lemp)
}
fprintf(fp, "----------------------------------------------------\n");
fprintf(fp, "Symbols:\n");
fprintf(fp, "The first-set of non-terminals is shown after the name.\n\n");
for(i=0; i<lemp->nsymbol; i++){
int j;
struct symbol *sp;
@ -3343,6 +3347,26 @@ void ReportOutput(struct lemon *lemp)
fprintf(fp, "\n");
}
fprintf(fp, "----------------------------------------------------\n");
fprintf(fp, "Syntax-only Symbols:\n");
fprintf(fp, "The following symbols never carry semantic content.\n\n");
for(i=n=0; i<lemp->nsymbol; i++){
int w;
struct symbol *sp = lemp->symbols[i];
if( sp->bContent ) continue;
w = (int)strlen(sp->name);
if( n>0 && n+w>75 ){
fprintf(fp,"\n");
n = 0;
}
if( n>0 ){
fprintf(fp, " ");
n++;
}
fprintf(fp, "%s", sp->name);
n += w;
}
if( n>0 ) fprintf(fp, "\n");
fprintf(fp, "----------------------------------------------------\n");
fprintf(fp, "Rules:\n");
for(rp=lemp->rule; rp; rp=rp->next){
fprintf(fp, "%4d: ", rp->iRule);