/[bison]/bison/src/reduce.c
ViewVC logotype

Diff of /bison/src/reduce.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.19.2.3 by akim, Mon Nov 12 09:15:57 2001 UTC revision 1.19.2.4 by akim, Mon Nov 19 09:12:25 2001 UTC
# Line 100  useful_production (int i, BSet N0) Line 100  useful_production (int i, BSet N0)
100    /* A production is useful if all of the nonterminals in its appear    /* A production is useful if all of the nonterminals in its appear
101       in the set of useful nonterminals.  */       in the set of useful nonterminals.  */
102    
103    for (r = &ritem[rrhs[i]]; *r > 0; r++)    for (r = &ritem[rule_table[i].rhs]; *r > 0; r++)
104      if (ISVAR (n = *r))      if (ISVAR (n = *r))
105        if (!BITISSET (N0, n - ntokens))        if (!BITISSET (N0, n - ntokens))
106          return FALSE;          return FALSE;
# Line 149  useless_nonterminals (void) Line 149  useless_nonterminals (void)
149              {              {
150                if (useful_production (i, N))                if (useful_production (i, N))
151                  {                  {
152                    SETBIT (Np, rlhs[i] - ntokens);                    SETBIT (Np, rule_table[i].lhs - ntokens);
153                    SETBIT (P, i);                    SETBIT (P, i);
154                  }                  }
155              }              }
# Line 211  inaccessable_symbols (void) Line 211  inaccessable_symbols (void)
211          Vp[i] = V[i];          Vp[i] = V[i];
212        for (i = 1; i <= nrules; i++)        for (i = 1; i <= nrules; i++)
213          {          {
214            if (!BITISSET (Pp, i) && BITISSET (P, i) && BITISSET (V, rlhs[i]))            if (!BITISSET (Pp, i) && BITISSET (P, i) && BITISSET (V, rule_table[i].lhs))
215              {              {
216                for (r = &ritem[rrhs[i]]; *r >= 0; r++)                for (r = &ritem[rule_table[i].rhs]; *r >= 0; r++)
217                  {                  {
218                    if (ISTOKEN (t = *r) || BITISSET (N, t - ntokens))                    if (ISTOKEN (t = *r) || BITISSET (N, t - ntokens))
219                      {                      {
# Line 279  reduce_grammar_tables (void) Line 279  reduce_grammar_tables (void)
279                np++;                np++;
280                if (pn != np)                if (pn != np)
281                  {                  {
282                    rlhs[np] = rlhs[pn];                    rule_table[np].lhs = rule_table[pn].lhs;
283                    rline[np] = rline[pn];                    rline[np] = rline[pn];
284                    rprec[np] = rprec[pn];                    rprec[np] = rprec[pn];
285                    rassoc[np] = rassoc[pn];                    rassoc[np] = rassoc[pn];
286                    rrhs[np] = rrhs[pn];                    rule_table[np].rhs = rule_table[pn].rhs;
287                    if (rrhs[np] != ni)                    if (rule_table[np].rhs != ni)
288                      {                      {
289                        pi = rrhs[np];                        pi = rule_table[np].rhs;
290                        rrhs[np] = ni;                        rule_table[np].rhs = ni;
291                        while (ritem[pi] >= 0)                        while (ritem[pi] >= 0)
292                          ritem[ni++] = ritem[pi++];                          ritem[ni++] = ritem[pi++];
293                        ritem[ni++] = -np;                        ritem[ni++] = -np;
# Line 319  reduce_grammar_tables (void) Line 319  reduce_grammar_tables (void)
319          {          {
320            if (!BITISSET (P, pn))            if (!BITISSET (P, pn))
321              {              {
322                rlhs[pn] = -1;                rule_table[pn].lhs = -1;
323              }              }
324          }          }
325      }      }
# Line 368  reduce_grammar_tables (void) Line 368  reduce_grammar_tables (void)
368        for (i = 1; i <= nrules; i++)        for (i = 1; i <= nrules; i++)
369          {          {
370            /* Ignore the rules disabled above.  */            /* Ignore the rules disabled above.  */
371            if (rlhs[i] >= 0)            if (rule_table[i].lhs >= 0)
372              rlhs[i] = nontermmap[rlhs[i]];              rule_table[i].lhs = nontermmap[rule_table[i].lhs];
373            if (ISVAR (rprecsym[i]))            if (ISVAR (rprecsym[i]))
374              /* Can this happen?  */              /* Can this happen?  */
375              rprecsym[i] = nontermmap[rprecsym[i]];              rprecsym[i] = nontermmap[rprecsym[i]];
# Line 434  reduce_output (FILE *out) Line 434  reduce_output (FILE *out)
434            if (!BITISSET (P, i))            if (!BITISSET (P, i))
435              {              {
436                fprintf (out, "#%-4d  ", i);                fprintf (out, "#%-4d  ", i);
437                fprintf (out, "%s :\t", tags[rlhs[i]]);                fprintf (out, "%s :\t", tags[rule_table[i].lhs]);
438                for (r = &ritem[rrhs[i]]; *r >= 0; r++)                for (r = &ritem[rule_table[i].rhs]; *r >= 0; r++)
439                  fprintf (out, " %s", tags[*r]);                  fprintf (out, " %s", tags[*r]);
440                fprintf (out, ";\n");                fprintf (out, ";\n");
441              }              }
# Line 464  dump_grammar (FILE *out) Line 464  dump_grammar (FILE *out)
464    for (i = 1; i <= nrules; i++)    for (i = 1; i <= nrules; i++)
465      {      {
466        fprintf (out, "%-5d(%5d%5d)%5d : (@%-5d)",        fprintf (out, "%-5d(%5d%5d)%5d : (@%-5d)",
467                 i, rprec[i], rassoc[i], rlhs[i], rrhs[i]);                 i, rprec[i], rassoc[i], rule_table[i].lhs, rule_table[i].rhs);
468        for (r = &ritem[rrhs[i]]; *r > 0; r++)        for (r = &ritem[rule_table[i].rhs]; *r > 0; r++)
469          fprintf (out, "%5d", *r);          fprintf (out, "%5d", *r);
470        fprintf (out, " [%d]\n", -(*r));        fprintf (out, " [%d]\n", -(*r));
471      }      }
# Line 473  dump_grammar (FILE *out) Line 473  dump_grammar (FILE *out)
473    fprintf (out, _("Rules interpreted\n-----------------\n\n"));    fprintf (out, _("Rules interpreted\n-----------------\n\n"));
474    for (i = 1; i <= nrules; i++)    for (i = 1; i <= nrules; i++)
475      {      {
476        fprintf (out, "%-5d  %s :", i, tags[rlhs[i]]);        fprintf (out, "%-5d  %s :", i, tags[rule_table[i].lhs]);
477        for (r = &ritem[rrhs[i]]; *r > 0; r++)        for (r = &ritem[rule_table[i].rhs]; *r > 0; r++)
478          fprintf (out, " %s", tags[*r]);          fprintf (out, " %s", tags[*r]);
479        fputc ('\n', out);        fputc ('\n', out);
480      }      }

Legend:
Removed from v.1.19.2.3  
changed lines
  Added in v.1.19.2.4

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26