159 |
static void |
static void |
160 |
set_goto_map (void) |
set_goto_map (void) |
161 |
{ |
{ |
162 |
int state; |
int state, i; |
|
int i; |
|
|
int symbol; |
|
|
int k; |
|
163 |
short *temp_map; |
short *temp_map; |
|
int state2; |
|
164 |
|
|
165 |
goto_map = XCALLOC (short, nvars + 1) - ntokens; |
goto_map = XCALLOC (short, nvars + 1) - ntokens; |
166 |
temp_map = XCALLOC (short, nvars + 1) - ntokens; |
temp_map = XCALLOC (short, nvars + 1) - ntokens; |
171 |
shifts *sp = state_table[state]->shifts; |
shifts *sp = state_table[state]->shifts; |
172 |
for (i = sp->nshifts - 1; i >= 0 && SHIFT_IS_GOTO (sp, i); --i) |
for (i = sp->nshifts - 1; i >= 0 && SHIFT_IS_GOTO (sp, i); --i) |
173 |
{ |
{ |
174 |
symbol = state_table[sp->shifts[i]]->accessing_symbol; |
int symbol = state_table[sp->shifts[i]]->accessing_symbol; |
175 |
|
|
176 |
if (ngotos == MAXSHORT) |
if (ngotos == MAXSHORT) |
177 |
fatal (_("too many gotos (max %d)"), MAXSHORT); |
fatal (_("too many gotos (max %d)"), MAXSHORT); |
181 |
} |
} |
182 |
} |
} |
183 |
|
|
184 |
k = 0; |
{ |
185 |
for (i = ntokens; i < nsyms; i++) |
int k = 0; |
186 |
{ |
for (i = ntokens; i < nsyms; i++) |
187 |
temp_map[i] = k; |
{ |
188 |
k += goto_map[i]; |
temp_map[i] = k; |
189 |
} |
k += goto_map[i]; |
190 |
|
} |
191 |
for (i = ntokens; i < nsyms; i++) |
|
192 |
goto_map[i] = temp_map[i]; |
for (i = ntokens; i < nsyms; i++) |
193 |
|
goto_map[i] = temp_map[i]; |
194 |
goto_map[nsyms] = ngotos; |
|
195 |
temp_map[nsyms] = ngotos; |
goto_map[nsyms] = ngotos; |
196 |
|
temp_map[nsyms] = ngotos; |
197 |
|
} |
198 |
|
|
199 |
from_state = XCALLOC (short, ngotos); |
from_state = XCALLOC (short, ngotos); |
200 |
to_state = XCALLOC (short, ngotos); |
to_state = XCALLOC (short, ngotos); |
204 |
shifts *sp = state_table[state]->shifts; |
shifts *sp = state_table[state]->shifts; |
205 |
for (i = sp->nshifts - 1; i >= 0 && SHIFT_IS_GOTO (sp, i); --i) |
for (i = sp->nshifts - 1; i >= 0 && SHIFT_IS_GOTO (sp, i); --i) |
206 |
{ |
{ |
207 |
for (i = sp->nshifts - 1; i >= 0 && SHIFT_IS_GOTO (sp, i); --i) |
int state2 = sp->shifts[i]; |
208 |
{ |
int symbol = state_table[state2]->accessing_symbol; |
209 |
state2 = sp->shifts[i]; |
|
210 |
symbol = state_table[state2]->accessing_symbol; |
int k = temp_map[symbol]++; |
211 |
|
from_state[k] = state; |
212 |
k = temp_map[symbol]++; |
to_state[k] = state2; |
|
from_state[k] = state; |
|
|
to_state[k] = state2; |
|
|
} |
|
213 |
} |
} |
214 |
} |
} |
215 |
|
|