294 |
static void |
static void |
295 |
prepare_rules (void) |
prepare_rules (void) |
296 |
{ |
{ |
297 |
int r; |
rule_number_t r; |
298 |
unsigned int i = 0; |
unsigned int i = 0; |
299 |
item_number_t *rhs = XMALLOC (item_number_t, nritems); |
item_number_t *rhs = XMALLOC (item_number_t, nritems); |
300 |
unsigned int *prhs = XMALLOC (unsigned int, nrules + 1); |
unsigned int *prhs = XMALLOC (unsigned int, nrules + 1); |
306 |
|
|
307 |
for (r = 1; r < nrules + 1; ++r) |
for (r = 1; r < nrules + 1; ++r) |
308 |
{ |
{ |
309 |
item_number_t *rhsp; |
item_number_t *rhsp = NULL; |
310 |
/* Index of rule R in RHS. */ |
/* Index of rule R in RHS. */ |
311 |
prhs[r] = i; |
prhs[r] = i; |
312 |
/* RHS of the rule R. */ |
/* RHS of the rule R. */ |
428 |
action_row (state_t *state) |
action_row (state_t *state) |
429 |
{ |
{ |
430 |
int i; |
int i; |
431 |
int default_rule = 0; |
rule_number_t default_rule = 0; |
432 |
reductions_t *redp = state->reductions; |
reductions_t *redp = state->reductions; |
433 |
shifts_t *shiftp = state->shifts; |
shifts_t *shiftp = state->shifts; |
434 |
errs_t *errp = state->errs; |
errs_t *errp = state->errs; |
504 |
for (i = 0; i < state->nlookaheads; i++) |
for (i = 0; i < state->nlookaheads; i++) |
505 |
{ |
{ |
506 |
int count = 0; |
int count = 0; |
507 |
int rule = -state->lookaheads_rule[i]->number; |
rule_number_t rule = -state->lookaheads_rule[i]->number; |
508 |
int j; |
symbol_number_t j; |
509 |
|
|
510 |
for (j = 0; j < ntokens; j++) |
for (j = 0; j < ntokens; j++) |
511 |
if (actrow[j] == rule) |
if (actrow[j] == rule) |
638 |
void |
void |
639 |
actions_output (FILE *out) |
actions_output (FILE *out) |
640 |
{ |
{ |
641 |
int rule; |
rule_number_t r; |
642 |
|
|
643 |
fputs ("m4_define([b4_actions], \n[[", out); |
fputs ("m4_define([b4_actions], \n[[", out); |
644 |
for (rule = 1; rule < nrules + 1; ++rule) |
for (r = 1; r < nrules + 1; ++r) |
645 |
if (rules[rule].action) |
if (rules[r].action) |
646 |
{ |
{ |
647 |
fprintf (out, " case %d:\n", rule); |
fprintf (out, " case %d:\n", r); |
648 |
|
|
649 |
if (!no_lines_flag) |
if (!no_lines_flag) |
650 |
fprintf (out, muscle_find ("linef"), |
fprintf (out, muscle_find ("linef"), |
651 |
rules[rule].action_location.first_line, |
rules[r].action_location.first_line, |
652 |
quotearg_style (c_quoting_style, |
quotearg_style (c_quoting_style, |
653 |
muscle_find ("filename"))); |
muscle_find ("filename"))); |
654 |
fprintf (out, " %s\n break;\n\n", |
fprintf (out, " %s\n break;\n\n", |
655 |
rules[rule].action); |
rules[r].action); |
656 |
} |
} |
657 |
fputs ("]])\n\n", out); |
fputs ("]])\n\n", out); |
658 |
} |
} |