X-Git-Url: https://git.saurik.com/bison.git/blobdiff_plain/720e5c1bc36411c1a0591a525a897f47cfd17987..80a697503460fcf0d52bed9fb3b86e4c276fb37e:/src/derives.c diff --git a/src/derives.c b/src/derives.c index f0c41165..ab7cc326 100644 --- a/src/derives.c +++ b/src/derives.c @@ -19,11 +19,6 @@ Boston, MA 02111-1307, USA. */ -/* set_derives finds, for each variable (nonterminal), which rules can - derive it. It sets up the value of derives so that derives[i - - ntokens] points to a vector of rule numbers, terminated with -1. - */ - #include "system.h" #include "getargs.h" #include "types.h" @@ -31,8 +26,7 @@ #include "gram.h" #include "derives.h" -short **derives; - +short **derives = NULL; static void print_derives (void) @@ -51,7 +45,7 @@ print_derives (void) fprintf (stderr, "\t\t%d:", *sp); for (rhsp = ritem + rule_table[*sp].rhs; *rhsp > 0; ++rhsp) fprintf (stderr, " %s", tags[*rhsp]); - fputc ('\n', stderr); + fprintf (stderr, " (rule %d)\n", -*rhsp); } } @@ -63,7 +57,6 @@ void set_derives (void) { int i; - int lhs; shorts *p; short *q; shorts **dset; @@ -74,16 +67,14 @@ set_derives (void) p = delts; for (i = nrules; i > 0; i--) - { - lhs = rule_table[i].lhs; - if (lhs >= 0) - { - p->next = dset[lhs]; - p->value = i; - dset[lhs] = p; - p++; - } - } + if (rule_table[i].useful) + { + int lhs = rule_table[i].lhs; + p->next = dset[lhs]; + p->value = i; + dset[lhs] = p; + p++; + } derives = XCALLOC (short *, nvars) - ntokens; q = XCALLOC (short, nvars + nrules);