]> git.saurik.com Git - bison.git/commitdiff
* src/gram.h (rprec, rprecsym, rassoc): Remove, now part of...
authorAkim Demaille <akim@epita.fr>
Mon, 19 Nov 2001 09:12:49 +0000 (09:12 +0000)
committerAkim Demaille <akim@epita.fr>
Mon, 19 Nov 2001 09:12:49 +0000 (09:12 +0000)
(rule_t): this.
* src/conflicts.c, src/reader.c, src/reduce.c: Adjust.

ChangeLog
src/conflicts.c
src/gram.h
src/reader.c
src/reduce.c

index 3a37f08125c2feaeccbb309139707c9551439d6e..4b2e6d9e639b11926e620102c1fee6ad4d958e76 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2001-11-19  Akim Demaille  <akim@epita.fr>
+
+       * src/gram.h (rprec, rprecsym, rassoc): Remove, now part of...
+       (rule_t): this.
+       * src/conflicts.c, src/reader.c, src/reduce.c: Adjust.
+
 2001-11-19  Akim Demaille  <akim@epita.fr>
 
        * src/gram.h (rule_t): New.
 2001-11-19  Akim Demaille  <akim@epita.fr>
 
        * src/gram.h (rule_t): New.
index 73df3b64d2edf091b700a0c7532e812f5051b98a..fd7af88c189516af907a3551196aa686de76ec8b 100644 (file)
@@ -94,7 +94,7 @@ resolve_sr_conflict (int state, int lookaheadnum)
   short *errtokens = errp->errs;
 
   /* find the rule to reduce by to get precedence of reduction  */
   short *errtokens = errp->errs;
 
   /* find the rule to reduce by to get precedence of reduction  */
-  redprec = rprec[LAruleno[lookaheadnum]];
+  redprec = rule_table[LAruleno[lookaheadnum]].prec;
 
   mask = 1;
   fp1 = LA (lookaheadnum);
 
   mask = 1;
   fp1 = LA (lookaheadnum);
@@ -217,7 +217,7 @@ set_conflicts (int state)
      check for shift-reduce conflict, and try to resolve using
      precedence */
   for (i = state_table[state].lookaheads; i < k; i++)
      check for shift-reduce conflict, and try to resolve using
      precedence */
   for (i = state_table[state].lookaheads; i < k; i++)
-    if (rprec[LAruleno[i]])
+    if (rule_table[LAruleno[i]].prec)
       {
        fp1 = LA (i);
        fp2 = fp1;
       {
        fp1 = LA (i);
        fp2 = fp1;
index 66031cc38e67220f55ad241d7c82088208170e02..c12698b6fe5ae321c2b1db098c12f69329b1268a 100644 (file)
    RULE_TABLE[R].rhs -- the index in RITEM of the beginning of the
    portion for rule R.
 
    RULE_TABLE[R].rhs -- the index in RITEM of the beginning of the
    portion for rule R.
 
+   RULE_TABLE[R].prec -- the precedence level of R.
+
+   RULE_TABLE[R].precsym -- the symbol-number of the symbol in %prec
+   for R (if any).
+
+   RULE_TABLE[R].assoc -- the associativity of the rule.
+
    The right hand side is stored as symbol numbers in a portion of
    RITEM.
 
    The right hand side is stored as symbol numbers in a portion of
    RITEM.
 
    Item numbers are used in the finite state machine to represent
    places that parsing can get to.
 
    Item numbers are used in the finite state machine to represent
    places that parsing can get to.
 
-   Precedence levels are recorded in the vectors sprec and rprec.
-   sprec records the precedence level of each symbol, rprec the
-   precedence level of each rule.  rprecsym is the symbol-number of
-   the symbol in %prec for this rule (if any).
+   SPREC records the precedence level of each symbol.
 
    Precedence levels are assigned in increasing order starting with 1
    so that numerically higher precedence values mean tighter binding
 
    Precedence levels are assigned in increasing order starting with 1
    so that numerically higher precedence values mean tighter binding
@@ -91,23 +95,12 @@ extern int nvars;
 
 extern short *ritem;
 
 
 extern short *ritem;
 
-extern short *rprec;
-extern short *rprecsym;
 extern short *sprec;
 extern short *sprec;
-extern short *rassoc;
 extern short *sassoc;
 extern short *rline;           /* Source line number of each rule */
 
 extern int start_symbol;
 
 extern short *sassoc;
 extern short *rline;           /* Source line number of each rule */
 
 extern int start_symbol;
 
-typedef struct rule_s
-{
-  short lhs;
-  short rhs;
-} rule_t;
-
-extern struct rule_s *rule_table;
-
 /* associativity values in elements of rassoc, sassoc.  */
 typedef enum
 {
 /* associativity values in elements of rassoc, sassoc.  */
 typedef enum
 {
@@ -117,6 +110,17 @@ typedef enum
 } associativity;
 
 
 } associativity;
 
 
+typedef struct rule_s
+{
+  short lhs;
+  short rhs;
+  short prec;
+  short precsym;
+  short assoc;
+} rule_t;
+
+extern struct rule_s *rule_table;
+
 /* token translation table: indexed by a token number as returned by
    the user's yylex routine, it yields the internal token number used
    by the parser and throughout bison.  */
 /* token translation table: indexed by a token number as returned by
    the user's yylex routine, it yields the internal token number used
    by the parser and throughout bison.  */
index 829baf8dea477b6efe01ff8141a22a43ff8950c2..7ba1b55fdb47c7bce5c8438f6a9378599c2d5524 100644 (file)
@@ -1875,9 +1875,6 @@ packgram (void)
 
   ritem = XCALLOC (short, nitems + 1);
   rule_table = XCALLOC (rule_t, nrules) - 1;
 
   ritem = XCALLOC (short, nitems + 1);
   rule_table = XCALLOC (rule_t, nrules) - 1;
-  rprec = XCALLOC (short, nrules) - 1;
-  rprecsym = XCALLOC (short, nrules) - 1;
-  rassoc = XCALLOC (short, nrules) - 1;
 
   itemno = 0;
   ruleno = 1;
 
   itemno = 0;
   ruleno = 1;
@@ -1897,8 +1894,8 @@ packgram (void)
             of the last token in it.  */
          if (p->sym->class == token_sym)
            {
             of the last token in it.  */
          if (p->sym->class == token_sym)
            {
-             rprec[ruleno] = p->sym->prec;
-             rassoc[ruleno] = p->sym->assoc;
+             rule_table[ruleno].prec = p->sym->prec;
+             rule_table[ruleno].assoc = p->sym->assoc;
            }
          if (p)
            p = p->next;
            }
          if (p)
            p = p->next;
@@ -1908,9 +1905,9 @@ packgram (void)
          the specified symbol's precedence replaces the default.  */
       if (ruleprec)
        {
          the specified symbol's precedence replaces the default.  */
       if (ruleprec)
        {
-         rprec[ruleno] = ruleprec->prec;
-         rassoc[ruleno] = ruleprec->assoc;
-         rprecsym[ruleno] = ruleprec->value;
+         rule_table[ruleno].prec = ruleprec->prec;
+         rule_table[ruleno].assoc = ruleprec->assoc;
+         rule_table[ruleno].precsym = ruleprec->value;
        }
 
       ritem[itemno++] = -ruleno;
        }
 
       ritem[itemno++] = -ruleno;
index 71448410cf8962c714e225b2cbc252ed55803991..1e65eee009910df1d04ad56a201b331b7d5a609b 100644 (file)
@@ -255,8 +255,8 @@ end_iteration:
 
   /* A token that was used in %prec should not be warned about.  */
   for (i = 1; i < nrules; i++)
 
   /* A token that was used in %prec should not be warned about.  */
   for (i = 1; i < nrules; i++)
-    if (rprecsym[i] != 0)
-      SETBIT (V1, rprecsym[i]);
+    if (rule_table[i].precsym != 0)
+      SETBIT (V1, rule_table[i].precsym);
 }
 
 static void
 }
 
 static void
@@ -281,8 +281,8 @@ reduce_grammar_tables (void)
                {
                  rule_table[np].lhs = rule_table[pn].lhs;
                  rline[np] = rline[pn];
                {
                  rule_table[np].lhs = rule_table[pn].lhs;
                  rline[np] = rline[pn];
-                 rprec[np] = rprec[pn];
-                 rassoc[np] = rassoc[pn];
+                 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)
                    {
                  rule_table[np].rhs = rule_table[pn].rhs;
                  if (rule_table[np].rhs != ni)
                    {
@@ -370,9 +370,9 @@ reduce_grammar_tables (void)
          /* Ignore the rules disabled above.  */
          if (rule_table[i].lhs >= 0)
            rule_table[i].lhs = nontermmap[rule_table[i].lhs];
          /* Ignore the rules disabled above.  */
          if (rule_table[i].lhs >= 0)
            rule_table[i].lhs = nontermmap[rule_table[i].lhs];
-         if (ISVAR (rprecsym[i]))
+         if (ISVAR (rule_table[i].precsym))
            /* Can this happen?  */
            /* Can this happen?  */
-           rprecsym[i] = nontermmap[rprecsym[i]];
+           rule_table[i].precsym = nontermmap[rule_table[i].precsym];
        }
 
       for (r = ritem; *r; r++)
        }
 
       for (r = ritem; *r; r++)
@@ -464,7 +464,11 @@ dump_grammar (FILE *out)
   for (i = 1; i <= nrules; i++)
     {
       fprintf (out, "%-5d(%5d%5d)%5d : (@%-5d)",
   for (i = 1; i <= nrules; i++)
     {
       fprintf (out, "%-5d(%5d%5d)%5d : (@%-5d)",
-              i, rprec[i], rassoc[i], rule_table[i].lhs, rule_table[i].rhs);
+              i,
+              rule_table[i].prec,
+              rule_table[i].assoc,
+              rule_table[i].lhs,
+              rule_table[i].rhs);
       for (r = &ritem[rule_table[i].rhs]; *r > 0; r++)
        fprintf (out, "%5d", *r);
       fprintf (out, " [%d]\n", -(*r));
       for (r = &ritem[rule_table[i].rhs]; *r > 0; r++)
        fprintf (out, "%5d", *r);
       fprintf (out, " [%d]\n", -(*r));