mirror of
https://git.savannah.gnu.org/git/bison.git
synced 2026-03-14 06:43:03 +00:00
* src/lalr.c (maxrhs): Move to...
* src/gram.c, src/gram.h (ritem_longest_rhs): here. * src/lalr.c (build_relations): Adjust.
This commit is contained in:
34
src/gram.c
34
src/gram.c
@@ -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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user