avoid null-reference if some nonterminal is not defined

This commit is contained in:
ceriel 1989-03-06 18:48:30 +00:00
parent bf62834959
commit d97abb0763

View file

@ -35,7 +35,6 @@ STATIC reachwalk();
co_reach() { co_reach() {
/* /*
* Check for undefined or unreachable nonterminals. * Check for undefined or unreachable nonterminals.
* An undefined nonterminal is a fatal error!
*/ */
register p_nont p; register p_nont p;
register p_start st; register p_start st;
@ -50,6 +49,7 @@ co_reach() {
p->n_name); p->n_name);
} }
} }
/* /*
* Walk the grammar rules, starting with the startsymbols * Walk the grammar rules, starting with the startsymbols
* Mark the nonterminals that are encountered with the flag * Mark the nonterminals that are encountered with the flag
@ -106,7 +106,7 @@ reachwalk(p) register p_gram p; {
register p_nont n = &nonterms[g_getcont(p)]; register p_nont n = &nonterms[g_getcont(p)];
reachable(n); reachable(n);
if (g_gettype(n->n_rule) == EORULE && if (p->n_rule && g_gettype(n->n_rule) == EORULE &&
! g_getnpar(p) && (getntparams(n) == 0)) { ! g_getnpar(p) && (getntparams(n) == 0)) {
register p_gram np = p; register p_gram np = p;
do { do {