[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
09-fyi-ritem-max-rhs.patch
From: |
Akim Demaille |
Subject: |
09-fyi-ritem-max-rhs.patch |
Date: |
Wed, 05 Dec 2001 08:24:47 +0100 |
Index: ChangeLog
from Akim Demaille <address@hidden>
* src/lalr.c (maxrhs): Move to...
* src/gram.c, src/gram.h (ritem_longest_rhs): here.
* src/lalr.c (build_relations): Adjust.
Index: src/gram.c
--- src/gram.c Sat, 01 Dec 2001 12:41:03 +0100 akim
+++ src/gram.c Sat, 01 Dec 2001 14:47:13 +0100 akim
@@ -53,6 +53,11 @@
int error_token_number;
+
+/*------------------------.
+| Dump RITEM for traces. |
+`------------------------*/
+
void
ritem_print (FILE *out)
{
@@ -64,4 +69,33 @@
else
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: src/gram.h
--- src/gram.h Sat, 01 Dec 2001 12:41:03 +0100 akim
+++ src/gram.h Sat, 01 Dec 2001 14:46:31 +0100 akim
@@ -150,5 +150,9 @@
/* 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: src/lalr.c
--- src/lalr.c Sat, 01 Dec 2001 14:43:15 +0100 akim
+++ src/lalr.c Sat, 01 Dec 2001 14:46:44 +0100 akim
@@ -194,37 +194,6 @@
}
-/*------------------------------------------.
-| 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 @@
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);