From: Akim Demaille Date: Mon, 2 Oct 2000 08:10:26 +0000 (+0000) Subject: * src/print.h: New file. X-Git-Tag: BISON-1_28b~112 X-Git-Url: https://git.saurik.com/bison.git/commitdiff_plain/07a58c1301a1131f7505e74f1d54bfdb31d193f5 * src/print.h: New file. Propagate its use. * src/print.c: Formatting and ordering changes. (verbose, terse): Replace with... (print_results): this new function. Adjust dependencies. --- diff --git a/ChangeLog b/ChangeLog index 8430f5c4..5876dad9 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,13 @@ +2000-10-02 Akim Demaille + + * src/print.h: New file. + Propagate its use. + * src/print.c: Formatting and ordering changes. + (verbose, terse): Replace with... + (print_results): this new function. + Adjust dependencies. + + 2000-10-02 Akim Demaille * src/conflicts.c (conflict_report): New function. diff --git a/src/Makefile.am b/src/Makefile.am index cebc1fd4..4919ddbb 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -22,7 +22,7 @@ noinst_HEADERS = alloc.h closure.h complain.h conflicts.h \ derives.h \ files.h getargs.h gram.h lalr.h lex.h nullable.h \ output.h state.h \ - reader.h reduce.h symtab.h system.h types.h + print.h reader.h reduce.h symtab.h system.h types.h data_DATA = bison.simple bison.hairy diff --git a/src/getargs.h b/src/getargs.h index a0180d79..3b9e2997 100644 --- a/src/getargs.h +++ b/src/getargs.h @@ -29,6 +29,6 @@ extern int nolinesflag; /* for -l */ extern int noparserflag; /* for -n */ extern int rawtoknumflag; /* for -r */ extern int toknumflag; /* for -k */ -extern int verboseflag; /* for -v */ +extern int verboseflag; /* for -v */ void getargs PARAMS ((int argc, char *argv[])); diff --git a/src/main.c b/src/main.c index 4dff4de5..248bcd89 100644 --- a/src/main.c +++ b/src/main.c @@ -30,6 +30,7 @@ #include "lalr.h" #include "reduce.h" #include "nullable.h" +#include "print.h" #if 0 /* XXX currently unused. */ /* Nonzero means failure has been detected; don't write a parser file. */ @@ -46,8 +47,6 @@ extern char *printable_version PARAMS ((int)); extern void generate_states PARAMS ((void)); extern void initialize_conflicts PARAMS ((void)); extern void finalize_conflicts PARAMS ((void)); -extern void verbose PARAMS ((void)); -extern void terse PARAMS ((void)); /* VMS complained about using `int'. */ @@ -96,12 +95,8 @@ main (int argc, char *argv[]) declarations. */ initialize_conflicts (); - /* Print information about results, if requested. In file print. - */ - if (verboseflag) - verbose (); - else - terse (); + /* Print information about results, if requested. */ + print_results (); /* Output the tables and the parser to ftable. In file output. */ output (); diff --git a/src/print.c b/src/print.c index 061a0fee..bf3fce87 100644 --- a/src/print.c +++ b/src/print.c @@ -26,47 +26,13 @@ #include "state.h" #include "lalr.h" #include "conflicts.h" +#include "getargs.h" +#include "state.h" extern char **tags; -extern int nstates; extern int final_state; -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) - print_conflicts (); -} - - -void -verbose (void) -{ - int i; - - if (any_conflicts) - print_conflicts (); - - print_grammar (); - - for (i = 0; i < nstates; i++) - print_state (i); -} - - -#if 0 /* XXX currently unused. */ +#if 0 static void print_token (int extnum, int token) { @@ -74,15 +40,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) @@ -130,7 +91,6 @@ print_core (int state) putc ('\n', foutput); } - static void print_actions (int state) { @@ -232,6 +192,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)) { \ @@ -241,6 +213,7 @@ print_actions (int state) } \ } while (0) + static void print_grammar (void) { @@ -370,3 +343,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); +} diff --git a/src/print.h b/src/print.h new file mode 100644 index 00000000..5fa82b16 --- /dev/null +++ b/src/print.h @@ -0,0 +1,26 @@ +/* Print information on generated parser, for bison, + Copyright (C) 2000 Free Software Foundation, Inc. + + This file is part of Bison, the GNU Compiler Compiler. + + Bison is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2, or (at your option) + any later version. + + Bison is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with Bison; see the file COPYING. If not, write to + the Free Software Foundation, Inc., 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. */ + +#ifndef PRINT_H_ +# define PRINT_H_ + +void print_results PARAMS ((void)); + +#endif /* !PRINT_H_ */