#include "derives.h"
#include "warshall.h"
+/* ITEMSETSIZE is the size of the array ITEMSET. */
short *itemset;
-short *itemsetend;
+int itemsetsize;
+
static unsigned *ruleset;
/* internal data. See comments before set_fderives and set_firsts. */
static void
print_closure (int n)
{
- short *isp;
-
+ int i;
fprintf (stderr, "n = %d\n", n);
- for (isp = itemset; isp < itemsetend; isp++)
- fprintf (stderr, " %d\n", *isp);
+ for (i = 0; i < itemsetsize; ++i)
+ fprintf (stderr, " %d\n", itemset[i]);
fprintf (stderr, "\n\n");
}
for (j = 0; j <= nrules; j++)
if (BITISSET (rp, j))
- fprintf (stderr, "\t\t%d (%s)\n", j, tags[j]);
+ {
+ short *rhsp;
+ fprintf (stderr, "\t\t%d:", j);
+ for (rhsp = ritem + rule_table[j].rhs; *rhsp > 0; ++rhsp)
+ fprintf (stderr, " %s", tags[*rhsp]);
+ fputc ('\n', stderr);
+ }
}
fprintf (stderr, "\n\n");
}
}
ruleno = 0;
- itemsetend = itemset;
+ itemsetsize = 0;
csp = core;
- for (i= 0; i < rulesetsize; ++i)
+ for (i = 0; i < rulesetsize; ++i)
{
int word = ruleset[i];
if (word == 0)
if (word & (1 << b))
{
itemno = rule_table[ruleno].rhs;
- while (csp < (core + n ) && *csp < itemno)
- *itemsetend++ = *csp++;
- *itemsetend++ = itemno;
+ while (csp < (core + n) && *csp < itemno)
+ itemset[itemsetsize++] = *csp++;
+ itemset[itemsetsize++] = itemno;
}
ruleno++;
}
while (csp < (core + n))
- *itemsetend++ = *csp++;
+ itemset[itemsetsize++] = *csp++;
if (trace_flag)
print_closure (n);