X-Git-Url: https://git.saurik.com/bison.git/blobdiff_plain/b32ba448c85a41a75e9ef9b22c1f22f944eebdf4..e89a22bfab22e4d2ee73be49dcb66b51f8d0e892:/src/lalr.c diff --git a/src/lalr.c b/src/lalr.c index 09dc7602..d05d4ff5 100644 --- a/src/lalr.c +++ b/src/lalr.c @@ -103,7 +103,7 @@ traverse (int i) break; for (k = 0; k < size; ++k) - F (i)[k] = F (j)[k]; + F (j)[k] = F (i)[k]; } } @@ -247,16 +247,17 @@ set_goto_map (void) ngotos = 0; for (sp = first_shift; sp; sp = sp->next) - for (i = sp->nshifts - 1; i >= 0 && SHIFT_IS_GOTO (sp, i); --i) - { - symbol = state_table[sp->shifts[i]].accessing_symbol; + if (sp->nshifts) + for (i = sp->nshifts - 1; i >= 0 && SHIFT_IS_GOTO (sp, i); --i) + { + symbol = state_table[sp->shifts[i]].accessing_symbol; - if (ngotos == MAXSHORT) - fatal (_("too many gotos (max %d)"), MAXSHORT); + if (ngotos == MAXSHORT) + fatal (_("too many gotos (max %d)"), MAXSHORT); - ngotos++; - goto_map[symbol]++; - } + ngotos++; + goto_map[symbol]++; + } k = 0; for (i = ntokens; i < nsyms; i++) @@ -277,15 +278,16 @@ set_goto_map (void) for (sp = first_shift; sp; sp = sp->next) { state1 = sp->number; - for (i = sp->nshifts - 1; i >= 0 && SHIFT_IS_GOTO (sp, i); --i) - { - state2 = sp->shifts[i]; - symbol = state_table[state2].accessing_symbol; - - k = temp_map[symbol]++; - from_state[k] = state1; - to_state[k] = state2; - } + if (sp->nshifts) + for (i = sp->nshifts - 1; i >= 0 && SHIFT_IS_GOTO (sp, i); --i) + { + state2 = sp->shifts[i]; + symbol = state_table[state2].accessing_symbol; + + k = temp_map[symbol]++; + from_state[k] = state1; + to_state[k] = state2; + } } XFREE (temp_map + ntokens);