diff options
author | drh <drh@noemail.net> | 2010-07-19 01:52:07 +0000 |
---|---|---|
committer | drh <drh@noemail.net> | 2010-07-19 01:52:07 +0000 |
commit | dd7e9dba970b24e572179aea087ff3c83e8697cd (patch) | |
tree | 07acb44c28656b2cef5c4d9e97f510c406e26178 /tool/lemon.c | |
parent | f5c4e0f12a6f944467f6c29be87a83d873b382aa (diff) | |
download | sqlite-dd7e9dba970b24e572179aea087ff3c83e8697cd.tar.gz sqlite-dd7e9dba970b24e572179aea087ff3c83e8697cd.zip |
Improvements to the formatting of parse.out file from Lemon. Add the -r option
to Lemon to disable the state sorting, making debugging easier.
FossilOrigin-Name: a2eaf8294f6d3fb39548987d632e934bb5d71cc9
Diffstat (limited to 'tool/lemon.c')
-rw-r--r-- | tool/lemon.c | 15 |
1 files changed, 9 insertions, 6 deletions
diff --git a/tool/lemon.c b/tool/lemon.c index 6d8b220ea..70d7c1cbf 100644 --- a/tool/lemon.c +++ b/tool/lemon.c @@ -1085,7 +1085,7 @@ static int resolve_conflict( /* Not enough precedence information. */ apy->type = SRCONFLICT; errcnt++; - }else if( spx->prec>spy->prec ){ /* Lower precedence wins */ + }else if( spx->prec>spy->prec ){ /* higher precedence wins */ apy->type = RD_RESOLVED; }else if( spx->prec<spy->prec ){ apx->type = SH_RESOLVED; @@ -1405,6 +1405,7 @@ int main(int argc, char **argv) static int statistics = 0; static int mhflag = 0; static int nolinenosflag = 0; + static int noResort = 0; static struct s_options options[] = { {OPT_FLAG, "b", (char*)&basisflag, "Print only the basis in report."}, {OPT_FLAG, "c", (char*)&compress, "Don't compress the action table."}, @@ -1416,6 +1417,7 @@ int main(int argc, char **argv) {OPT_FLAG, "p", (char*)&showPrecedenceConflict, "Show conflicts resolved by precedence rules"}, {OPT_FLAG, "q", (char*)&quiet, "(Quiet) Don't print the report file."}, + {OPT_FLAG, "r", (char*)&noResort, "Do not sort or renumber states"}, {OPT_FLAG, "s", (char*)&statistics, "Print parser stats to standard output."}, {OPT_FLAG, "x", (char*)&version, "Print the version number."}, @@ -1502,8 +1504,9 @@ int main(int argc, char **argv) if( compress==0 ) CompressTables(&lem); /* Reorder and renumber the states so that states with fewer choices - ** occur at the end. */ - ResortStates(&lem); + ** occur at the end. This is an optimization that helps make the + ** generated parser tables smaller. */ + if( noResort==0 ) ResortStates(&lem); /* Generate a report of the parser generated. (the "y.output" file) */ if( !quiet ) ReportOutput(&lem); @@ -2899,12 +2902,12 @@ int PrintAction(struct action *ap, FILE *fp, int indent){ indent,ap->sp->name,ap->x.rp->index); break; case SSCONFLICT: - fprintf(fp,"%*s shift %d ** Parsing conflict **", + fprintf(fp,"%*s shift %-3d ** Parsing conflict **", indent,ap->sp->name,ap->x.stp->statenum); break; case SH_RESOLVED: if( showPrecedenceConflict ){ - fprintf(fp,"%*s shift %d -- dropped by precedence", + fprintf(fp,"%*s shift %-3d -- dropped by precedence", indent,ap->sp->name,ap->x.stp->statenum); }else{ result = 0; @@ -2912,7 +2915,7 @@ int PrintAction(struct action *ap, FILE *fp, int indent){ break; case RD_RESOLVED: if( showPrecedenceConflict ){ - fprintf(fp,"%*s reduce %d -- dropped by precedence", + fprintf(fp,"%*s reduce %-3d -- dropped by precedence", indent,ap->sp->name,ap->x.rp->index); }else{ result = 0; |