X-Git-Url: https://git.saurik.com/bison.git/blobdiff_plain/720d742f8e74acf1ade85a7d39c02fa5b9528b5a..340ef489223a5d1f9c40674ea2973435cb8ecc1b:/src/print.c?ds=sidebyside diff --git a/src/print.c b/src/print.c index 8e10e4cf..9a848537 100644 --- a/src/print.c +++ b/src/print.c @@ -23,56 +23,15 @@ #include "alloc.h" #include "files.h" #include "gram.h" -#include "state.h" +#include "LR0.h" #include "lalr.h" - -extern char **tags; -extern int nstates; -extern errs **err_table; -extern char any_conflicts; -extern char *conflicts; -extern int final_state; - -extern void conflict_log PARAMS ((void)); -extern void verbose_conflict_log PARAMS ((void)); -extern void print_reductions PARAMS ((int)); - -extern void terse PARAMS ((void)); -extern void verbose PARAMS ((void)); - -#if 0 /* XXX currently unused. */ -static void print_token PARAMS ((int, int)); -#endif - -static void print_state PARAMS ((int)); -static void print_core PARAMS ((int)); -static void print_actions PARAMS ((int)); -static void print_grammar PARAMS ((void)); - -void -terse (void) -{ - if (any_conflicts) - conflict_log (); -} - - -void -verbose (void) -{ - int i; - - if (any_conflicts) - verbose_conflict_log (); - - print_grammar (); - - for (i = 0; i < nstates; i++) - print_state (i); -} +#include "conflicts.h" +#include "getargs.h" +#include "state.h" +#include "reader.h" -#if 0 /* XXX currently unused. */ +#if 0 static void print_token (int extnum, int token) { @@ -80,15 +39,10 @@ print_token (int extnum, int token) } #endif - -static void -print_state (int state) -{ - fprintf (foutput, _("\n\nstate %d\n\n"), state); - print_core (state); - print_actions (state); -} - + +/*================================\ +| Report information on a state. | +\================================*/ static void print_core (int state) @@ -136,7 +90,6 @@ print_core (int state) putc ('\n', foutput); } - static void print_actions (int state) { @@ -238,6 +191,18 @@ print_actions (int state) } } +static void +print_state (int state) +{ + fprintf (foutput, _("\n\nstate %d\n\n"), state); + print_core (state); + print_actions (state); +} + +/*-----------------------------------------. +| Print information on the whole grammar. | +`-----------------------------------------*/ + #define END_TEST(end) \ do { \ if (column + strlen(buffer) > (end)) { \ @@ -247,6 +212,7 @@ print_actions (int state) } \ } while (0) + static void print_grammar (void) { @@ -376,3 +342,19 @@ print_grammar (void) fprintf (foutput, "%s\n", buffer); } } + +void +print_results (void) +{ + int i; + + if (any_conflicts) + print_conflicts (); + + if (verboseflag) + print_grammar (); + + if (verboseflag) + for (i = 0; i < nstates; i++) + print_state (i); +}