394 |
} |
} |
395 |
} |
} |
396 |
|
|
|
/* Find the rules which are reduced. */ |
|
|
if (!glr_parser) |
|
|
{ |
|
|
for (i = 0; i < ntokens; i++) |
|
|
if (actrow[i] < 0 && actrow[i] != ACTION_MIN) |
|
|
rules[item_number_as_rule_number (actrow[i])].useful = TRUE; |
|
|
if (default_rule) |
|
|
default_rule->useful = TRUE; |
|
|
} |
|
|
|
|
397 |
/* If have no default rule, the default is an error. |
/* If have no default rule, the default is an error. |
398 |
So replace any action which says "error" with "use default". */ |
So replace any action which says "error" with "use default". */ |
399 |
|
|
467 |
token_actions (void) |
token_actions (void) |
468 |
{ |
{ |
469 |
state_number_t i; |
state_number_t i; |
470 |
|
symbol_number_t j; |
471 |
rule_number_t r; |
rule_number_t r; |
472 |
|
|
473 |
int nconflict = conflicts_total_count (); |
int nconflict = conflicts_total_count (); |
474 |
|
|
475 |
yydefact = XCALLOC (rule_number_t, nstates); |
yydefact = XCALLOC (rule_number_t, nstates); |
477 |
actrow = XCALLOC (action_t, ntokens); |
actrow = XCALLOC (action_t, ntokens); |
478 |
conflrow = XCALLOC (unsigned int, ntokens); |
conflrow = XCALLOC (unsigned int, ntokens); |
479 |
|
|
480 |
/* Now that the parser was computed, we can find which rules are |
/* Find the rules which are reduced. */ |
|
really reduced, and which are not because of SR or RR conflicts. |
|
|
*/ |
|
481 |
if (!glr_parser) |
if (!glr_parser) |
482 |
for (r = 0; r < nrules; ++r) |
for (r = 0; r < nrules; ++r) |
483 |
rules[r].useful = FALSE; |
rules[r].useful = FALSE; |
496 |
rule_t *default_rule = action_row (states[i]); |
rule_t *default_rule = action_row (states[i]); |
497 |
yydefact[i] = default_rule ? default_rule->number + 1 : 0; |
yydefact[i] = default_rule ? default_rule->number + 1 : 0; |
498 |
save_row (i); |
save_row (i); |
|
} |
|
499 |
|
|
500 |
if (!glr_parser) |
/* Now that the parser was computed, we can find which rules are |
501 |
for (r = 0; r < nrules ; ++r) |
really reduced, and which are not because of SR or RR |
502 |
if (!rules[r].useful) |
conflicts. */ |
503 |
|
if (!glr_parser) |
504 |
{ |
{ |
505 |
LOCATION_PRINT (stderr, rules[r].location); |
for (j = 0; j < ntokens; ++j) |
506 |
fprintf (stderr, ": %s: %s: ", |
if (actrow[j] < 0 && actrow[j] != ACTION_MIN) |
507 |
_("warning"), _("rule never reduced because of conflicts")); |
rules[item_number_as_rule_number (actrow[j])].useful = TRUE; |
508 |
rule_print (&rules[r], stderr); |
if (yydefact[i]) |
509 |
|
rules[yydefact[i] - 1].useful = TRUE; |
510 |
} |
} |
511 |
|
} |
512 |
|
|
513 |
free (actrow); |
free (actrow); |
514 |
free (conflrow); |
free (conflrow); |