X-Git-Url: https://git.saurik.com/bison.git/blobdiff_plain/d4e7d3a1919c20a6dbf5eb4cfa62cb6228a0e48d..86eff18354964702e7f32d8b1550264efa573147:/src/print.c diff --git a/src/print.c b/src/print.c index cfc047f1..d8a4f008 100644 --- a/src/print.c +++ b/src/print.c @@ -72,9 +72,8 @@ print_core (FILE *out, state_t *state) item_number_t *sitems = state->items; int snritems = state->nitems; - /* New experimental feature: if TRACE_FLAGS output all the items of - a state, not only its kernel. */ - if (trace_flag) + /* Output all the items of a state, not only its kernel. */ + if (report_flag & report_itemsets) { closure (sitems, snritems); sitems = itemset; @@ -105,8 +104,8 @@ print_core (FILE *out, state_t *state) for (/* Nothing */; *sp >= 0; ++sp) fprintf (out, " %s", escape (symbols[*sp]->tag)); - /* Experimental feature: display the lookaheads. */ - if (trace_flag && state->nlookaheads) + /* Display the lookaheads? */ + if (report_flag & report_lookaheads) { int j, k; int nlookaheads = 0; @@ -150,7 +149,7 @@ print_shifts (FILE *out, state_t *state) if (!SHIFT_IS_DISABLED (shiftp, i)) { int state1 = shiftp->shifts[i]; - token_number_t symbol = states[state1]->accessing_symbol; + symbol_number_t symbol = states[state1]->accessing_symbol; fprintf (out, _(" %-4s\tshift, and go to state %d\n"), escape (symbols[symbol]->tag), state1); @@ -192,7 +191,7 @@ print_gotos (FILE *out, state_t *state) if (!SHIFT_IS_DISABLED (shiftp, i)) { int state1 = shiftp->shifts[i]; - token_number_t symbol = states[state1]->accessing_symbol; + symbol_number_t symbol = states[state1]->accessing_symbol; fprintf (out, _(" %-4s\tgo to state %d\n"), escape (symbols[symbol]->tag), state1); } @@ -216,7 +215,7 @@ print_reductions (FILE *out, state_t *state) if (state->consistent) { int rule = redp->rules[0]; - token_number_t symbol = rules[rule].lhs->number; + symbol_number_t symbol = rules[rule].lhs->number; fprintf (out, _(" $default\treduce using rule %d (%s)\n\n"), rule - 1, escape (symbols[symbol]->tag)); return; @@ -365,6 +364,9 @@ print_state (FILE *out, state_t *state) fputs ("\n\n", out); print_core (out, state); print_actions (out, state); + if ((report_flag & report_solved_conflicts) + && state->solved_conflicts) + fputs (state->solved_conflicts, out); fputs ("\n\n", out); } @@ -386,7 +388,7 @@ do { \ static void print_grammar (FILE *out) { - token_number_t i; + symbol_number_t i; int j; item_number_t *rule; char buffer[90]; @@ -423,7 +425,7 @@ print_grammar (FILE *out) for (j = 1; j < nrules + 1; j++) for (rule = rules[j].rhs; *rule >= 0; rule++) - if (item_number_as_token_number (*rule) == token_translations[i]) + if (item_number_as_symbol_number (*rule) == token_translations[i]) { END_TEST (65); sprintf (buffer + strlen (buffer), " %d", j - 1); @@ -444,7 +446,7 @@ print_grammar (FILE *out) if (rules[j].lhs->number == i) left_count++; for (rule = rules[j].rhs; *rule >= 0; rule++) - if (item_number_as_token_number (*rule) == i) + if (item_number_as_symbol_number (*rule) == i) { right_count++; break; @@ -479,7 +481,7 @@ print_grammar (FILE *out) for (j = 1; j < nrules + 1; j++) { for (rule = rules[j].rhs; *rule >= 0; rule++) - if (item_number_as_token_number (*rule) == i) + if (item_number_as_symbol_number (*rule) == i) { END_TEST (65); sprintf (buffer + strlen (buffer), " %d", j - 1); @@ -513,10 +515,9 @@ print_results (void) print_grammar (out); - /* New experimental feature: output all the items of a state, not - only its kernel. Requires to run closure, which need memory - allocation/deallocation. */ - if (trace_flag) + /* If the whole state item sets, not only the kernels, are wanted, + `closure' will be run, which needs memory allocation/deallocation. */ + if (report_flag & report_itemsets) new_closure (nritems); /* Storage for print_reductions. */ shiftset = bitset_create (ntokens, BITSET_FIXED); @@ -525,7 +526,7 @@ print_results (void) print_state (out, states[i]); bitset_free (shiftset); bitset_free (lookaheadset); - if (trace_flag) + if (report_flag & report_itemsets) free_closure (); xfclose (out);