[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
lalr: offer more flexibility in debugging routines
From: |
Akim Demaille |
Subject: |
lalr: offer more flexibility in debugging routines |
Date: |
Wed, 3 Apr 2019 19:20:18 +0200 |
commit 10175e4a6590ba4d29941d49a67d0f9d0012884f
Author: Akim Demaille <address@hidden>
Date: Wed Apr 3 07:24:56 2019 +0200
lalr: offer more flexibility in debugging routines
* src/state.h, src/state.c (state_transitions_print): New, extracted
from...
(state_transitions_set): here.
diff --git a/src/state.c b/src/state.c
index 29eca5b9..87fbb1c6 100644
--- a/src/state.c
+++ b/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. |
`---------------------------*/
@@ -199,17 +214,7 @@ state_transitions_set (state *s, int num, state **dst)
aver (!s->transitions);
s->transitions = transitions_new (num, dst);
if (trace_flag & trace_automaton)
- {
- 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);
- }
+ state_transitions_print (s, stderr);
}
diff --git a/src/state.h b/src/state.h
index 605d7e1d..031d959b 100644
--- a/src/state.h
+++ b/src/state.h
@@ -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). */
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. */
void state_reductions_set (state *s, int num, rule **reds);
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- lalr: offer more flexibility in debugging routines,
Akim Demaille <=