1 |
/* Allocate input grammar variables for bison, |
/* Allocate input grammar variables for bison, |
2 |
Copyright 1984, 1986, 1989, 2001 Free Software Foundation, Inc. |
Copyright 1984, 1986, 1989, 2001, 2002 Free Software Foundation, Inc. |
3 |
|
|
4 |
This file is part of Bison, the GNU Compiler Compiler. |
This file is part of Bison, the GNU Compiler Compiler. |
5 |
|
|
51 |
int error_token_number; |
int error_token_number; |
52 |
|
|
53 |
|
|
54 |
|
/*--------------------------------------. |
55 |
|
| Return the number of symbols in RHS. | |
56 |
|
`--------------------------------------*/ |
57 |
|
|
58 |
|
int |
59 |
|
rule_rhs_length (rule_t *rule) |
60 |
|
{ |
61 |
|
int res = 0; |
62 |
|
short *rhsp; |
63 |
|
for (rhsp = rule->rhs; *rhsp >= 0; ++rhsp) |
64 |
|
++res; |
65 |
|
return res; |
66 |
|
} |
67 |
|
|
68 |
|
|
69 |
/*------------------------. |
/*------------------------. |
70 |
| Dump RITEM for traces. | |
| Dump RITEM for traces. | |
71 |
`------------------------*/ |
`------------------------*/ |
91 |
size_t |
size_t |
92 |
ritem_longest_rhs (void) |
ritem_longest_rhs (void) |
93 |
{ |
{ |
94 |
int length; |
int max = 0; |
|
int max; |
|
95 |
int i; |
int i; |
96 |
|
|
97 |
length = 0; |
for (i = 1; i < nrules + 1; ++i) |
98 |
max = 0; |
{ |
99 |
for (i = 0; i < nritems; ++i) |
int length = rule_rhs_length (&rules[i]); |
100 |
if (ritem[i] >= 0) |
if (length > max) |
101 |
{ |
max = length; |
102 |
length++; |
} |
|
} |
|
|
else |
|
|
{ |
|
|
if (length > max) |
|
|
max = length; |
|
|
length = 0; |
|
|
} |
|
103 |
|
|
104 |
return max; |
return max; |
105 |
} |
} |