static int nuseful_nonterminals;
int nuseless_nonterminals;
\f
-static int
-bits_size (bitset S)
-{
- int i, count = 0;
-
- BITSET_EXECUTE (S, 0, i, { ++count; });
- return count;
-}
-\f
/*-------------------------------------------------------------------.
| Another way to do this would be with a set for each production and |
| then do subset tests against N0, but even for the C grammar the |
in the set of useful nonterminals. */
for (r = &ritem[rules[i].rhs]; *r >= 0; r++)
- if (ISVAR (n = *r))
- if (!bitset_test (N0, n - ntokens))
- return FALSE;
+ if (ISVAR (n = *r) && !bitset_test (N0, n - ntokens))
+ return FALSE;
return TRUE;
}
set of all productions which have a RHS all in N. */
Np = bitset_create (nvars, BITSET_FIXED);
- bitset_zero (Np);
/* The set being computed is a set of nonterminals which can derive
user can know. */
Vp = bitset_create (nsyms, BITSET_FIXED);
- bitset_zero (Vp);
Pp = bitset_create (nrules + 1, BITSET_FIXED);
- bitset_zero (Pp);
/* If the start symbol isn't useful, then nothing will be useful. */
if (bitset_test (N, start_symbol - ntokens))
bitset_free (P);
P = Pp;
- nuseful_productions = bits_size (P);
+ nuseful_productions = bitset_count (P);
nuseless_productions = nrules - nuseful_productions;
nuseful_nonterminals = 0;
/* Allocate the global sets used to compute the reduced grammar */
N = bitset_create (nvars, BITSET_FIXED);
- bitset_zero (N);
P = bitset_create (nrules + 1, BITSET_FIXED);
- bitset_zero (P);
V = bitset_create (nsyms, BITSET_FIXED);
- bitset_zero (V);
V1 = bitset_create (nsyms, BITSET_FIXED);
- bitset_zero (V1);
useless_nonterminals ();
inaccessable_symbols ();