GOTO_NUMBER_MAXIMUM, since we occasionally compute
ngotos + 1 without checking for overflow.
(build_relations): Use END_NODE, not -1, to denote end of edges.
(set_goto_map, map_goto, initialize_F, add_loopback_edge,
build_relations): Use goto_number, not int, for goto numbers.
for (i = sp->num - 1; i >= 0 && TRANSITION_IS_GOTO (sp, i); --i)
{
ngotos++;
for (i = sp->num - 1; i >= 0 && TRANSITION_IS_GOTO (sp, i); --i)
{
ngotos++;
+
+ /* Abort if (ngotos + 1) would overflow. */
+ if (ngotos == GOTO_NUMBER_MAXIMUM)
goto_map[TRANSITION_SYMBOL (sp, i) - ntokens]++;
}
}
{
goto_map[TRANSITION_SYMBOL (sp, i) - ntokens]++;
}
}
{
int i;
for (i = ntokens; i < nsyms; i++)
{
int i;
for (i = ntokens; i < nsyms; i++)
{
int i;
for (i = sp->num - 1; i >= 0 && TRANSITION_IS_GOTO (sp, i); --i)
{
int i;
for (i = sp->num - 1; i >= 0 && TRANSITION_IS_GOTO (sp, i); --i)
{
- int k = temp_map[TRANSITION_SYMBOL (sp, i) - ntokens]++;
+ goto_number k = temp_map[TRANSITION_SYMBOL (sp, i) - ntokens]++;
from_state[k] = s;
to_state[k] = sp->states[i]->number;
}
from_state[k] = s;
to_state[k] = sp->states[i]->number;
}
| Map a state/symbol pair into its numeric representation. |
`----------------------------------------------------------*/
| Map a state/symbol pair into its numeric representation. |
`----------------------------------------------------------*/
map_goto (state_number s0, symbol_number sym)
{
map_goto (state_number s0, symbol_number sym)
{
- int high;
- int low;
- int middle;
+ goto_number high;
+ goto_number low;
+ goto_number middle;
state_number s;
low = goto_map[sym - ntokens];
state_number s;
low = goto_map[sym - ntokens];
{
goto_number **reads = CALLOC (reads, ngotos);
goto_number *edge = CALLOC (edge, ngotos + 1);
{
goto_number **reads = CALLOC (reads, ngotos);
goto_number *edge = CALLOC (edge, ngotos + 1);
+ goto_number nedges = 0;
F = bitsetv_create (ngotos, ntokens, BITSET_FIXED);
F = bitsetv_create (ngotos, ntokens, BITSET_FIXED);
{
CALLOC (reads[i], nedges + 1);
memcpy (reads[i], edge, nedges * sizeof (edge[0]));
{
CALLOC (reads[i], nedges + 1);
memcpy (reads[i], edge, nedges * sizeof (edge[0]));
+ reads[i][nedges] = END_NODE;
-add_lookback_edge (state *s, rule *r, int gotono)
+add_lookback_edge (state *s, rule *r, goto_number gotono)
{
int ri = state_reduction_find (s, r);
goto_list *sp = MALLOC (sp, 1);
{
int ri = state_reduction_find (s, r);
goto_list *sp = MALLOC (sp, 1);
{
goto_number *edge = CALLOC (edge, ngotos + 1);
state_number *states1 = CALLOC (states1, ritem_longest_rhs () + 1);
{
goto_number *edge = CALLOC (edge, ngotos + 1);
state_number *states1 = CALLOC (states1, ritem_longest_rhs () + 1);
CALLOC (includes, ngotos);
CALLOC (includes, ngotos);
CALLOC (includes[i], nedges + 1);
for (j = 0; j < nedges; j++)
includes[i][j] = edge[j];
CALLOC (includes[i], nedges + 1);
for (j = 0; j < nedges; j++)
includes[i][j] = edge[j];
- includes[i][nedges] = -1;
+ includes[i][nedges] = END_NODE;
static void
compute_FOLLOWS (void)
{
static void
compute_FOLLOWS (void)
{
relation_digraph (includes, ngotos, &F);
relation_digraph (includes, ngotos, &F);