-/* Returns the number of lines of S. */
-size_t
-get_lines_number (const char *s)
-{
- size_t lines = 0;
-
- size_t i;
- for (i = 0; s[i]; ++i)
- if (s[i] == '\n')
- ++lines;
-
- return lines;
-}
-
-
-/* FIXME. */
-
-static inline void
-output_table_data (struct obstack *oout,
- short *table_data,
- short first,
- int begin,
- int end)
-{
- int i;
- int j = 1;
-
- obstack_fgrow1 (oout, "%6d", first);
- for (i = begin; i < end; ++i)
- {
- obstack_1grow (oout, ',');
- if (j >= 10)
- {
- obstack_sgrow (oout, "\n ");
- j = 1;
- }
- else
- ++j;
- obstack_fgrow1 (oout, "%6d", table_data[i]);
- }
- obstack_1grow (oout, 0);
-}
-
-
-static void
-output_token_translations (void)
-{
- output_table_data (&format_obstack, token_translations,
- 0, 1, max_user_token_number + 1);
- muscle_insert ("translate", obstack_finish (&format_obstack));
- XFREE (token_translations);
-}
-
-
-static void
-output_gram (void)
-{
- {
- int i;
- short *values = XCALLOC (short, nrules + 1);
- for (i = 0; i < nrules + 1; ++i)
- values[i] = rules[i].rhs;
- output_table_data (&format_obstack, values,
- 0, 1, nrules + 1);
- XFREE (values);
- }
-
- muscle_insert ("prhs", obstack_finish (&format_obstack));
-
- {
- short *yyrhs;
- int i;
-
- yyrhs = XMALLOC (short, nritems);
-
- for (i = 1; i < nritems; ++i)
- yyrhs[i] = ritem[i] >= 0 ? ritem[i] : -1;
-
- output_table_data (&format_obstack, yyrhs,
- ritem[0], 1, nritems);
- muscle_insert ("rhs", obstack_finish (&format_obstack));
-
- XFREE (yyrhs);
- }
-
-#if 0
- if (!semantic_parser)
- obstack_sgrow (&table_obstack, "\n#endif\n");
-#endif
-}
-
-
-static void
-output_stos (void)
-{
- int i;
- short *values = (short *) alloca (sizeof (short) * nstates);
- for (i = 0; i < nstates; ++i)
- values[i] = states[i]->accessing_symbol;
- output_table_data (&format_obstack, values,
- 0, 1, nstates);
- muscle_insert ("stos", obstack_finish (&format_obstack));
-}
-
-
-static void
-output_rule_data (void)
-{
- int i;
- int j;
- short *short_tab = NULL;
-
- {
- short *values = XCALLOC (short, nrules + 1);
- for (i = 0; i < nrules + 1; ++i)
- values[i] = rules[i].line;
- output_table_data (&format_obstack, values,
- 0, 1, nrules + 1);
- muscle_insert ("rline", obstack_finish (&format_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, symbols[i]->tag));
- /* 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 (&format_obstack, "\n ");
- j = 2;
- }
-
- obstack_sgrow (&format_obstack, cp);
- obstack_sgrow (&format_obstack, ", ");
- j += strsize;
- }
- /* add a NULL entry to list of tokens */
- obstack_sgrow (&format_obstack, "NULL");