diff options
Diffstat (limited to 'contrib/byacc/verbose.c')
-rw-r--r-- | contrib/byacc/verbose.c | 64 |
1 files changed, 31 insertions, 33 deletions
diff --git a/contrib/byacc/verbose.c b/contrib/byacc/verbose.c index 1135e8f17421..b29dbfe11d7f 100644 --- a/contrib/byacc/verbose.c +++ b/contrib/byacc/verbose.c @@ -1,4 +1,4 @@ -/* $Id: verbose.c,v 1.12 2016/06/07 00:22:05 tom Exp $ */ +/* $Id: verbose.c,v 1.14 2021/05/20 23:57:23 tom Exp $ */ #include "defs.h" @@ -36,9 +36,10 @@ verbose(void) if (SRtotal || RRtotal) log_conflicts(); - fprintf(verbose_file, "\n\n%d terminals, %d nonterminals\n", ntokens, - nvars); - fprintf(verbose_file, "%d grammar rules, %d states\n", nrules - 2, nstates); + fprintf(verbose_file, "\n\n%ld terminals, %ld nonterminals\n", + (long)ntokens, (long)nvars); + fprintf(verbose_file, "%ld grammar rules, %ld states\n", + (long)(nrules - 2), (long)nstates); #if defined(YYBTYACC) { /* print out the grammar symbol # and parser internal symbol # for each symbol as an aide to writing the implementation for YYDESTRUCT_CALL() @@ -92,14 +93,14 @@ log_conflicts(void) { fprintf(verbose_file, "State %d contains ", i); if (SRconflicts[i] > 0) - fprintf(verbose_file, "%d shift/reduce conflict%s", - SRconflicts[i], + fprintf(verbose_file, "%ld shift/reduce conflict%s", + (long)SRconflicts[i], PLURAL(SRconflicts[i])); if (SRconflicts[i] && RRconflicts[i]) fprintf(verbose_file, ", "); if (RRconflicts[i] > 0) - fprintf(verbose_file, "%d reduce/reduce conflict%s", - RRconflicts[i], + fprintf(verbose_file, "%ld reduce/reduce conflict%s", + (long)RRconflicts[i], PLURAL(RRconflicts[i])); fprintf(verbose_file, ".\n"); } @@ -147,20 +148,20 @@ print_conflicts(int state) if (state == final_state && symbol == 0) { fprintf(verbose_file, "%d: shift/reduce conflict \ -(accept, reduce %d) on $end\n", state, p->number - 2); +(accept, reduce %ld) on $end\n", state, (long)(p->number - 2)); } else { if (act == SHIFT) { fprintf(verbose_file, "%d: shift/reduce conflict \ -(shift %d, reduce %d) on %s\n", state, number, p->number - 2, +(shift %ld, reduce %ld) on %s\n", state, (long)number, (long)(p->number - 2), symbol_name[symbol]); } else { fprintf(verbose_file, "%d: reduce/reduce conflict \ -(reduce %d, reduce %d) on %s\n", state, number - 2, p->number - 2, +(reduce %ld, reduce %ld) on %s\n", state, (long)(number - 2), (long)(p->number - 2), symbol_name[symbol]); } } @@ -172,18 +173,14 @@ static void print_core(int state) { int i; - int k; - int rule; - core *statep; - Value_t *sp; - Value_t *sp1; - - statep = state_table[state]; - k = statep->nitems; + core *statep = state_table[state]; + int k = statep->nitems; for (i = 0; i < k; i++) { - sp1 = sp = ritem + statep->items[i]; + int rule; + Value_t *sp = ritem + statep->items[i]; + Value_t *sp1 = sp; while (*sp >= 0) ++sp; @@ -200,7 +197,7 @@ print_core(int state) fprintf(verbose_file, " %s", symbol_name[*sp]); sp++; } - fprintf(verbose_file, " (%d)\n", -2 - *sp); + fprintf(verbose_file, " (%ld)\n", (long)(-2 - *sp)); } } @@ -241,8 +238,8 @@ print_nulls(int state) for (i = 0; i < nnulls; ++i) { j = null_rules[i]; - fprintf(verbose_file, "\t%s : . (%d)\n", symbol_name[rlhs[j]], - j - 2); + fprintf(verbose_file, "\t%s : . (%ld)\n", symbol_name[rlhs[j]], + (long)(j - 2)); } fprintf(verbose_file, "\n"); } @@ -252,7 +249,6 @@ print_actions(int stateno) { action *p; shifts *sp; - int as; if (stateno == final_state) fprintf(verbose_file, "\t$end accept\n"); @@ -267,7 +263,8 @@ print_actions(int stateno) sp = shift_table[stateno]; if (sp && sp->nshifts > 0) { - as = accessing_symbol[sp->shift[sp->nshifts - 1]]; + int as = accessing_symbol[sp->shift[sp->nshifts - 1]]; + if (ISVAR(as)) print_gotos(stateno); } @@ -291,8 +288,8 @@ print_shifts(action *p) for (; p; p = p->next) { if (p->action_code == SHIFT && p->suppressed == 0) - fprintf(verbose_file, "\t%s shift %d\n", - symbol_name[p->symbol], p->number); + fprintf(verbose_file, "\t%s shift %ld\n", + symbol_name[p->symbol], (long)p->number); #if defined(YYBTYACC) if (backtrack && p->action_code == SHIFT && p->suppressed == 1) fprintf(verbose_file, "\t%s [trial] shift %d\n", @@ -305,7 +302,7 @@ print_shifts(action *p) static void print_reductions(action *p, int defred2) { - int k, anyreds; + int anyreds; action *q; anyreds = 0; @@ -326,7 +323,8 @@ print_reductions(action *p, int defred2) { if (p->action_code == REDUCE && p->number != defred2) { - k = p->number - 2; + int k = p->number - 2; + if (p->suppressed == 0) fprintf(verbose_file, "\t%s reduce %d\n", symbol_name[p->symbol], k); @@ -346,8 +344,7 @@ print_reductions(action *p, int defred2) static void print_gotos(int stateno) { - int i, k; - int as; + int i; Value_t *to_state2; shifts *sp; @@ -356,8 +353,9 @@ print_gotos(int stateno) to_state2 = sp->shift; for (i = 0; i < sp->nshifts; ++i) { - k = to_state2[i]; - as = accessing_symbol[k]; + int k = to_state2[i]; + int as = accessing_symbol[k]; + if (ISVAR(as)) fprintf(verbose_file, "\t%s goto %d\n", symbol_name[as], k); } |