void
set_nullable (void)
{
- int ruleno;
- short *s1;
- short *s2;
+ rule_number_t ruleno;
+ symbol_number_t *s1;
+ symbol_number_t *s2;
shorts *p;
- short *squeue = XCALLOC (short, nvars);
+ symbol_number_t *squeue = XCALLOC (symbol_number_t, nvars);
short *rcount = XCALLOC (short, nrules + 1);
/* RITEM contains all the rules, including useless productions.
Hence we must allocate room for useless nonterminals too. */
p = relts;
for (ruleno = 1; ruleno < nrules + 1; ++ruleno)
- if (rule_table[ruleno].useful)
+ if (rules[ruleno].useful)
{
- if (ritem[rule_table[ruleno].rhs] >= 0)
+ rule_t *rule = &rules[ruleno];
+ if (rule->rhs[0] >= 0)
{
/* This rule has a non empty RHS. */
- short *r;
+ item_number_t *r = NULL;
int any_tokens = 0;
- for (r = &ritem[rule_table[ruleno].rhs]; *r >= 0; ++r)
+ for (r = rule->rhs; *r >= 0; ++r)
if (ISTOKEN (*r))
any_tokens = 1;
/* This rule has only nonterminals: schedule it for the second
pass. */
if (!any_tokens)
- for (r = &ritem[rule_table[ruleno].rhs]; *r >= 0; ++r)
+ for (r = rule->rhs; *r >= 0; ++r)
{
rcount[ruleno]++;
p->next = rsets[*r];
else
{
/* This rule has an empty RHS. */
- assert (ritem[rule_table[ruleno].rhs] == -ruleno);
- if (rule_table[ruleno].useful && !nullable[rule_table[ruleno].lhs])
+ assert (rule_number_of_item_number (rule->rhs[0]) == ruleno);
+ if (rule->useful && !nullable[rule->lhs->number])
{
- nullable[rule_table[ruleno].lhs] = 1;
- *s2++ = rule_table[ruleno].lhs;
+ nullable[rule->lhs->number] = 1;
+ *s2++ = rule->lhs->number;
}
}
}
{
ruleno = p->value;
if (--rcount[ruleno] == 0)
- if (rule_table[ruleno].useful && !nullable[rule_table[ruleno].lhs])
+ if (rules[ruleno].useful && !nullable[rules[ruleno].lhs->number])
{
- nullable[rule_table[ruleno].lhs] = 1;
- *s2++ = rule_table[ruleno].lhs;
+ nullable[rules[ruleno].lhs->number] = 1;
+ *s2++ = rules[ruleno].lhs->number;
}
}