X-Git-Url: https://git.saurik.com/bison.git/blobdiff_plain/43168960182a2537605d6a1262a39e4e43c57d98..331dbc1bb7fac0b108adc5591bd9308a39629287:/src/print.c diff --git a/src/print.c b/src/print.c index 025c179f..d7d04eab 100644 --- a/src/print.c +++ b/src/print.c @@ -49,8 +49,8 @@ static void print_core (FILE *out, int state) { int i; - short *sitems = state_table[state].state->items; - int snitems = state_table[state].state->nitems; + short *sitems = state_table[state]->items; + int snitems = state_table[state]->nitems; /* New experimental feature: if TRACE_FLAGS output all the items of a state, not only its kernel. */ @@ -98,9 +98,9 @@ print_actions (FILE *out, int state) { int i; - shifts *shiftp = state_table[state].shift_table; - reductions *redp = state_table[state].reduction_table; - errs *errp = err_table[state]; + shifts *shiftp = state_table[state]->shifts; + reductions *redp = state_table[state]->reductions; + errs *errp = state_table[state]->errs; if (!shiftp->nshifts && !redp) { @@ -111,21 +111,14 @@ print_actions (FILE *out, int state) return; } - for (i = 0; i < shiftp->nshifts; i++) + for (i = 0; i < shiftp->nshifts && SHIFT_IS_SHIFT (shiftp, i); i++) if (!SHIFT_IS_DISABLED (shiftp, i)) { int state1 = shiftp->shifts[i]; - int symbol = state_table[state1].accessing_symbol; - /* The following line used to be turned off. */ - if (ISVAR (symbol)) - break; - if (symbol == 0) /* I.e. strcmp(tags[symbol],"$")==0 */ - fprintf (out, - _(" $ \tgo to state %d\n"), state1); - else - fprintf (out, - _(" %-4s\tshift, and go to state %d\n"), - tags[symbol], state1); + int symbol = state_table[state1]->accessing_symbol; + fprintf (out, + _(" %-4s\tshift, and go to state %d\n"), + tags[symbol], state1); } if (i > 0) @@ -147,7 +140,7 @@ print_actions (FILE *out, int state) fputc ('\n', out); } - if (state_table[state].consistent && redp) + if (state_table[state]->consistent && redp) { int rule = redp->rules[0]; int symbol = rule_table[rule].lhs; @@ -165,7 +158,7 @@ print_actions (FILE *out, int state) if (!SHIFT_IS_DISABLED (shiftp, i)) { int state1 = shiftp->shifts[i]; - int symbol = state_table[state1].accessing_symbol; + int symbol = state_table[state1]->accessing_symbol; fprintf (out, _(" %-4s\tgo to state %d\n"), tags[symbol], state1); } @@ -314,35 +307,33 @@ print_grammar (FILE *out) void print_results (void) { - if (verbose_flag) - { - int i; + int i; - /* We used to use just .out if spec_name_prefix (-p) was used, but - that conflicts with Posix. */ - FILE *out = xfopen (spec_verbose_file, "w"); + /* We used to use just .out if SPEC_NAME_PREFIX (-p) was used, but + that conflicts with Posix. */ + FILE *out = xfopen (spec_verbose_file, "w"); - size_t size = obstack_object_size (&output_obstack); - fwrite (obstack_finish (&output_obstack), 1, size, out); - if (size) - fputs ("\n\n", out); + size_t size = obstack_object_size (&output_obstack); + fwrite (obstack_finish (&output_obstack), 1, size, out); + obstack_free (&output_obstack, NULL); - reduce_output (out); - conflicts_output (out); + if (size) + fputs ("\n\n", out); - print_grammar (out); + reduce_output (out); + conflicts_output (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) - new_closure (nitems); - for (i = 0; i < nstates; i++) - print_state (out, i); - if (trace_flag) - free_closure (); + print_grammar (out); - xfclose (out); - } - obstack_free (&output_obstack, NULL); + /* 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) + new_closure (nitems); + for (i = 0; i < nstates; i++) + print_state (out, i); + if (trace_flag) + free_closure (); + + xfclose (out); }