]> git.saurik.com Git - bison.git/commitdiff
* src/symtab.h, src/symtab.c: `line' is a new member of `bucket'.
authorAkim Demaille <akim@epita.fr>
Mon, 19 Nov 2001 10:26:16 +0000 (10:26 +0000)
committerAkim Demaille <akim@epita.fr>
Mon, 19 Nov 2001 10:26:16 +0000 (10:26 +0000)
* src/reader.c (record_rule_lines, rline, rline_allocated): Remove.
* src/output.c: Adjust.

ChangeLog
src/gram.h
src/output.c
src/reader.c
src/symtab.c
src/symtab.h

index c8fe7aed3265832baa89cad0f1ab2942d2f47872..d19050aadd5a42ba18157d3f9552859204479c3b 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2001-11-19  Akim Demaille  <akim@epita.fr>
+
+       * src/symtab.h, src/symtab.c: `line' is a new member of `bucket'.
+       * src/reader.c (record_rule_lines, rline, rline_allocated): Remove.
+       * src/output.c: Adjust.
+
+       
 2001-11-19  Akim Demaille  <akim@epita.fr>
 
        * src/gram.h (rprec, rprecsym, rassoc): Remove, now part of...
index c12698b6fe5ae321c2b1db098c12f69329b1268a..531d1d9aa3a1ea72f2dcfb0089dfaff143be0c5e 100644 (file)
@@ -55,7 +55,9 @@
    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.
+   RULE_TABLE[R].assoc -- the associativity of R.
+
+   RULE_TABLE[R].line -- the line where R was defined.
 
    The right hand side is stored as symbol numbers in a portion of
    RITEM.
@@ -97,7 +99,6 @@ extern short *ritem;
 
 extern short *sprec;
 extern short *sassoc;
-extern short *rline;           /* Source line number of each rule */
 
 extern int start_symbol;
 
@@ -117,6 +118,7 @@ typedef struct rule_s
   short prec;
   short precsym;
   short assoc;
+  short line;
 } rule_t;
 
 extern struct rule_s *rule_table;
index dabcba1592f563bdc8196e48c57b30732d30c778..87ab880e1365e8d26032a6d1fa49248b34e68bfe 100644 (file)
@@ -225,9 +225,16 @@ output_rule_data (void)
   int j;
   short *short_tab = NULL;
 
-  output_table_data (&output_obstack, rline,
-                    0, 1, nrules + 1);
-  muscle_insert ("rline", obstack_finish (&output_obstack));
+  {
+    short *values = XCALLOC (short, nrules + 1);
+    for (i = 0; i < nrules + 1; ++i)
+      values[i] = rule_table[i].line;
+    output_table_data (&output_obstack, values,
+                      0, 1, nrules + 1);
+    muscle_insert ("rline", obstack_finish (&output_obstack));
+    XFREE (values);
+  }
+
 
   j = 0;
   for (i = 0; i < nsyms; i++)
index b7795deeb527bc3e27945c877c004d4bf9d32c6f..5abb46edaeb3b7f3fb8bcf819766edc3b1164fe8 100644 (file)
@@ -1251,20 +1251,6 @@ copy_guard (symbol_list *rule, int stack_offset)
 }
 \f
 
-static void
-record_rule_line (void)
-{
-  /* Record each rule's source line number in rline table.  */
-
-  if (nrules >= rline_allocated)
-    {
-      rline_allocated = nrules * 2;
-      rline = XREALLOC (rline, short, rline_allocated);
-    }
-  rline[nrules] = lineno;
-}
-
-
 /*-------------------------------------------------------------------.
 | Generate a dummy symbol, a nonterminal, whose name cannot conflict |
 | with the user's names.                                             |
@@ -1407,8 +1393,6 @@ readgram (void)
          nrules++;
          nitems++;
 
-         record_rule_line ();
-
          p = XCALLOC (symbol_list, 1);
          p->sym = lhs;
 
@@ -1486,7 +1470,6 @@ readgram (void)
                     just read can belong to it.  */
                  nrules++;
                  nitems++;
-                 record_rule_line ();
                  p = XCALLOC (symbol_list, 1);
                  if (crule1)
                    crule1->next = p;
@@ -1494,9 +1477,10 @@ readgram (void)
                    grammar = p;
                  p->sym = sdummy;
                  crule1 = XCALLOC (symbol_list, 1);
-                 p->next = crule1;
                  crule1->next = crule;
 
+                 p->next = crule1;
+
                  /* Insert the dummy generated by that rule into this
                     rule.  */
                  nitems++;
@@ -1932,6 +1916,7 @@ packgram (void)
     {
       rule_table[ruleno].lhs = p->sym->value;
       rule_table[ruleno].rhs = itemno;
+      rule_table[ruleno].line = p->sym->line;
       ruleprec = p->ruleprec;
 
       p = p->next;
@@ -1986,8 +1971,6 @@ reader (void)
   nvars = 0;
   nrules = 0;
   nitems = 0;
-  rline_allocated = 10;
-  rline = XCALLOC (short, rline_allocated);
 
   typed = 0;
   lastprec = 0;
index 455e74e2310ec00727a8f68034e406d3f7fd17a9..c701ccd673b6479f9ff8533305bcdc5db1a0e9c8 100644 (file)
@@ -49,6 +49,9 @@ hash (const char *key)
 static bucket *
 bucket_new (const char *tag, int hashval)
 {
+  /* Hack, until we have a Bison parser. */
+  extern int lineno;
+
   bucket *res = XMALLOC (bucket, 1);
 
   res->link = symtab[hashval];
@@ -61,6 +64,7 @@ bucket_new (const char *tag, int hashval)
   res->user_token_number = SUNDEF;
   res->alias = NULL;
   res->class = unknown_sym;
+  res->line = lineno;
 
   nsyms++;
 
index b98902e14015b1e210cd307b99fc0f24aaaab010..4ebc4a1afea4f1fee3b9b142533164a8bdb156d0 100644 (file)
@@ -42,6 +42,9 @@ typedef struct bucket
   struct bucket *link;
   struct bucket *next;
 
+  /* The line it was found in. */
+  short line;
+
   /* The key, name of the symbol. */
   char *tag;
   /* Its type. */