+static void
+prepare_rules (void)
+{
+ rule_number_t r;
+ unsigned int i = 0;
+ item_number_t *rhs = XMALLOC (item_number_t, nritems);
+ unsigned int *prhs = XMALLOC (unsigned int, nrules + 1);
+ unsigned int *rline = XMALLOC (unsigned int, nrules + 1);
+ symbol_number_t *r1 = XMALLOC (symbol_number_t, nrules + 1);
+ unsigned int *r2 = XMALLOC (unsigned int, nrules + 1);
+ short *dprec = XMALLOC (short, nrules + 1);
+ short *merger = XMALLOC (short, nrules + 1);
+
+ for (r = 1; r < nrules + 1; ++r)
+ {
+ item_number_t *rhsp = NULL;
+ /* Index of rule R in RHS. */
+ prhs[r] = i;
+ /* RHS of the rule R. */
+ for (rhsp = rules[r].rhs; *rhsp >= 0; ++rhsp)
+ rhs[i++] = *rhsp;
+ /* LHS of the rule R. */
+ r1[r] = rules[r].lhs->number;
+ /* Length of rule R's RHS. */
+ r2[r] = i - prhs[r];
+ /* Separator in RHS. */
+ rhs[i++] = -1;
+ /* Line where rule was defined. */
+ rline[r] = rules[r].location.first_line;
+ /* Dynamic precedence (GLR) */
+ dprec[r] = rules[r].dprec;
+ /* Merger-function index (GLR) */
+ merger[r] = rules[r].merger;
+ }
+ assert (i == nritems);
+
+ muscle_insert_item_number_table ("rhs", rhs, ritem[0], 1, nritems);
+ muscle_insert_unsigned_int_table ("prhs", prhs, 0, 1, nrules + 1);
+ muscle_insert_unsigned_int_table ("rline", rline, 0, 1, nrules + 1);
+ muscle_insert_symbol_number_table ("r1", r1, 0, 1, nrules + 1);
+ muscle_insert_unsigned_int_table ("r2", r2, 0, 1, nrules + 1);
+ muscle_insert_short_table ("dprec", dprec, 0, 1, nrules + 1);
+ muscle_insert_short_table ("merger", merger, 0, 1, nrules + 1);
+
+ free (rhs);
+ free (prhs);
+ free (rline);
+ free (r1);
+ free (r2);
+ free (dprec);
+ free (merger);