- int i;
- int j;
- short *short_tab = NULL;
-
- {
- short *values = XCALLOC (short, nrules + 1);
- for (i = 0; i < nrules + 1; ++i)
- values[i] = rule_table[i].line;
- output_table_data (&output_obstack, values,
- 0, 1, nrules + 1);
- muscle_insert ("rline", obstack_finish (&output_obstack));
- XFREE (values);
- }
-
-
- j = 0;
- for (i = 0; i < nsyms; i++)
- {
- /* Be sure not to use twice the same quotearg slot. */
- const char *cp =
- quotearg_n_style (1, c_quoting_style,
- quotearg_style (escape_quoting_style, tags[i]));
- /* Width of the next token, including the two quotes, the coma
- and the space. */
- int strsize = strlen (cp) + 2;
-
- if (j + strsize > 75)
- {
- obstack_sgrow (&output_obstack, "\n ");
- j = 2;
- }
-
- obstack_sgrow (&output_obstack, cp);
- obstack_sgrow (&output_obstack, ", ");
- j += strsize;
- }
- /* add a NULL entry to list of tokens */
- obstack_sgrow (&output_obstack, "NULL");
-
- /* Finish table and store. */
- obstack_1grow (&output_obstack, 0);
- muscle_insert ("tname", obstack_finish (&output_obstack));
-
- /* Output YYTOKNUM. */
- output_table_data (&output_obstack, user_toknums,
- 0, 1, ntokens + 1);
- muscle_insert ("toknum", obstack_finish (&output_obstack));
-
- /* Output YYR1. */
- {
- short *values = XCALLOC (short, nrules + 1);
- for (i = 0; i < nrules + 1; ++i)
- values[i] = rule_table[i].lhs;
- output_table_data (&output_obstack, values,
- 0, 1, nrules + 1);
- muscle_insert ("r1", obstack_finish (&output_obstack));
- XFREE (values);
- }
-
- /* Output YYR2. */
- short_tab = XMALLOC (short, nrules + 1);
- for (i = 1; i < nrules; i++)
- short_tab[i] = rule_table[i + 1].rhs - rule_table[i].rhs - 1;
- short_tab[nrules] = nitems - rule_table[nrules].rhs - 1;
- output_table_data (&output_obstack, short_tab,
- 0, 1, nrules + 1);
- muscle_insert ("r2", obstack_finish (&output_obstack));
- XFREE (short_tab);
-}
-
-/*------------------------------------------------------------------.
-| 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 |
-| MINSHORT, 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. |
-`------------------------------------------------------------------*/
-
-static int
-action_row (int state)
-{
- int i;
- int m = 0;
- int n = 0;
- int default_rule = 0;
- reductions *redp = state_table[state]->reductions;
- int nreds = redp ? redp->nreds : 0;
- shifts *shiftp = state_table[state]->shifts;
- errs *errp = state_table[state]->errs;
- /* set nonzero to inhibit having any default reduction */
- int nodefault = 0;
-
- for (i = 0; i < ntokens; i++)
- actrow[i] = 0;
-
- if (nreds >= 1)
- {
- int j;
- /* loop over all the rules available here which require
- lookahead */
- m = state_table[state]->lookaheads;
- n = state_table[state + 1]->lookaheads;
-
- for (i = n - 1; i >= m; i--)
- /* and find each token which the rule finds acceptable
- to come next */
- for (j = 0; j < ntokens; j++)
- /* and record this rule as the rule to use if that
- token follows. */
- if (BITISSET (LA (i), j))
- actrow[j] = -LAruleno[i];
- }
-
- /* 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 (i = 0; i < shiftp->nshifts; i++)
- {
- int symbol;
- int shift_state = shiftp->shifts[i];
- if (!shift_state)
- continue;
-
- symbol = state_table[shift_state]->accessing_symbol;
-
- if (ISVAR (symbol))
- break;
-
- actrow[symbol] = shift_state;
-
- /* Do not use any default reduction if there is a shift for
- error */
- if (symbol == error_token_number)
- nodefault = 1;
- }