if (!bitset_test (P, i)
&& useful_production (i, N))
{
- bitset_set (Np, rules[i].lhs - ntokens);
+ bitset_set (Np, rules[i].lhs->number - ntokens);
bitset_set (P, i);
}
if (bitset_equal_p (N, Np))
{
if (!bitset_test (Pp, i)
&& bitset_test (P, i)
- && bitset_test (V, rules[i].lhs))
+ && bitset_test (V, rules[i].lhs->number))
{
for (r = rules[i].rhs; *r >= 0; r++)
if (ISTOKEN (t = *r) || bitset_test (N, t - ntokens))
free (rules + 1);
rules = rules_sorted;
- /* Also reorder ritems. */
- {
- short *ritems_sorted = XCALLOC (short, nitems + 1);
- short *ritemsp = ritems_sorted;
- for (i = 1; i < nrules + 1; ++i)
- {
- short *rhsp = rules[i].rhs;
- rules[i].rhs = ritemsp;
- for (/* Nothing. */; *rhsp >= 0; ++rhsp)
- *ritemsp++ = *rhsp;
- *ritemsp++ = -i;
- }
- *ritemsp++ = 0;
- free (ritem);
- ritem = ritems_sorted;
- }
+ /* Renumber the rules markers in RITEMS. */
+ for (i = 1; i < nrules + 1; ++i)
+ {
+ short *rhsp = rules[i].rhs;
+ for (/* Nothing. */; *rhsp >= 0; ++rhsp)
+ /* Nothing. */;
+ *rhsp = -i;
+ rules[i].number = i;
+ }
nrules -= nuseless_productions;
}
{
bucket **symbols_sorted = XMALLOC (bucket *, nvars) - ntokens;
+ for (i = ntokens; i < nsyms; i++)
+ symbols[i]->number = nontermmap[i];
for (i = ntokens; i < nsyms; i++)
symbols_sorted[nontermmap[i]] = symbols[i];
for (i = ntokens; i < nsyms; i++)
for (i = 1; i < nrules + 1; i++)
{
- rules[i].lhs = nontermmap[rules[i].lhs];
if (ISVAR (rules[i].precsym))
/* Can this happen? */
rules[i].precsym = nontermmap[rules[i].precsym];
for (i = nrules + 1; i < nuseless_productions + nrules + 1; i++)
{
rule r;
- fprintf (out, "#%-4d ", rules[i].number - 1);
- fprintf (out, "%s:", symbols[rules[i].lhs]->tag);
+ fprintf (out, "#%-4d ", rules[i].user_number - 1);
+ fprintf (out, "%s:", rules[i].lhs->tag);
for (r = rules[i].rhs; *r >= 0; r++)
fprintf (out, " %s", symbols[*r]->tag);
fputs (";\n", out);
i - 1,
rules[i].prec, rules[i].assoc, rules[i].useful,
rules[i].rhs - ritem, rules[i].rhs - ritem + rhs_count - 1,
- rules[i].lhs);
+ rules[i].lhs->number);
/* Dumped the RHS. */
for (r = rules[i].rhs; *r >= 0; r++)
fprintf (out, "%3d", *r);
fprintf (out, "Rules interpreted\n-----------------\n\n");
for (i = 1; i < nrules + nuseless_productions + 1; i++)
{
- fprintf (out, "%-5d %s :", i, symbols[rules[i].lhs]->tag);
+ fprintf (out, "%-5d %s :", i, rules[i].lhs->tag);
for (r = rules[i].rhs; *r >= 0; r++)
fprintf (out, " %s", symbols[*r]->tag);
fputc ('\n', out);