* src/lalr.c (add_lookback_edge): Use state_t instead of ints.

(build_relations): Adjust.
This commit is contained in:
Akim Demaille
2001-12-27 18:07:17 +00:00
parent d0b0fefa03
commit dac3c91005
2 changed files with 21 additions and 17 deletions

View File

@@ -1,3 +1,9 @@
2001-12-27 Akim Demaille <akim@epita.fr>
* src/lalr.c (add_lookback_edge): Use state_t instead of ints.
(build_relations): Adjust.
2001-12-27 Akim Demaille <akim@epita.fr> 2001-12-27 Akim Demaille <akim@epita.fr>
* src/lalr.c (set_goto_map): Remove a wrong but benign loop * src/lalr.c (set_goto_map): Remove a wrong but benign loop

View File

@@ -301,21 +301,21 @@ initialize_F (void)
static void static void
add_lookback_edge (int stateno, int ruleno, int gotono) add_lookback_edge (state_t *state, int ruleno, int gotono)
{ {
int i; int i;
shorts *sp; shorts *sp;
for (i = 0; i < state_table[stateno]->nlookaheads; ++i) for (i = 0; i < state->nlookaheads; ++i)
if (LAruleno[state_table[stateno]->lookaheadsp + i] == ruleno) if (LAruleno[state->lookaheadsp + i] == ruleno)
break; break;
assert (LAruleno[state_table[stateno]->lookaheadsp + i] == ruleno); assert (LAruleno[state->lookaheadsp + i] == ruleno);
sp = XCALLOC (shorts, 1); sp = XCALLOC (shorts, 1);
sp->next = lookback[state_table[stateno]->lookaheadsp + i]; sp->next = lookback[state->lookaheadsp + i];
sp->value = gotono; sp->value = gotono;
lookback[state_table[stateno]->lookaheadsp + i] = sp; lookback[state->lookaheadsp + i] = sp;
} }
@@ -417,7 +417,6 @@ build_relations (void)
for (i = 0; i < ngotos; i++) for (i = 0; i < ngotos; i++)
{ {
int nedges = 0; int nedges = 0;
int state1 = from_state[i];
int symbol1 = state_table[to_state[i]]->accessing_symbol; int symbol1 = state_table[to_state[i]]->accessing_symbol;
short *rulep; short *rulep;
@@ -425,26 +424,26 @@ build_relations (void)
{ {
int done; int done;
int length = 1; int length = 1;
int stateno = state1;
short *rp; short *rp;
states[0] = state1; state_t *state = state_table[from_state[i]];
states[0] = state->number;
for (rp = ritem + rule_table[*rulep].rhs; *rp > 0; rp++) for (rp = ritem + rule_table[*rulep].rhs; *rp > 0; rp++)
{ {
shifts *sp = state_table[stateno]->shifts; shifts *sp = state->shifts;
int j; int j;
for (j = 0; j < sp->nshifts; j++) for (j = 0; j < sp->nshifts; j++)
{ {
stateno = sp->shifts[j]; state = state_table[sp->shifts[j]];
if (state_table[stateno]->accessing_symbol == *rp) if (state->accessing_symbol == *rp)
break; break;
} }
states[length++] = stateno; states[length++] = state->number;
} }
if (!state_table[stateno]->consistent) if (!state->consistent)
add_lookback_edge (stateno, *rulep, i); add_lookback_edge (state, *rulep, i);
length--; length--;
done = 0; done = 0;
@@ -455,8 +454,7 @@ build_relations (void)
/* JF added rp>=ritem && I hope to god its right! */ /* JF added rp>=ritem && I hope to god its right! */
if (rp >= ritem && ISVAR (*rp)) if (rp >= ritem && ISVAR (*rp))
{ {
stateno = states[--length]; edge[nedges++] = map_goto (states[--length], *rp);
edge[nedges++] = map_goto (stateno, *rp);
if (nullable[*rp]) if (nullable[*rp])
done = 0; done = 0;
} }