`--------------------------------*/
static void
-print_core (FILE *out, int state)
+print_core (FILE *out, state_t *state)
{
int i;
- short *sitems = state_table[state]->items;
- int snitems = state_table[state]->nitems;
+ short *sitems = state->items;
+ int snitems = state->nitems;
/* New experimental feature: if TRACE_FLAGS output all the items of
a state, not only its kernel. */
}
static void
-print_actions (FILE *out, int state)
+print_actions (FILE *out, state_t *state)
{
int i;
- shifts *shiftp = state_table[state]->shifts;
- reductions *redp = state_table[state]->reductions;
- errs *errp = state_table[state]->errs;
+ shifts *shiftp = state->shifts;
+ reductions *redp = state->reductions;
+ errs *errp = state->errs;
if (!shiftp->nshifts && !redp)
{
- if (final_state == state)
+ if (final_state == state->number)
fprintf (out, _(" $default\taccept\n"));
else
fprintf (out, _(" NO ACTIONS\n"));
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);
+ fprintf (out,
+ _(" %-4s\tshift, and go to state %d\n"),
+ tags[symbol], state1);
}
if (i > 0)
fputc ('\n', out);
}
- if (state_table[state]->consistent && redp)
+ if (state->consistent && redp)
{
int rule = redp->rules[0];
int symbol = rule_table[rule].lhs;
}
static void
-print_state (FILE *out, int state)
+print_state (FILE *out, state_t *state)
{
- fprintf (out, _("state %d"), state);
+ fprintf (out, _("state %d"), state->number);
fputs ("\n\n", out);
print_core (out, state);
print_actions (out, state);
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, state_table[i]);
+ if (trace_flag)
+ free_closure ();
+
+ xfclose (out);
}