style: split large function

* src/print.c (print_grammar): Split into...
(print_terminal_symbols, print_nonterminal_symbols): these.
Adjust dependencies.
This commit is contained in:
Akim Demaille
2018-06-17 18:06:56 +02:00
parent 7f42eb0a5e
commit 4cdcb6f243

View File

@@ -402,13 +402,11 @@ print_state (FILE *out, state *s)
static void static void
print_grammar (FILE *out) print_terminal_symbols (FILE *out)
{ {
symbol_number i; symbol_number i;
char buffer[90]; char buffer[90];
grammar_rules_print (out);
/* TERMINAL (type #) : rule #s terminal is on RHS */ /* TERMINAL (type #) : rule #s terminal is on RHS */
fprintf (out, "%s\n\n", _("Terminals, with rules where they appear")); fprintf (out, "%s\n\n", _("Terminals, with rules where they appear"));
for (i = 0; i < max_user_token_number + 1; i++) for (i = 0; i < max_user_token_number + 1; i++)
@@ -435,8 +433,15 @@ print_grammar (FILE *out)
fprintf (out, "%s\n", buffer); fprintf (out, "%s\n", buffer);
} }
fputs ("\n\n", out); fputs ("\n\n", out);
}
static void
print_nonterminal_symbols (FILE *out)
{
symbol_number i;
char buffer[90];
fprintf (out, "%s\n\n", _("Nonterminals, with rules where they appear")); fprintf (out, "%s\n\n", _("Nonterminals, with rules where they appear"));
for (i = ntokens; i < nsyms; i++) for (i = ntokens; i < nsyms; i++)
{ {
@@ -513,7 +518,9 @@ print_results (void)
rule_useless_in_parser_p); rule_useless_in_parser_p);
conflicts_output (out); conflicts_output (out);
print_grammar (out); grammar_rules_print (out);
print_terminal_symbols (out);
print_nonterminal_symbols (out);
/* If the whole state item sets, not only the kernels, are wanted, /* If the whole state item sets, not only the kernels, are wanted,
'closure' will be run, which needs memory allocation/deallocation. */ 'closure' will be run, which needs memory allocation/deallocation. */