fprintf (stderr, "\t%s derives\n", symbols[i]->tag);
BITSET_FOR_EACH (iter, FDERIVES (i), r, 0)
{
- item_number_t *rhsp = NULL;
- fprintf (stderr, "\t\t%d:", r - 1);
- for (rhsp = rules[r].rhs; *rhsp >= 0; ++rhsp)
- fprintf (stderr, " %s", symbols[*rhsp]->tag);
- fputc ('\n', stderr);
+ fprintf (stderr, "\t\t%3d ", r);
+ rule_rhs_print (&rules[r], stderr);
}
}
fprintf (stderr, "\n\n");
firsts = bitsetv_create (nvars, nvars, BITSET_FIXED);
for (i = ntokens; i < nsyms; i++)
- for (j = 0; derives[i][j] >= 0; ++j)
+ for (j = 0; derives[i][j]; ++j)
{
- int symbol = rules[derives[i][j]].rhs[0];
+ int symbol = derives[i][j]->rhs[0];
if (ISVAR (symbol))
bitset_set (FIRSTS (i), symbol - ntokens);
}
- if (trace_flag)
+ if (trace_flag & trace_sets)
bitsetv_matrix_dump (stderr, "RTC: Firsts Input", firsts);
bitsetv_reflexive_transitive_closure (firsts);
- if (trace_flag)
+ if (trace_flag & trace_sets)
bitsetv_matrix_dump (stderr, "RTC: Firsts Output", firsts);
- if (trace_flag)
+ if (trace_flag & trace_sets)
print_firsts ();
}
symbol_number_t i, j;
rule_number_t k;
- fderives = bitsetv_create (nvars, nrules + 1, BITSET_FIXED);
+ fderives = bitsetv_create (nvars, nrules, BITSET_FIXED);
set_firsts ();
for (i = ntokens; i < nsyms; ++i)
for (j = ntokens; j < nsyms; ++j)
if (bitset_test (FIRSTS (i), j - ntokens))
- for (k = 0; derives[j][k] > 0; ++k)
- bitset_set (FDERIVES (i), derives[j][k]);
+ for (k = 0; derives[j][k]; ++k)
+ bitset_set (FDERIVES (i), derives[j][k]->number);
- if (trace_flag)
+ if (trace_flag & trace_sets)
print_fderives ();
bitsetv_free (firsts);
{
itemset = XCALLOC (item_number_t, n);
- ruleset = bitset_create (nrules + 1, BITSET_FIXED);
+ ruleset = bitset_create (nrules, BITSET_FIXED);
set_fderives ();
}
bitset_iterator iter;
- if (trace_flag)
+ if (trace_flag & trace_sets)
print_closure ("input", core, n);
bitset_zero (ruleset);
c++;
}
- if (trace_flag)
+ if (trace_flag & trace_sets)
print_closure ("output", itemset, nritemset);
}