static void
set_firsts (void)
{
- unsigned *row;
- int symbol;
- short *sp;
int rowsize;
- int i;
+ int i, j;
varsetsize = rowsize = WORDSIZE (nvars);
firsts = XCALLOC (unsigned, nvars * rowsize);
- row = firsts;
for (i = ntokens; i < nsyms; i++)
- {
- sp = derives[i];
- while (*sp >= 0)
- {
- symbol = ritem[rule_table[*sp++].rhs];
- if (ISVAR (symbol))
- {
- symbol -= ntokens;
- SETBIT (row, symbol);
- }
- }
-
- row += rowsize;
- }
+ for (j = 0; derives[i][j] >= 0; ++j)
+ {
+ int symbol = ritem[rule_table[derives[i][j]].rhs];
+ if (ISVAR (symbol))
+ {
+ symbol -= ntokens;
+ SETBIT (FIRSTS (i - ntokens), symbol);
+ }
+ }
RTC (firsts, nvars);
void
closure (short *core, int n)
{
- int ruleno;
/* Index over CORE. */
int c;
int r;
/* A bit index over RULESET. */
- int b;
+ int ruleno;
if (trace_flag)
{
ruleset[r] |= FDERIVES (ritem[core[c]])[r];
}
- ruleno = 0;
itemsetsize = 0;
c = 0;
- for (b = 0; b < rulesetsize * BITS_PER_WORD; ++b)
- {
- if (BITISSET (ruleset, b))
- {
- int itemno = rule_table[ruleno].rhs;
- while (c < n && core[c] < itemno)
- {
- itemset[itemsetsize] = core[c];
- itemsetsize++;
- c++;
- }
- itemset[itemsetsize] = itemno;
- itemsetsize++;
- }
-
- ruleno++;
- }
+ for (ruleno = 0; ruleno < rulesetsize * BITS_PER_WORD; ++ruleno)
+ if (BITISSET (ruleset, ruleno))
+ {
+ int itemno = rule_table[ruleno].rhs;
+ while (c < n && core[c] < itemno)
+ {
+ itemset[itemsetsize] = core[c];
+ itemsetsize++;
+ c++;
+ }
+ itemset[itemsetsize] = itemno;
+ itemsetsize++;
+ }
while (c < n)
{