378 |
if (! glr_parser) |
if (! glr_parser) |
379 |
return; |
return; |
380 |
|
|
381 |
for (j = 0; j < ntokens; j += 1) |
for (j = 0; j < ntokens; j += 1) |
382 |
if (conflrow[j]) |
if (conflrow[j]) |
383 |
{ |
{ |
384 |
conflrow[j] = conflict_list_cnt; |
conflrow[j] = conflict_list_cnt; |
385 |
|
|
388 |
for (i = 0; i < state->nlookaheads; i += 1) |
for (i = 0; i < state->nlookaheads; i += 1) |
389 |
if (bitset_test (state->lookaheads[i], j) |
if (bitset_test (state->lookaheads[i], j) |
390 |
&& actrow[j] != -state->lookaheads_rule[i]->number) |
&& actrow[j] != -state->lookaheads_rule[i]->number) |
391 |
{ |
{ |
392 |
assert (conflict_list_free > 0); |
assert (conflict_list_free > 0); |
393 |
conflict_list[conflict_list_cnt] |
conflict_list[conflict_list_cnt] |
394 |
= state->lookaheads_rule[i]->number; |
= state->lookaheads_rule[i]->number; |
395 |
conflict_list_cnt += 1; |
conflict_list_cnt += 1; |
396 |
conflict_list_free -= 1; |
conflict_list_free -= 1; |
397 |
} |
} |
398 |
|
|
399 |
/* Leave a 0 at the end */ |
/* Leave a 0 at the end */ |
400 |
assert (conflict_list_free > 0); |
assert (conflict_list_free > 0); |
401 |
conflict_list_cnt += 1; |
conflict_list_cnt += 1; |
519 |
|
|
520 |
/* GLR parsers need space for conflict lists, so we can't |
/* GLR parsers need space for conflict lists, so we can't |
521 |
default conflicted entries. For non-conflicted entries |
default conflicted entries. For non-conflicted entries |
522 |
or as long as we are not building a GLR parser, |
or as long as we are not building a GLR parser, |
523 |
actions that match the default are replaced with zero, |
actions that match the default are replaced with zero, |
524 |
which means "use the default". */ |
which means "use the default". */ |
525 |
|
|
554 |
{ |
{ |
555 |
int i; |
int i; |
556 |
int count; |
int count; |
557 |
short *sp; |
short *sp = NULL; |
558 |
short *sp1; |
short *sp1 = NULL; |
559 |
short *sp2; |
short *sp2 = NULL; |
560 |
unsigned int *sp3; |
unsigned int *sp3 = NULL; |
561 |
|
|
562 |
count = 0; |
count = 0; |
563 |
for (i = 0; i < ntokens; i++) |
for (i = 0; i < ntokens; i++) |
570 |
froms[state] = sp1 = sp = XCALLOC (short, count); |
froms[state] = sp1 = sp = XCALLOC (short, count); |
571 |
tos[state] = sp2 = XCALLOC (short, count); |
tos[state] = sp2 = XCALLOC (short, count); |
572 |
if (glr_parser) |
if (glr_parser) |
573 |
conflict_tos[state] = sp3 = XCALLOC (unsigned int, count); |
conflict_tos[state] = sp3 = XCALLOC (unsigned int, count); |
574 |
else |
else |
575 |
conflict_tos[state] = NULL; |
conflict_tos[state] = NULL; |
576 |
|
|
577 |
for (i = 0; i < ntokens; i++) |
for (i = 0; i < ntokens; i++) |
612 |
conflict_list = XCALLOC (unsigned int, 1 + 2 * nconflict); |
conflict_list = XCALLOC (unsigned int, 1 + 2 * nconflict); |
613 |
conflict_list_free = 2 * nconflict; |
conflict_list_free = 2 * nconflict; |
614 |
conflict_list_cnt = 1; |
conflict_list_cnt = 1; |
615 |
} |
} |
616 |
else |
else |
617 |
conflict_list_free = conflict_list_cnt = 0; |
conflict_list_free = conflict_list_cnt = 0; |
618 |
|
|
619 |
for (i = 0; i < nstates; ++i) |
for (i = 0; i < nstates; ++i) |
667 |
merger_list* p; |
merger_list* p; |
668 |
|
|
669 |
fputs ("m4_define([b4_mergers], \n[[", out); |
fputs ("m4_define([b4_mergers], \n[[", out); |
670 |
for (n = 1, p = merge_functions; p != NULL; n += 1, p = p->next) |
for (n = 1, p = merge_functions; p != NULL; n += 1, p = p->next) |
671 |
{ |
{ |
672 |
if (p->type[0] == '\0') |
if (p->type[0] == '\0') |
673 |
fprintf (out, " case %d: yyval = %s (*yy0, *yy1); break;\n", |
fprintf (out, " case %d: yyval = %s (*yy0, *yy1); break;\n", |
674 |
n, p->name); |
n, p->name); |
675 |
else |
else |
1103 |
if (! glr_parser) |
if (! glr_parser) |
1104 |
return; |
return; |
1105 |
|
|
1106 |
muscle_insert_unsigned_int_table ("conflict_list_heads", conflict_table, |
muscle_insert_unsigned_int_table ("conflict_list_heads", conflict_table, |
1107 |
conflict_table[0], 1, high+1); |
conflict_table[0], 1, high+1); |
1108 |
muscle_insert_unsigned_int_table ("conflicting_rules", conflict_list, |
muscle_insert_unsigned_int_table ("conflicting_rules", conflict_list, |
1109 |
conflict_list[0], 1, conflict_list_cnt); |
conflict_list[0], 1, conflict_list_cnt); |
1110 |
|
|
1111 |
XFREE (conflict_table); |
XFREE (conflict_table); |