From e20dc913b77451027e86bd6c29755122820843ed Mon Sep 17 00:00:00 2001 From: Randy Heit Date: Sun, 20 Mar 2016 09:57:51 -0500 Subject: [PATCH] Lemon update 2010-07-18 11:35:53 on branch trunk - Add the -p option to lemon to cause conflicts resolved by precedence rules to appear in the parse.out file. (user: drh) --- tools/lemon/lemon.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/tools/lemon/lemon.c b/tools/lemon/lemon.c index e21a4cffc6..2dedf16dc5 100644 --- a/tools/lemon/lemon.c +++ b/tools/lemon/lemon.c @@ -44,6 +44,7 @@ extern int access(char *path, int mode); #define MAXRHS 1000 #endif +static int showPrecedenceConflict = 0; static void *msort(void *list, void *next, int (*cmp)()); /* @@ -1419,6 +1420,8 @@ int main(int argc, char **argv) {OPT_FLAG, "g", (char*)&rpflag, "Print grammar without actions."}, {OPT_FLAG, "m", (char*)&mhflag, "Output a makeheaders compatible file."}, {OPT_FLAG, "l", (char*)&nolinenosflag, "Do not print #line statements."}, + {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, "s", (char*)&statistics, "Print parser stats to standard output."}, @@ -2896,7 +2899,21 @@ int PrintAction(struct action *ap, FILE *fp, int indent){ indent,ap->sp->name,ap->x.stp->statenum); break; case SH_RESOLVED: + if( showPrecedenceConflict ){ + fprintf(fp,"%*s shift %d -- dropped by precedence", + indent,ap->sp->name,ap->x.stp->statenum); + }else{ + result = 0; + } + break; case RD_RESOLVED: + if( showPrecedenceConflict ){ + fprintf(fp,"%*s reduce %d -- dropped by precedence", + indent,ap->sp->name,ap->x.rp->index); + }else{ + result = 0; + } + break; case NOT_USED: result = 0; break;