-}
-
-
-/*-------------------------------------------------------------------.
-| For GLR parsers, for each conflicted token in STATE, as indicated |
-| by non-zero entries in CONFLROW, create a list of possible |
-| reductions that are alternatives to the shift or reduction |
-| currently recorded for that token in STATE. Store the alternative |
-| reductions followed by a 0 in CONFLICT_LIST, updating |
-| CONFLICT_LIST_CNT, and storing an index to the start of the list |
-| back into CONFLROW. |
-`-------------------------------------------------------------------*/
-
-static void
-conflict_row (state_t *state)
-{
- int i, j;
-
- if (! glr_parser)
- return;
-
- for (j = 0; j < ntokens; j += 1)
- if (conflrow[j])
- {
- conflrow[j] = conflict_list_cnt;
-
- /* Find all reductions for token J, and record all that do not
- match ACTROW[J]. */
- for (i = 0; i < state->nlookaheads; i += 1)
- if (bitset_test (state->lookaheads[i], j)
- && (actrow[j]
- != rule_number_as_item_number (state->lookaheads_rule[i]->number)))
- {
- assert (conflict_list_free > 0);
- conflict_list[conflict_list_cnt]
- = state->lookaheads_rule[i]->number + 1;
- conflict_list_cnt += 1;
- conflict_list_free -= 1;
- }
-
- /* Leave a 0 at the end. */
- assert (conflict_list_free > 0);
- conflict_list_cnt += 1;
- conflict_list_free -= 1;
- }
-}
-
-
-/*------------------------------------------------------------------.
-| Decide what to do for each type of token if seen as the lookahead |
-| token in specified state. The value returned is used as the |
-| default action (yydefact) for the state. In addition, ACTROW is |
-| filled with what to do for each kind of token, index by symbol |
-| number, with zero meaning do the default action. The value |
-| ACTION_MIN, a very negative number, means this situation is an |
-| error. The parser recognizes this value specially. |
-| |
-| This is where conflicts are resolved. The loop over lookahead |
-| rules considered lower-numbered rules last, and the last rule |
-| considered that likes a token gets to handle it. |
-| |
-| For GLR parsers, also sets CONFLROW[SYM] to an index into |
-| CONFLICT_LIST iff there is an unresolved conflict (s/r or r/r) |
-| with symbol SYM. The default reduction is not used for a symbol |
-| that has any such conflicts. |
-`------------------------------------------------------------------*/
-
-static rule_t *
-action_row (state_t *state)
-{
- int i;
- rule_t *default_rule = NULL;
- reductions_t *redp = state->reductions;
- transitions_t *transitions = state->transitions;
- errs_t *errp = state->errs;
- /* Set to nonzero to inhibit having any default reduction. */
- int nodefault = 0;
- int conflicted = 0;
-
- for (i = 0; i < ntokens; i++)
- actrow[i] = conflrow[i] = 0;
-
- if (redp->num >= 1)
- {
- int j;
- bitset_iterator biter;
- /* loop over all the rules available here which require
- lookahead */
- for (i = state->nlookaheads - 1; i >= 0; --i)
- /* and find each token which the rule finds acceptable
- to come next */
- BITSET_FOR_EACH (biter, state->lookaheads[i], j, 0)
- {
- /* and record this rule as the rule to use if that
- token follows. */
- if (actrow[j] != 0)
- conflicted = conflrow[j] = 1;
- actrow[j] = rule_number_as_item_number (state->lookaheads_rule[i]->number);
- }
- }
-
- /* Now see which tokens are allowed for shifts in this state. For
- them, record the shift as the thing to do. So shift is preferred
- to reduce. */
- FOR_EACH_SHIFT (transitions, i)
- {
- symbol_number_t symbol = TRANSITION_SYMBOL (transitions, i);
- state_t *shift_state = transitions->states[i];
-
- if (actrow[symbol] != 0)
- conflicted = conflrow[symbol] = 1;
- actrow[symbol] = state_number_as_int (shift_state->number);
-
- /* Do not use any default reduction if there is a shift for
- error */
- if (symbol == errtoken->number)
- nodefault = 1;
- }
-
- /* See which tokens are an explicit error in this state (due to
- %nonassoc). For them, record ACTION_MIN as the action. */
- for (i = 0; i < errp->num; i++)
- {
- symbol_t *symbol = errp->symbols[i];
- actrow[symbol->number] = ACTION_MIN;
- }