bison-patches
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

17-fyi-rules.patch


From: Akim Demaille
Subject: 17-fyi-rules.patch
Date: Sat, 29 Dec 2001 15:14:38 +0100

Index: ChangeLog
from  Akim Demaille  <address@hidden>
        * src/closure.c, src/conflicts.c, src/derives.c, src/gram.c
        * src/gram.h, src/lalr.c, src/nullable.c, src/output.c, src/print.c
        * src/print_graph.c, src/reader.c, src/reduce.c: Rename rule_table
        as rules.
        
        
Index: src/closure.c
--- src/closure.c Fri, 28 Dec 2001 16:30:23 +0100 akim
+++ src/closure.c Fri, 28 Dec 2001 16:40:05 +0100 akim
@@ -103,7 +103,7 @@
          {
            short *rhsp;
            fprintf (stderr, "\t\t%d:", j - 1);
-           for (rhsp = &ritem[rule_table[j].rhs]; *rhsp >= 0; ++rhsp)
+           for (rhsp = &ritem[rules[j].rhs]; *rhsp >= 0; ++rhsp)
              fprintf (stderr, " %s", symbols[*rhsp]->tag);
            fputc ('\n', stderr);
          }
@@ -133,7 +133,7 @@
   for (i = ntokens; i < nsyms; i++)
     for (j = 0; derives[i][j] >= 0; ++j)
       {
-       int symbol = ritem[rule_table[derives[i][j]].rhs];
+       int symbol = ritem[rules[derives[i][j]].rhs];
        if (ISVAR (symbol))
          SETBIT (FIRSTS (i), symbol - ntokens);
       }
@@ -225,7 +225,7 @@
   for (ruleno = 0; ruleno < nrules + 1; ++ruleno)
     if (BITISSET (ruleset, ruleno))
       {
-       int itemno = rule_table[ruleno].rhs;
+       int itemno = rules[ruleno].rhs;
        while (c < n && core[c] < itemno)
          {
            itemset[nitemset] = core[c];
Index: src/conflicts.c
--- src/conflicts.c Fri, 28 Dec 2001 16:33:19 +0100 akim
+++ src/conflicts.c Fri, 28 Dec 2001 16:40:05 +0100 akim
@@ -94,7 +94,7 @@
 {
   int i;
   /* find the rule to reduce by to get precedence of reduction  */
-  int redprec = rule_table[LAruleno[lookahead]].prec;
+  int redprec = rules[LAruleno[lookahead]].prec;
   errs *errp = errs_new (ntokens + 1);
   errp->nerrs = 0;
 
@@ -172,7 +172,7 @@
      check for shift-reduce conflict, and try to resolve using
      precedence */
   for (i = 0; i < state->nlookaheads; ++i)
-    if (rule_table[LAruleno[state->lookaheadsp + i]].prec)
+    if (rules[LAruleno[state->lookaheadsp + i]].prec)
       for (j = 0; j < tokensetsize; ++j)
        if (LA (state->lookaheadsp + i)[j] & lookaheadset[j])
          {
Index: src/derives.c
--- src/derives.c Fri, 28 Dec 2001 16:30:23 +0100 akim
+++ src/derives.c Fri, 28 Dec 2001 16:40:05 +0100 akim
@@ -44,7 +44,7 @@
        {
          short *rhsp;
          fprintf (stderr, "\t\t%d:", *sp);
-         for (rhsp = &ritem[rule_table[*sp].rhs]; *rhsp >= 0; ++rhsp)
+         for (rhsp = &ritem[rules[*sp].rhs]; *rhsp >= 0; ++rhsp)
            fprintf (stderr, " %s", symbols[*rhsp]->tag);
          fprintf (stderr, " (rule %d)\n", -*rhsp - 1);
        }
@@ -68,9 +68,9 @@
 
   p = delts;
   for (i = nrules; i > 0; i--)
-    if (rule_table[i].useful)
+    if (rules[i].useful)
       {
-       int lhs = rule_table[i].lhs;
+       int lhs = rules[i].lhs;
        p->next = dset[lhs];
        p->value = i;
        dset[lhs] = p;
Index: src/gram.c
--- src/gram.c Fri, 28 Dec 2001 16:38:48 +0100 akim
+++ src/gram.c Fri, 28 Dec 2001 16:40:05 +0100 akim
@@ -35,7 +35,7 @@
 short *ritem = NULL;
 int nritems;
 
-rule_t *rule_table = NULL;
+rule_t *rules = NULL;
 
 struct bucket **symbols = NULL;
 short *token_translations = NULL;
Index: src/gram.h
--- src/gram.h Fri, 28 Dec 2001 16:33:19 +0100 akim
+++ src/gram.h Fri, 28 Dec 2001 16:40:05 +0100 akim
@@ -39,27 +39,27 @@
    written.  Actions and guards are accessed via the rule number.
 
    The rules themselves are described by several arrays: amongst which
-   RITEM, and RULE_TABLE.
+   RITEM, and RULES.
 
-   RULE_TABLE is an array of struct rule_s, which members are:
+   RULES is an array of struct rule_s, which members are:
 
-   RULE_TABLE[R].lhs -- the symbol number of the left hand side of
+   RULES[R].lhs -- the symbol number of the left hand side of
    rule R.  If -1, the rule has been thrown out by reduce.c and should
    be ignored.
 
-   RULE_TABLE[R].rhs -- the index in RITEM of the beginning of the
+   RULES[R].rhs -- the index in RITEM of the beginning of the
    portion for rule R.
 
-   RULE_TABLE[R].prec -- the precedence level of R.
+   RULES[R].prec -- the precedence level of R.
 
-   RULE_TABLE[R].precsym -- the symbol-number of the symbol in %prec
+   RULES[R].precsym -- the symbol-number of the symbol in %prec
    for R (if any).
 
-   RULE_TABLE[R].assoc -- the associativity of R.
+   RULES[R].assoc -- the associativity of R.
 
-   RULE_TABLE[R].line -- the line where R was defined.
+   RULES[R].line -- the line where R was defined.
 
-   RULE_TABLE[R].useful -- TRUE iff the rule is used.
+   RULES[R].useful -- TRUE iff the rule is used.
 
    The right hand side is stored as symbol numbers in a portion of
    RITEM.
@@ -128,7 +128,7 @@
   short guard_line;
 } rule_t;
 
-extern struct rule_s *rule_table;
+extern struct rule_s *rules;
 
 /* Table of the symbols, indexed by the symbol number. */
 extern struct bucket **symbols;
Index: src/lalr.c
--- src/lalr.c Fri, 28 Dec 2001 16:30:23 +0100 akim
+++ src/lalr.c Fri, 28 Dec 2001 16:40:05 +0100 akim
@@ -420,7 +420,7 @@
          state_t *state = state_table[from_state[i]];
          states[0] = state->number;
 
-         for (rp = &ritem[rule_table[*rulep].rhs]; *rp >= 0; rp++)
+         for (rp = &ritem[rules[*rulep].rhs]; *rp >= 0; rp++)
            {
              shifts *sp = state->shifts;
              int j;
Index: src/nullable.c
--- src/nullable.c Fri, 28 Dec 2001 16:30:23 +0100 akim
+++ src/nullable.c Fri, 28 Dec 2001 16:40:05 +0100 akim
@@ -69,21 +69,21 @@
   p = relts;
 
   for (ruleno = 1; ruleno < nrules + 1; ++ruleno)
-    if (rule_table[ruleno].useful)
+    if (rules[ruleno].useful)
       {
-       if (ritem[rule_table[ruleno].rhs] >= 0)
+       if (ritem[rules[ruleno].rhs] >= 0)
          {
            /* This rule has a non empty RHS. */
            short *r;
            int any_tokens = 0;
-           for (r = &ritem[rule_table[ruleno].rhs]; *r >= 0; ++r)
+           for (r = &ritem[rules[ruleno].rhs]; *r >= 0; ++r)
              if (ISTOKEN (*r))
                any_tokens = 1;
 
            /* This rule has only nonterminals: schedule it for the second
               pass.  */
            if (!any_tokens)
-             for (r = &ritem[rule_table[ruleno].rhs]; *r >= 0; ++r)
+             for (r = &ritem[rules[ruleno].rhs]; *r >= 0; ++r)
                {
                  rcount[ruleno]++;
                  p->next = rsets[*r];
@@ -95,11 +95,11 @@
        else
          {
            /* This rule has an empty RHS. */
-           assert (ritem[rule_table[ruleno].rhs] == -ruleno);
-           if (rule_table[ruleno].useful && !nullable[rule_table[ruleno].lhs])
+           assert (ritem[rules[ruleno].rhs] == -ruleno);
+           if (rules[ruleno].useful && !nullable[rules[ruleno].lhs])
              {
-               nullable[rule_table[ruleno].lhs] = 1;
-               *s2++ = rule_table[ruleno].lhs;
+               nullable[rules[ruleno].lhs] = 1;
+               *s2++ = rules[ruleno].lhs;
              }
          }
       }
@@ -109,10 +109,10 @@
       {
        ruleno = p->value;
        if (--rcount[ruleno] == 0)
-         if (rule_table[ruleno].useful && !nullable[rule_table[ruleno].lhs])
+         if (rules[ruleno].useful && !nullable[rules[ruleno].lhs])
            {
-             nullable[rule_table[ruleno].lhs] = 1;
-             *s2++ = rule_table[ruleno].lhs;
+             nullable[rules[ruleno].lhs] = 1;
+             *s2++ = rules[ruleno].lhs;
            }
       }
 
Index: src/output.c
--- src/output.c Fri, 28 Dec 2001 16:37:20 +0100 akim
+++ src/output.c Fri, 28 Dec 2001 16:40:05 +0100 akim
@@ -185,7 +185,7 @@
     int i;
     short *values = XCALLOC (short, nrules + 1);
     for (i = 0; i < nrules + 1; ++i)
-      values[i] = rule_table[i].rhs;
+      values[i] = rules[i].rhs;
     output_table_data (&format_obstack, values,
                       0, 1, nrules + 1);
     XFREE (values);
@@ -239,7 +239,7 @@
   {
     short *values = XCALLOC (short, nrules + 1);
     for (i = 0; i < nrules + 1; ++i)
-      values[i] = rule_table[i].line;
+      values[i] = rules[i].line;
     output_table_data (&format_obstack, values,
                       0, 1, nrules + 1);
     muscle_insert ("rline", obstack_finish (&format_obstack));
@@ -291,7 +291,7 @@
   {
     short *values = XCALLOC (short, nrules + 1);
     for (i = 0; i < nrules + 1; ++i)
-      values[i] = rule_table[i].lhs;
+      values[i] = rules[i].lhs;
     output_table_data (&format_obstack, values,
                       0, 1, nrules + 1);
     muscle_insert ("r1", obstack_finish (&format_obstack));
@@ -301,8 +301,8 @@
   /* Output YYR2. */
   short_tab = XMALLOC (short, nrules + 1);
   for (i = 1; i < nrules; i++)
-    short_tab[i] = rule_table[i + 1].rhs - rule_table[i].rhs - 1;
-  short_tab[nrules] =  nritems - rule_table[nrules].rhs - 1;
+    short_tab[i] = rules[i + 1].rhs - rules[i].rhs - 1;
+  short_tab[nrules] =  nritems - rules[nrules].rhs - 1;
   output_table_data (&format_obstack, short_tab,
                     0, 1, nrules + 1);
   muscle_insert ("r2", obstack_finish (&format_obstack));
@@ -508,20 +508,20 @@
 {
   int rule;
   for (rule = 1; rule < nrules + 1; ++rule)
-    if (rule_table[rule].action)
+    if (rules[rule].action)
       {
        fprintf (out, "  case %d:\n", rule);
 
        if (!no_lines_flag)
          fprintf (out, muscle_find ("linef"),
-                  rule_table[rule].action_line,
+                  rules[rule].action_line,
                   quotearg_style (c_quoting_style,
                                   muscle_find ("filename")));
        /* As a Bison extension, add the ending semicolon.  Since some
           Yacc don't do that, help people using bison as a Yacc
           finding their missing semicolons.  */
        fprintf (out, "{ %s%s }\n    break;\n\n",
-                rule_table[rule].action,
+                rules[rule].action,
                 yacc_flag ? ";" : "");
 
        /* We always output 4 '\n' per action.  */
@@ -530,7 +530,7 @@
        if (!no_lines_flag)
          ++*line;
        /* Get the number of lines written by the user.  */
-       *line += get_lines_number (rule_table[rule].action);
+       *line += get_lines_number (rules[rule].action);
       }
 }
 
@@ -544,17 +544,17 @@
 {
   int rule;
   for (rule = 1; rule < nrules + 1; ++rule)
-    if (rule_table[rule].action)
+    if (rules[rule].action)
       {
        fprintf (out, "  case %d:\n", rule);
 
        if (!no_lines_flag)
          fprintf (out, muscle_find ("linef"),
-                  rule_table[rule].guard_line,
+                  rules[rule].guard_line,
                   quotearg_style (c_quoting_style,
                                   muscle_find ("filename")));
        fprintf (out, "{ %s; }\n    break;\n\n",
-                rule_table[rule].guard);
+                rules[rule].guard);
 
        /* We always output 4 '\n' per action.  */
        *line += 4;
@@ -562,7 +562,7 @@
        if (!no_lines_flag)
          ++*line;
        /* Get the number of lines written by the user.  */
-       *line += get_lines_number (rule_table[rule].guard);
+       *line += get_lines_number (rules[rule].guard);
       }
 }
 
@@ -1122,7 +1122,7 @@
   if (defines_flag)
     header_output ();
 
-  free (rule_table + 1);
+  free (rules + 1);
   obstack_free (&muscle_obstack, NULL);
   obstack_free (&format_obstack, NULL);
   obstack_free (&action_obstack, NULL);
Index: src/print.c
--- src/print.c Fri, 28 Dec 2001 16:30:23 +0100 akim
+++ src/print.c Fri, 28 Dec 2001 16:40:05 +0100 akim
@@ -93,9 +93,9 @@
            sp++;
 
          rule = -(*sp);
-         fprintf (out, "    %s  ->  ", escape 
(symbols[rule_table[rule].lhs]->tag));
+         fprintf (out, "    %s  ->  ", escape (symbols[rules[rule].lhs]->tag));
 
-         for (sp = ritem + rule_table[rule].rhs; sp < sp1; sp++)
+         for (sp = ritem + rules[rule].rhs; sp < sp1; sp++)
            fprintf (out, "%s ", escape (symbols[*sp]->tag));
 
          fputc ('.', out);
@@ -188,7 +188,7 @@
   if (state->consistent)
     {
       int rule = redp->rules[0];
-      int symbol = rule_table[rule].lhs;
+      int symbol = rules[rule].lhs;
       fprintf (out, _("    $default\treduce using rule %d (%s)\n\n"),
               rule - 1, escape (symbols[symbol]->tag));
       return;
@@ -223,10 +223,10 @@
        if (BITISSET (lookaheadset, i))
          fprintf (out, _("    %-4s\t[reduce using rule %d (%s)]\n"),
                   escape (symbols[i]->tag), default_rule - 1,
-                  escape2 (symbols[rule_table[default_rule].lhs]->tag));
+                  escape2 (symbols[rules[default_rule].lhs]->tag));
 
       fprintf (out, _("    $default\treduce using rule %d (%s)\n\n"),
-              default_rule - 1, escape 
(symbols[rule_table[default_rule].lhs]->tag));
+              default_rule - 1, escape 
(symbols[rules[default_rule].lhs]->tag));
     }
   else if (state->nlookaheads >= 1)
     {
@@ -282,7 +282,7 @@
                                 _("    %-4s\treduce using rule %d (%s)\n"),
                                 escape (symbols[i]->tag),
                                 LAruleno[state->lookaheadsp + j] - 1,
-                                escape2 
(symbols[rule_table[LAruleno[state->lookaheadsp + j]].lhs]->tag));
+                                escape2 
(symbols[rules[LAruleno[state->lookaheadsp + j]].lhs]->tag));
                      else
                        defaulted = 1;
 
@@ -295,13 +295,13 @@
                                 _("    %-4s\treduce using rule %d (%s)\n"),
                                 escape (symbols[i]->tag),
                                 LAruleno[default_LA] - 1,
-                                escape2 
(symbols[rule_table[LAruleno[default_LA]].lhs]->tag));
+                                escape2 
(symbols[rules[LAruleno[default_LA]].lhs]->tag));
                      defaulted = 0;
                      fprintf (out,
                               _("    %-4s\t[reduce using rule %d (%s)]\n"),
                               escape (symbols[i]->tag),
                               LAruleno[state->lookaheadsp + j] - 1,
-                              escape2 
(symbols[rule_table[LAruleno[state->lookaheadsp + j]].lhs]->tag));
+                              escape2 
(symbols[rules[LAruleno[state->lookaheadsp + j]].lhs]->tag));
                    }
                }
            }
@@ -310,7 +310,7 @@
       if (default_LA >= 0)
        fprintf (out, _("    $default\treduce using rule %d (%s)\n"),
                 default_rule - 1,
-                escape (symbols[rule_table[default_rule].lhs]->tag));
+                escape (symbols[rules[default_rule].lhs]->tag));
     }
 }
 
@@ -374,11 +374,11 @@
   fprintf (out, "  %s\n", _("Number, Line, Rule"));
   for (i = 1; i <= nrules; i++)
     /* Don't print rules disabled in reduce_grammar_tables.  */
-    if (rule_table[i].useful)
+    if (rules[i].useful)
       {
        fprintf (out, _("  %3d %3d %s ->"),
-                i - 1, rule_table[i].line, escape 
(symbols[rule_table[i].lhs]->tag));
-       rule = &ritem[rule_table[i].rhs];
+                i - 1, rules[i].line, escape (symbols[rules[i].lhs]->tag));
+       rule = &ritem[rules[i].rhs];
        if (*rule >= 0)
          while (*rule >= 0)
            fprintf (out, " %s", escape (symbols[*rule++]->tag));
@@ -401,7 +401,7 @@
        sprintf (buffer, " (%d)", i);
 
        for (j = 1; j <= nrules; j++)
-         for (rule = &ritem[rule_table[j].rhs]; *rule >= 0; rule++)
+         for (rule = &ritem[rules[j].rhs]; *rule >= 0; rule++)
            if (*rule == token_translations[i])
              {
                END_TEST (65);
@@ -420,9 +420,9 @@
 
       for (j = 1; j <= nrules; j++)
        {
-         if (rule_table[j].lhs == i)
+         if (rules[j].lhs == i)
            left_count++;
-         for (rule = &ritem[rule_table[j].rhs]; *rule >= 0; rule++)
+         for (rule = &ritem[rules[j].rhs]; *rule >= 0; rule++)
            if (*rule == i)
              {
                right_count++;
@@ -444,7 +444,7 @@
          for (j = 1; j <= nrules; j++)
            {
              END_TEST (65);
-             if (rule_table[j].lhs == i)
+             if (rules[j].lhs == i)
                sprintf (buffer + strlen (buffer), " %d", j - 1);
            }
        }
@@ -457,7 +457,7 @@
          sprintf (buffer + strlen (buffer), _(" on right:"));
          for (j = 1; j <= nrules; j++)
            {
-             for (rule = &ritem[rule_table[j].rhs]; *rule >= 0; rule++)
+             for (rule = &ritem[rules[j].rhs]; *rule >= 0; rule++)
                if (*rule == i)
                  {
                    END_TEST (65);
Index: src/print_graph.c
--- src/print_graph.c Fri, 28 Dec 2001 16:30:23 +0100 akim
+++ src/print_graph.c Fri, 28 Dec 2001 16:40:05 +0100 akim
@@ -78,9 +78,9 @@
       if (i)
        obstack_1grow (node_obstack, '\n');
       obstack_fgrow1 (node_obstack, " %s -> ",
-                     escape (symbols[rule_table[rule].lhs]->tag));
+                     escape (symbols[rules[rule].lhs]->tag));
 
-      for (sp = ritem + rule_table[rule].rhs; sp < sp1; sp++)
+      for (sp = ritem + rules[rule].rhs; sp < sp1; sp++)
        obstack_fgrow1 (node_obstack, "%s ", escape (symbols[*sp]->tag));
 
       obstack_1grow (node_obstack, '.');
Index: src/reader.c
--- src/reader.c Fri, 28 Dec 2001 16:37:20 +0100 akim
+++ src/reader.c Fri, 28 Dec 2001 16:40:05 +0100 akim
@@ -1720,7 +1720,7 @@
     fatal (_("too many items (max %d)"), MAXSHORT);
 
   ritem = XCALLOC (short, nitems + 1);
-  rule_table = XCALLOC (rule_t, nrules) - 1;
+  rules = XCALLOC (rule_t, nrules) - 1;
 
   itemno = 0;
   ruleno = 1;
@@ -1729,14 +1729,14 @@
   while (p)
     {
       bucket *ruleprec = p->ruleprec;
-      rule_table[ruleno].lhs = p->sym->value;
-      rule_table[ruleno].rhs = itemno;
-      rule_table[ruleno].line = p->line;
-      rule_table[ruleno].useful = TRUE;
-      rule_table[ruleno].action = p->action;
-      rule_table[ruleno].action_line = p->action_line;
-      rule_table[ruleno].guard = p->guard;
-      rule_table[ruleno].guard_line = p->guard_line;
+      rules[ruleno].lhs = p->sym->value;
+      rules[ruleno].rhs = itemno;
+      rules[ruleno].line = p->line;
+      rules[ruleno].useful = TRUE;
+      rules[ruleno].action = p->action;
+      rules[ruleno].action_line = p->action_line;
+      rules[ruleno].guard = p->guard;
+      rules[ruleno].guard_line = p->guard_line;
 
       p = p->next;
       while (p && p->sym)
@@ -1746,8 +1746,8 @@
             of the last token in it.  */
          if (p->sym->class == token_sym)
            {
-             rule_table[ruleno].prec = p->sym->prec;
-             rule_table[ruleno].assoc = p->sym->assoc;
+             rules[ruleno].prec = p->sym->prec;
+             rules[ruleno].assoc = p->sym->assoc;
            }
          if (p)
            p = p->next;
@@ -1757,9 +1757,9 @@
          the specified symbol's precedence replaces the default.  */
       if (ruleprec)
        {
-         rule_table[ruleno].prec = ruleprec->prec;
-         rule_table[ruleno].assoc = ruleprec->assoc;
-         rule_table[ruleno].precsym = ruleprec->value;
+         rules[ruleno].prec = ruleprec->prec;
+         rules[ruleno].assoc = ruleprec->assoc;
+         rules[ruleno].precsym = ruleprec->value;
        }
 
       ritem[itemno++] = -ruleno;
Index: src/reduce.c
--- src/reduce.c Fri, 28 Dec 2001 16:24:40 +0100 akim
+++ src/reduce.c Fri, 28 Dec 2001 16:40:05 +0100 akim
@@ -108,7 +108,7 @@
   /* A production is useful if all of the nonterminals in its appear
      in the set of useful nonterminals.  */
 
-  for (r = &ritem[rule_table[i].rhs]; *r >= 0; r++)
+  for (r = &ritem[rules[i].rhs]; *r >= 0; r++)
     if (ISVAR (n = *r))
       if (!BITISSET (N0, n - ntokens))
        return FALSE;
@@ -157,7 +157,7 @@
            {
              if (useful_production (i, N))
                {
-                 SETBIT (Np, rule_table[i].lhs - ntokens);
+                 SETBIT (Np, rules[i].lhs - ntokens);
                  SETBIT (P, i);
                }
            }
@@ -220,9 +220,9 @@
            {
              if (!BITISSET (Pp, i)
                  && BITISSET (P, i)
-                 && BITISSET (V, rule_table[i].lhs))
+                 && BITISSET (V, rules[i].lhs))
                {
-                 for (r = &ritem[rule_table[i].rhs]; *r >= 0; r++)
+                 for (r = &ritem[rules[i].rhs]; *r >= 0; r++)
                    if (ISTOKEN (t = *r) || BITISSET (N, t - ntokens))
                      SETBIT (Vp, t);
                  SETBIT (Pp, i);
@@ -258,8 +258,8 @@
 
   /* A token that was used in %prec should not be warned about.  */
   for (i = 1; i < nrules; i++)
-    if (rule_table[i].precsym != 0)
-      SETBIT (V1, rule_table[i].precsym);
+    if (rules[i].precsym != 0)
+      SETBIT (V1, rules[i].precsym);
 }
 
 static void
@@ -289,15 +289,15 @@
              np++;
              if (pn != np)
                {
-                 rule_table[np].lhs   = rule_table[pn].lhs;
-                 rule_table[np].line  = rule_table[pn].line;
-                 rule_table[np].prec  = rule_table[pn].prec;
-                 rule_table[np].assoc = rule_table[pn].assoc;
-                 rule_table[np].rhs   = rule_table[pn].rhs;
-                 if (rule_table[np].rhs != ni)
+                 rules[np].lhs   = rules[pn].lhs;
+                 rules[np].line  = rules[pn].line;
+                 rules[np].prec  = rules[pn].prec;
+                 rules[np].assoc = rules[pn].assoc;
+                 rules[np].rhs   = rules[pn].rhs;
+                 if (rules[np].rhs != ni)
                    {
-                     pi = rule_table[np].rhs;
-                     rule_table[np].rhs = ni;
+                     pi = rules[np].rhs;
+                     rules[np].rhs = ni;
                      while (ritem[pi] >= 0)
                        ritem[ni++] = ritem[pi++];
                      ritem[ni++] = -np;
@@ -324,7 +324,7 @@
     {
       int pn;
       for (pn = 1; pn <= nrules; pn++)
-       rule_table[pn].useful = BITISSET (P, pn);
+       rules[pn].useful = BITISSET (P, pn);
     }
 }
 
@@ -367,10 +367,10 @@
 
   for (i = 1; i <= nrules; i++)
     {
-      rule_table[i].lhs = nontermmap[rule_table[i].lhs];
-      if (ISVAR (rule_table[i].precsym))
+      rules[i].lhs = nontermmap[rules[i].lhs];
+      if (ISVAR (rules[i].precsym))
        /* Can this happen?  */
-       rule_table[i].precsym = nontermmap[rule_table[i].precsym];
+       rules[i].precsym = nontermmap[rules[i].precsym];
     }
 
   for (i = 0; i < nritems; ++i)
@@ -422,12 +422,12 @@
       int i;
       fprintf (out, "%s\n\n", _("Useless rules:"));
       for (i = 1; i <= nrules; i++)
-       if (!rule_table[i].useful)
+       if (!rules[i].useful)
          {
            rule r;
            fprintf (out, "#%-4d  ", i - 1);
-           fprintf (out, "%s:", symbols[rule_table[i].lhs]->tag);
-           for (r = &ritem[rule_table[i].rhs]; *r >= 0; r++)
+           fprintf (out, "%s:", symbols[rules[i].lhs]->tag);
+           for (r = &ritem[rules[i].rhs]; *r >= 0; r++)
              fprintf (out, " %s", symbols[*r]->tag);
            fputs (";\n", out);
          }
@@ -458,15 +458,15 @@
     {
       int rhs_count = 0;
       /* Find the last RHS index in ritems. */
-      for (r = &ritem[rule_table[i].rhs]; *r >= 0; ++r)
+      for (r = &ritem[rules[i].rhs]; *r >= 0; ++r)
        ++rhs_count;
       fprintf (out, "%3d (%2d, %2d, %2d, %2d-%2d)   %2d ->",
               i - 1,
-              rule_table[i].prec, rule_table[i].assoc, rule_table[i].useful,
-              rule_table[i].rhs, rule_table[i].rhs + rhs_count - 1,
-              rule_table[i].lhs);
+              rules[i].prec, rules[i].assoc, rules[i].useful,
+              rules[i].rhs, rules[i].rhs + rhs_count - 1,
+              rules[i].lhs);
       /* Dumped the RHS. */
-      for (r = &ritem[rule_table[i].rhs]; *r >= 0; r++)
+      for (r = &ritem[rules[i].rhs]; *r >= 0; r++)
        fprintf (out, "%3d", *r);
       fprintf (out, "  [%d]\n", -(*r) - 1);
     }
@@ -474,8 +474,8 @@
   fprintf (out, "Rules interpreted\n-----------------\n\n");
   for (i = 1; i <= nrules; i++)
     {
-      fprintf (out, "%-5d  %s :", i, symbols[rule_table[i].lhs]->tag);
-      for (r = &ritem[rule_table[i].rhs]; *r >= 0; r++)
+      fprintf (out, "%-5d  %s :", i, symbols[rules[i].lhs]->tag);
+      for (r = &ritem[rules[i].rhs]; *r >= 0; r++)
        fprintf (out, " %s", symbols[*r]->tag);
       fputc ('\n', out);
     }



reply via email to

[Prev in Thread] Current Thread [Next in Thread]