323 |
`------------------------------------------------------------------*/ |
`------------------------------------------------------------------*/ |
324 |
|
|
325 |
static int |
static int |
326 |
action_row (int state) |
action_row (state_t *state) |
327 |
{ |
{ |
328 |
int i; |
int i; |
|
int m = 0; |
|
|
int n = 0; |
|
329 |
int default_rule = 0; |
int default_rule = 0; |
330 |
reductions *redp = state_table[state]->reductions; |
reductions *redp = state->reductions; |
331 |
int nreds = redp ? redp->nreds : 0; |
int nreds = redp ? redp->nreds : 0; |
332 |
shifts *shiftp = state_table[state]->shifts; |
shifts *shiftp = state->shifts; |
333 |
errs *errp = state_table[state]->errs; |
errs *errp = state->errs; |
334 |
/* set nonzero to inhibit having any default reduction */ |
/* set nonzero to inhibit having any default reduction */ |
335 |
int nodefault = 0; |
int nodefault = 0; |
336 |
|
|
342 |
int j; |
int j; |
343 |
/* loop over all the rules available here which require |
/* loop over all the rules available here which require |
344 |
lookahead */ |
lookahead */ |
345 |
m = state_table[state]->lookaheadsp; |
for (i = state->nlookaheads - 1; i >= 0; --i) |
|
n = state_table[state + 1]->lookaheadsp; |
|
|
|
|
|
for (i = n - 1; i >= m; i--) |
|
346 |
/* and find each token which the rule finds acceptable |
/* and find each token which the rule finds acceptable |
347 |
to come next */ |
to come next */ |
348 |
for (j = 0; j < ntokens; j++) |
for (j = 0; j < ntokens; j++) |
349 |
/* and record this rule as the rule to use if that |
/* and record this rule as the rule to use if that |
350 |
token follows. */ |
token follows. */ |
351 |
if (BITISSET (LA (i), j)) |
if (BITISSET (LA (state->lookaheadsp + i), j)) |
352 |
actrow[j] = -LAruleno[i]; |
actrow[j] = -LAruleno[state->lookaheadsp + i]; |
353 |
} |
} |
354 |
|
|
355 |
/* Now see which tokens are allowed for shifts in this state. For |
/* Now see which tokens are allowed for shifts in this state. For |
389 |
|
|
390 |
if (nreds >= 1 && !nodefault) |
if (nreds >= 1 && !nodefault) |
391 |
{ |
{ |
392 |
if (state_table[state]->consistent) |
if (state->consistent) |
393 |
default_rule = redp->rules[0]; |
default_rule = redp->rules[0]; |
394 |
else |
else |
395 |
{ |
{ |
396 |
int max = 0; |
int max = 0; |
397 |
for (i = m; i < n; i++) |
for (i = 0; i < state->nlookaheads; i++) |
398 |
{ |
{ |
399 |
int count = 0; |
int count = 0; |
400 |
int rule = -LAruleno[i]; |
int rule = -LAruleno[state->lookaheadsp + i]; |
401 |
int j; |
int j; |
402 |
|
|
403 |
for (j = 0; j < ntokens; j++) |
for (j = 0; j < ntokens; j++) |
487 |
actrow = XCALLOC (short, ntokens); |
actrow = XCALLOC (short, ntokens); |
488 |
for (i = 0; i < nstates; ++i) |
for (i = 0; i < nstates; ++i) |
489 |
{ |
{ |
490 |
yydefact[i] = action_row (i); |
yydefact[i] = action_row (state_table[i]); |
491 |
save_row (i); |
save_row (i); |
492 |
} |
} |
493 |
|
|