]> git.saurik.com Git - bison.git/commitdiff
* src/lalr.c (maxrhs): Move to...
authorAkim Demaille <akim@epita.fr>
Wed, 5 Dec 2001 09:29:02 +0000 (09:29 +0000)
committerAkim Demaille <akim@epita.fr>
Wed, 5 Dec 2001 09:29:02 +0000 (09:29 +0000)
* src/gram.c, src/gram.h (ritem_longest_rhs): here.
* src/lalr.c (build_relations): Adjust.

ChangeLog
src/gram.c
src/gram.h
src/lalr.c

index 954f35e0967c1bc013b65c4d386e49fb4221ede1..b3143352686147cc96539347b37860b8c8034842 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2001-12-05  Akim Demaille  <akim@epita.fr>
+
+       * src/lalr.c (maxrhs): Move to...
+       * src/gram.c, src/gram.h (ritem_longest_rhs): here.
+       * src/lalr.c (build_relations): Adjust.
+
 2001-12-05  Akim Demaille  <akim@epita.fr>
 
        * src/lalr.c (transpose): Free the memory allocated to the
index 35302616ace92a925b46d4bc0cd2c4c44409e31f..c45c84a02daad609800f96cadab3955adaf52a79 100644 (file)
@@ -53,6 +53,11 @@ int pure_parser;
 
 int error_token_number;
 
+
+/*------------------------.
+| Dump RITEM for traces.  |
+`------------------------*/
+
 void
 ritem_print (FILE *out)
 {
@@ -65,3 +70,32 @@ ritem_print (FILE *out)
       fprintf (out, "  (rule %d)\n", -ritem[i]);
   fputs ("\n\n", out);
 }
+
+
+/*------------------------------------------.
+| Return the size of the longest rule RHS.  |
+`------------------------------------------*/
+
+size_t
+ritem_longest_rhs (void)
+{
+  short *itemp;
+  int length;
+  int max;
+
+  length = 0;
+  max = 0;
+  for (itemp = ritem; *itemp; itemp++)
+    if (*itemp > 0)
+      {
+       length++;
+      }
+    else
+      {
+       if (length > max)
+         max = length;
+       length = 0;
+      }
+
+  return max;
+}
index 516907c225878e2daee5f008c786e5184bbf0cfb..e26582fe145017ca187b2c1d07591fc254f69af7 100644 (file)
@@ -150,5 +150,9 @@ extern int error_token_number;
 
 
 /* Dump RITEM for traces. */
-void ritem_print (FILE *out);
+void ritem_print PARAMS ((FILE *out));
+
+/* Return the size of the longest rule RHS.  */
+size_t ritem_longest_rhs PARAMS ((void));
+
 #endif /* !GRAM_H_ */
index ad2623d6295e01bc5bc615b05150e5b5a855b0b0..674a121a86ea482fdcf65906e22bbe44fb7f35e0 100644 (file)
@@ -194,37 +194,6 @@ set_state_table (void)
 }
 
 
-/*------------------------------------------.
-| Return the size of the longest rule RHS.  |
-`------------------------------------------*/
-
-static size_t
-maxrhs (void)
-{
-  short *itemp;
-  int length;
-  int max;
-
-  length = 0;
-  max = 0;
-  for (itemp = ritem; *itemp; itemp++)
-    {
-      if (*itemp > 0)
-       {
-         length++;
-       }
-      else
-       {
-         if (length > max)
-           max = length;
-         length = 0;
-       }
-    }
-
-  return max;
-}
-
-
 static void
 initialize_LA (void)
 {
@@ -497,7 +466,7 @@ static void
 build_relations (void)
 {
   short *edge = XCALLOC (short, ngotos + 1);
-  short *states = XCALLOC (short, maxrhs () + 1);
+  short *states = XCALLOC (short, ritem_longest_rhs () + 1);
   int i;
 
   includes = XCALLOC (short *, ngotos);