+ short *nontermmap = XCALLOC (short, nvars) - ntokens;
+ n = ntokens;
+ for (i = ntokens; i < nsyms; i++)
+ if (BITISSET (V, i))
+ nontermmap[i] = n++;
+ for (i = ntokens; i < nsyms; i++)
+ if (!BITISSET (V, i))
+ nontermmap[i] = n++;
+
+
+ /* Shuffle elements of tables indexed by symbol number. */
+ {
+ short *sassoc_sorted = XMALLOC (short, nvars) - ntokens;
+ short *sprec_sorted = XMALLOC (short, nvars) - ntokens;
+ char **tags_sorted = XMALLOC (char *, nvars) - ntokens;
+
+ for (i = ntokens; i < nsyms; i++)
+ {
+ n = nontermmap[i];
+ sassoc_sorted[n] = sassoc[i];
+ sprec_sorted[n] = sprec[i];
+ tags_sorted[n] = tags[i];
+ }
+ for (i = ntokens; i < nsyms; i++)
+ {
+ sassoc[i] = sassoc_sorted[i];
+ sprec[i] = sprec_sorted[i];
+ tags[i] = tags_sorted[i];
+ }
+ free (sassoc_sorted + ntokens);
+ free (sprec_sorted + ntokens);
+ free (tags_sorted + ntokens);
+ }
+
+ /* Replace all symbol numbers in valid data structures. */