X-Git-Url: https://git.saurik.com/bison.git/blobdiff_plain/4b3d3a8e4629cc3b0a6d011d80e1997f8306c304..c0cac722f7e5d7498528a67a37477cdf9ed1745c:/src/nullable.c diff --git a/src/nullable.c b/src/nullable.c index 6a70fa57..c0b60f64 100644 --- a/src/nullable.c +++ b/src/nullable.c @@ -30,14 +30,14 @@ #include "reduce.h" #include "nullable.h" -/* Linked list of rule numbers. */ +/* Linked list of rules. */ typedef struct rule_list_s { struct rule_list_s *next; - rule_number_t value; + rule_t *value; } rule_list_t; -char *nullable = NULL; +bool *nullable = NULL; static void nullable_print (FILE *out) @@ -50,7 +50,7 @@ nullable_print (FILE *out) } void -set_nullable (void) +nullable_compute (void) { rule_number_t ruleno; symbol_number_t *s1; @@ -66,10 +66,7 @@ set_nullable (void) Supposedly NRITEMS - NRULES is enough. But why take the risk? */ rule_list_t *relts = XCALLOC (rule_list_t, nritems + nvars + 1); - if (trace_flag) - fprintf (stderr, "Entering set_nullable\n"); - - nullable = XCALLOC (char, nvars) - ntokens; + nullable = XCALLOC (bool, nvars) - ntokens; s1 = s2 = squeue; p = relts; @@ -94,7 +91,7 @@ set_nullable (void) { rcount[ruleno]++; p->next = rsets[*r]; - p->value = ruleno; + p->value = rule; rsets[*r] = p; p++; } @@ -114,12 +111,12 @@ set_nullable (void) while (s1 < s2) for (p = rsets[*s1++]; p; p = p->next) { - ruleno = p->value; - if (--rcount[ruleno] == 0) - if (rules[ruleno].useful && !nullable[rules[ruleno].lhs->number]) + rule_t *rule = p->value; + if (--rcount[rule->number] == 0) + if (rule->useful && !nullable[rule->lhs->number]) { - nullable[rules[ruleno].lhs->number] = 1; - *s2++ = rules[ruleno].lhs->number; + nullable[rule->lhs->number] = 1; + *s2++ = rule->lhs->number; } } @@ -128,13 +125,13 @@ set_nullable (void) XFREE (rsets + ntokens); XFREE (relts); - if (trace_flag) + if (trace_flag & trace_sets) nullable_print (stderr); } void -free_nullable (void) +nullable_free (void) { XFREE (nullable + ntokens); }