X-Git-Url: https://git.saurik.com/bison.git/blobdiff_plain/a083fbbf221545ea6e68a831da060d8834f36eca..d9efd181112c1232acff11f11b2a5c064e08cf7d:/src/reduce.c diff --git a/src/reduce.c b/src/reduce.c index 9f9c2ee7..a654f0c7 100644 --- a/src/reduce.c +++ b/src/reduce.c @@ -15,7 +15,8 @@ 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, 675 Mass Ave, Cambridge, MA 02139, USA. */ +the Free Software Foundation, Inc., 59 Temple Place - Suite 330, +Boston, MA 02111-1307, USA. */ /* @@ -28,17 +29,17 @@ the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */ * parser. */ -#include #include "system.h" +#include "getargs.h" #include "files.h" #include "gram.h" -#include "machine.h" -#include "new.h" +#include "alloc.h" +#include "complain.h" extern char **tags; /* reader.c */ -extern int verboseflag; /* getargs.c */ static int statisticsflag; /* XXXXXXX */ +extern int fixed_outfiles; #ifndef TRUE #define TRUE (1) @@ -61,21 +62,24 @@ static int nuseful_productions, nuseless_productions, nuseful_nonterminals, nuseless_nonterminals; -static void useless_nonterminals(); -static void inaccessable_symbols(); -static void reduce_grammar_tables(); -static void print_results(); -static void print_notices(); -void dump_grammar(); +extern void reduce_grammar PARAMS((void)); +static bool bits_equal PARAMS((BSet, BSet, int)); +static int nbits PARAMS((unsigned)); +static int bits_size PARAMS((BSet, int)); +static void useless_nonterminals PARAMS((void)); +static void inaccessable_symbols PARAMS((void)); +static void reduce_grammar_tables PARAMS((void)); +static void print_results PARAMS((void)); +static void print_notices PARAMS((void)); + +#if 0 /* XXX currently unused. */ +static void dump_grammar PARAMS((void)); +#endif -extern void fatals (); -bool -bits_equal (L, R, n) -BSet L; -BSet R; -int n; +static bool +bits_equal (BSet L, BSet R, int n) { int i; @@ -86,24 +90,21 @@ int n; } -int -nbits (i) -unsigned i; +static int +nbits (unsigned i) { int count = 0; while (i != 0) { - i ^= (i & -i); + i ^= (i & ((unsigned) (- (int) i))); ++count; } return count; } -int -bits_size (S, n) -BSet S; -int n; +static int +bits_size (BSet S, int n) { int i, count = 0; @@ -113,7 +114,7 @@ int n; } void -reduce_grammar () +reduce_grammar (void) { bool reduced; @@ -138,16 +139,17 @@ reduce_grammar () print_notices(); if (!BITISSET(N, start_symbol - ntokens)) - fatals(_("Start symbol %s does not derive any sentence"), + fatal (_("Start symbol %s does not derive any sentence"), tags[start_symbol]); reduce_grammar_tables(); - /* if (verboseflag) { - fprintf(foutput, "REDUCED GRAMMAR\n\n"); - dump_grammar(); - } - */ - +#if 0 + if (verboseflag) + { + fprintf(foutput, "REDUCED GRAMMAR\n\n"); + dump_grammar(); + } +#endif /**/ statisticsflag = FALSE; /* someday getopts should handle this */ if (statisticsflag == TRUE) fprintf(stderr, @@ -169,14 +171,12 @@ reduce_grammar () /* * Another way to do this would be with a set for each production and then do - * subset tests against N, but even for the C grammar the whole reducing + * subset tests against N0, but even for the C grammar the whole reducing * process takes only 2 seconds on my 8Mhz AT. */ static bool -useful_production (i, N) -int i; -BSet N; +useful_production (int i, BSet N0) { rule r; short n; @@ -188,7 +188,7 @@ BSet N; for (r = &ritem[rrhs[i]]; *r > 0; r++) if (ISVAR(n = *r)) - if (!BITISSET(N, n - ntokens)) + if (!BITISSET(N0, n - ntokens)) return FALSE; return TRUE; } @@ -197,7 +197,7 @@ BSet N; /* Remember that rules are 1-origin, symbols are 0-origin. */ static void -useless_nonterminals () +useless_nonterminals (void) { BSet Np, Ns; int i, n; @@ -254,7 +254,7 @@ useless_nonterminals () } static void -inaccessable_symbols () +inaccessable_symbols (void) { BSet Vp, Vs, Pp; int i, n; @@ -353,7 +353,7 @@ inaccessable_symbols () } static void -reduce_grammar_tables () +reduce_grammar_tables (void) { /* This is turned off because we would need to change the numbers in the case statements in the actions file. */ @@ -482,7 +482,7 @@ reduce_grammar_tables () } static void -print_results () +print_results (void) { int i; /* short j; JF unused */ @@ -531,8 +531,9 @@ print_results () fprintf(foutput, "\n\n"); } -void -dump_grammar () +#if 0 /* XXX currently unused. */ +static void +dump_grammar (void) { int i; rule r; @@ -566,13 +567,12 @@ dump_grammar () } fprintf(foutput, "\n\n"); } +#endif static void -print_notices () +print_notices (void) { - extern int fixed_outfiles; - if (fixed_outfiles && nuseless_productions) fprintf(stderr, _("%d rules never reduced\n"), nuseless_productions);