- if (symbols[i]->destructor)
- {
- symbol_t *symbol = symbols[i];
-
- /* Filename, lineno,
- Symbol-name, Symbol-number,
- destructor, typename. */
- fprintf (out, "%s[[[%s]], [[%d]], [[%s]], [[%d]], [[%s]], [[%s]]]",
- first ? "" : ",\n",
- infile, symbol->destructor_location.first_line,
- symbol->tag,
- symbol->number,
- symbol->destructor,
- symbol->type_name);
-
- first = 0;
- }
- fputs ("])\n\n", out);
-}
-
-
-/*-------------------------------------.
-| Output the symbol printers to OOUT. |
-`-------------------------------------*/
-
-static void
-symbol_printers_output (FILE *out)
-{
- int i;
- int first = 1;
-
- fputs ("m4_define([b4_symbol_printers], \n[", out);
- for (i = 0; i < nsyms; ++i)
- if (symbols[i]->destructor)
- {
- symbol_t *symbol = symbols[i];
-
- /* Filename, lineno,
- Symbol-name, Symbol-number,
- destructor, typename. */
- fprintf (out, "%s[[[%s]], [[%d]], [[%s]], [[%d]], [[%s]], [[%s]]]",
- first ? "" : ",\n",
- infile, symbol->printer_location.first_line,
- symbol->tag,
- symbol->number,
- symbol->printer,
- symbol->type_name);
-
- first = 0;
- }
- fputs ("])\n\n", out);
-}
-
-
-/*------------------------------------------------------------------.
-| Compute FROMS[VECTOR], TOS[VECTOR], TALLY[VECTOR], WIDTH[VECTOR], |
-| i.e., the information related to non defaulted GOTO on the nterm |
-| SYMBOL. |
-| |
-| DEFAULT_STATE is the principal destination on SYMBOL, i.e., the |
-| default GOTO destination on SYMBOL. |
-`------------------------------------------------------------------*/
-
-static void
-save_column (symbol_number_t symbol, state_number_t default_state)
-{
- int i;
- base_t *sp;
- base_t *sp1;
- base_t *sp2;
- int count;
- vector_number_t symno = symbol_number_to_vector_number (symbol);
-
- goto_number_t begin = goto_map[symbol];
- goto_number_t end = goto_map[symbol + 1];
-
- /* Number of non default GOTO. */
- count = 0;
- for (i = begin; i < end; i++)
- if (to_state[i] != default_state)
- count++;
-
- if (count == 0)
- return;
-
- /* Allocate room for non defaulted gotos. */
- froms[symno] = sp1 = sp = XCALLOC (base_t, count);
- tos[symno] = sp2 = XCALLOC (base_t, count);
-
- /* Store the state numbers of the non defaulted gotos. */
- for (i = begin; i < end; i++)
- if (to_state[i] != default_state)
- {
- *sp1++ = from_state[i];
- *sp2++ = to_state[i];
- }
-
- tally[symno] = count;
- width[symno] = sp1[-1] - sp[0] + 1;
-}
-
-
-/*----------------------------------------------------------------.
-| Return `the' most common destination GOTO on SYMBOL (a nterm). |
-`----------------------------------------------------------------*/
-
-static state_number_t
-default_goto (symbol_number_t symbol, short state_count[])
-{
- state_number_t s;
- int i;
- goto_number_t m = goto_map[symbol];
- goto_number_t n = goto_map[symbol + 1];
- state_number_t default_state = (state_number_t) -1;
- int max = 0;
-
- if (m == n)
- return (state_number_t) -1;
-
- for (s = 0; s < nstates; s++)
- state_count[s] = 0;
-
- for (i = m; i < n; i++)
- state_count[to_state[i]]++;
-
- for (s = 0; s < nstates; s++)
- if (state_count[s] > max)
- {
- max = state_count[s];
- default_state = s;
- }
-
- return default_state;
-}
-
-
-/*-------------------------------------------------------------------.
-| Figure out what to do after reducing with each rule, depending on |
-| the saved state from before the beginning of parsing the data that |
-| matched this rule. |
-| |
-| The YYDEFGOTO table is output now. The detailed info is saved for |
-| putting into YYTABLE later. |
-`-------------------------------------------------------------------*/
-
-static void
-goto_actions (void)
-{
- symbol_number_t i;
- state_number_t *yydefgoto = XMALLOC (state_number_t, nvars);
-
- /* For a given nterm I, STATE_COUNT[S] is the number of times there
- is a GOTO to S on I. */
- short *state_count = XCALLOC (short, nstates);
- for (i = ntokens; i < nsyms; ++i)