+static void
+add_lookback_edge (state_t *state, int ruleno, int gotono)
+{
+ int i;
+ shorts *sp;
+
+ for (i = 0; i < state->nlookaheads; ++i)
+ if (LAruleno[state->lookaheadsp + i] == ruleno)
+ break;
+
+ assert (LAruleno[state->lookaheadsp + i] == ruleno);
+
+ sp = XCALLOC (shorts, 1);
+ sp->next = lookback[state->lookaheadsp + i];
+ sp->value = gotono;
+ lookback[state->lookaheadsp + i] = sp;
+}
+
+
+static void
+matrix_print (FILE *out, short **matrix, int n)
+{
+ int i, j;
+
+ for (i = 0; i < n; ++i)
+ {
+ fprintf (out, "%3d: ", i);
+ if (matrix[i])
+ for (j = 0; matrix[i][j] != -1; ++j)
+ fprintf (out, "%3d ", matrix[i][j]);
+ fputc ('\n', out);
+ }
+ fputc ('\n', out);
+}
+
+/*-------------------------------------------------------------------.
+| Return the transpose of R_ARG, of size N. Destroy R_ARG, as it is |
+| replaced with the result. |
+| |
+| R_ARG[I] is NULL or a -1 terminated list of numbers. |
+| |
+| RESULT[NUM] is NULL or the -1 terminated list of the I such as NUM |
+| is in R_ARG[I]. |
+`-------------------------------------------------------------------*/
+
+static short **
+transpose (short **R_arg, int n)
+{
+ /* The result. */
+ short **new_R = XCALLOC (short *, n);
+ /* END_R[I] -- next entry of NEW_R[I]. */
+ short **end_R = XCALLOC (short *, n);
+ /* NEDGES[I] -- total size of NEW_R[I]. */
+ short *nedges = XCALLOC (short, n);
+ int i, j;
+
+ if (trace_flag)
+ {
+ fputs ("transpose: input\n", stderr);
+ matrix_print (stderr, R_arg, n);