mirror of
https://git.savannah.gnu.org/git/bison.git
synced 2026-03-09 04:13:03 +00:00
lalr: offer more flexibility in debugging routines
* src/state.h, src/state.c (state_transitions_print): New, extracted from... (state_transitions_set): here.
This commit is contained in:
27
src/state.c
27
src/state.c
@@ -189,6 +189,21 @@ state_free (state *s)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
state_transitions_print (const state *s, FILE *out)
|
||||||
|
{
|
||||||
|
const transitions *trans = s->transitions;
|
||||||
|
fprintf (out, "transitions of %d (%d):\n",
|
||||||
|
s->number, trans->num);
|
||||||
|
for (int i = 0; i < trans->num; ++i)
|
||||||
|
fprintf (out, " %d: (%d, %s, %d)\n",
|
||||||
|
i,
|
||||||
|
s->number,
|
||||||
|
symbols[s->transitions->states[i]->accessing_symbol]->tag,
|
||||||
|
s->transitions->states[i]->number);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/*---------------------------.
|
/*---------------------------.
|
||||||
| Set the transitions of S. |
|
| Set the transitions of S. |
|
||||||
`---------------------------*/
|
`---------------------------*/
|
||||||
@@ -199,17 +214,7 @@ state_transitions_set (state *s, int num, state **dst)
|
|||||||
aver (!s->transitions);
|
aver (!s->transitions);
|
||||||
s->transitions = transitions_new (num, dst);
|
s->transitions = transitions_new (num, dst);
|
||||||
if (trace_flag & trace_automaton)
|
if (trace_flag & trace_automaton)
|
||||||
{
|
state_transitions_print (s, stderr);
|
||||||
const transitions *trans = s->transitions;
|
|
||||||
fprintf (stderr, "transitions of %d (%d):\n",
|
|
||||||
s->number, trans->num);
|
|
||||||
for (int i = 0; i < trans->num; ++i)
|
|
||||||
fprintf (stderr, " %d: (%d, %s, %d)\n",
|
|
||||||
i,
|
|
||||||
s->number,
|
|
||||||
symbols[s->transitions->states[i]->accessing_symbol]->tag,
|
|
||||||
s->transitions->states[i]->number);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -236,6 +236,9 @@ state *state_new_isocore (state const *s);
|
|||||||
/* Record that from S we can reach all the DST states (NUM of them). */
|
/* Record that from S we can reach all the DST states (NUM of them). */
|
||||||
void state_transitions_set (state *s, int num, state **dst);
|
void state_transitions_set (state *s, int num, state **dst);
|
||||||
|
|
||||||
|
/* Print the transitions of state s for debug. */
|
||||||
|
void state_transitions_print (const state *s, FILE *out);
|
||||||
|
|
||||||
/* Set the reductions of STATE. */
|
/* Set the reductions of STATE. */
|
||||||
void state_reductions_set (state *s, int num, rule **reds);
|
void state_reductions_set (state *s, int num, rule **reds);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user