* 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 (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
int error_token_number;
+
+/*------------------------.
+| Dump RITEM for traces. |
+`------------------------*/
+
void
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;
+}
/* 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_ */
}
-/*------------------------------------------.
-| 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)
{
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);