From d2729d44ab05f89e96d199ad6b10e127c1cb0a38 Mon Sep 17 00:00:00 2001 From: Jesse Thilo Date: Wed, 30 Dec 1998 05:27:11 +0000 Subject: [PATCH] Use prototypes if the compiler understands them. --- acconfig.h | 9 ++++ configure.in | 18 +++++-- src/LR0.c | 66 ++++++++++++------------ src/alloc.h | 4 +- src/allocate.c | 12 ++--- src/closure.c | 30 +++++------ src/conflicts.c | 58 ++++++++++----------- src/derives.c | 10 ++-- src/getargs.c | 12 ++--- src/gram.c | 4 +- src/lalr.c | 83 ++++++++++++++----------------- src/lex.c | 51 +++++++++---------- src/main.c | 72 ++++++++++++++------------- src/nullable.c | 6 ++- src/output.c | 130 +++++++++++++++++++++++------------------------- src/print.c | 38 +++++++------- src/reduce.c | 55 ++++++++++---------- src/symtab.c | 19 ++++--- src/symtab.h | 2 +- src/warshall.c | 12 ++--- 20 files changed, 346 insertions(+), 345 deletions(-) diff --git a/acconfig.h b/acconfig.h index fbf4463c..de444f8e 100644 --- a/acconfig.h +++ b/acconfig.h @@ -9,6 +9,15 @@ /* Version of package. */ #undef VERSION +/* Define if the compiler understands prototypes. */ +#undef PROTOTYPES + @BOTTOM@ +#if defined(PROTOTYPES) || defined(__cplusplus) +# define PARAMS(p) p +#else +# define PARAMS(p) () +#endif + #endif /* CONFIG_H */ diff --git a/configure.in b/configure.in index 4763fc5a..8e73c254 100644 --- a/configure.in +++ b/configure.in @@ -1,24 +1,32 @@ dnl Process this file with autoconf to produce a configure script. AC_INIT(reduce.c) -AM_INIT_AUTOMAKE(bison,1.25.90) +AM_INIT_AUTOMAKE(bison,1.26) AM_CONFIG_HEADER(config.h:config.hin) dnl Checks for programs. AC_PROG_CC +AC_MINIX +AC_ISC_POSIX +AM_PROG_CC_STDC AC_PROG_INSTALL AC_PROG_RANLIB -AC_MINIX -AC_ISC_POSIX +dnl Checks for libraries. dnl Checks for header files. AC_HEADER_STDC -AC_CHECK_HEADERS(string.h stdlib.h memory.h) +AC_CHECK_HEADERS(ctype.h locale.h memory.h stdlib.h string.h unistd.h) + +dnl Checks for typedefs. + +dnl Checks for structures. -dnl Checks for typedefs, structures, and compiler characteristics. +dnl Checks for compiler characteristics. AC_C_CONST +AM_C_PROTOTYPES dnl Checks for library functions. AC_FUNC_ALLOCA +AC_CHECK_FUNCS(setlocale) AC_OUTPUT(Makefile) diff --git a/src/LR0.c b/src/LR0.c index 34022195..1352c33d 100644 --- a/src/LR0.c +++ b/src/LR0.c @@ -40,20 +40,24 @@ core *first_state; shifts *first_shift; reductions *first_reduction; -int get_state(); -core *new_state(); - -void new_itemsets(); -void append_states(); -void initialize_states(); -void save_shifts(); -void save_reductions(); -void augment_automaton(); -void insert_start_shift(); -extern void initialize_closure(); -extern void closure(); -extern void finalize_closure(); -extern void toomany(); +int get_state PARAMS((int)); +core *new_state PARAMS((int)); + +void allocate_itemsets PARAMS((void)); +void allocate_storage PARAMS((void)); +void free_storage PARAMS((void)); +void generate_states PARAMS((void)); +void new_itemsets PARAMS((void)); +void append_states PARAMS((void)); +void initialize_states PARAMS((void)); +void save_shifts PARAMS((void)); +void save_reductions PARAMS((void)); +void augment_automaton PARAMS((void)); +void insert_start_shift PARAMS((void)); +extern void initialize_closure PARAMS((int)); +extern void closure PARAMS((short *, int)); +extern void finalize_closure PARAMS((void)); +extern void toomany PARAMS((char *)); static core *this_state; static core *last_state; @@ -78,7 +82,7 @@ static core **state_table; void -allocate_itemsets() +allocate_itemsets (void) { register short *itemp; register int symbol; @@ -123,7 +127,7 @@ allocate_itemsets() void -allocate_storage() +allocate_storage (void) { allocate_itemsets(); @@ -134,7 +138,7 @@ allocate_storage() void -free_storage() +free_storage (void) { FREE(shift_symbol); FREE(redset); @@ -150,7 +154,7 @@ free_storage() /* compute the nondeterministic finite state machine (see state.h for details) from the grammar. */ void -generate_states() +generate_states (void) { allocate_storage(); initialize_closure(nitems); @@ -196,7 +200,7 @@ generate_states() a vector of item numbers activated if that symbol is shifted, and kernel_end[symbol] points after the end of that vector. */ void -new_itemsets() +new_itemsets (void) { register int i; register int shiftcount; @@ -244,7 +248,7 @@ new_itemsets() shiftset is set up as a vector of state numbers of those states. */ void -append_states() +append_states (void) { register int i; register int j; @@ -283,8 +287,7 @@ Create a new state if no equivalent one exists already. Used by append_states */ int -get_state(symbol) -int symbol; +get_state (int symbol) { register int key; register short *isp1; @@ -357,8 +360,7 @@ int symbol; /* subroutine of get_state. create a new state for those items, if necessary. */ core * -new_state(symbol) -int symbol; +new_state (int symbol) { register int n; register core *p; @@ -396,7 +398,7 @@ int symbol; void -initialize_states() +initialize_states (void) { register core *p; /* register unsigned *rp1; JF unused */ @@ -410,7 +412,7 @@ initialize_states() void -save_shifts() +save_shifts (void) { register shifts *p; register short *sp1; @@ -418,7 +420,7 @@ save_shifts() register short *send; p = (shifts *) xmalloc((unsigned) (sizeof(shifts) + - (nshifts - 1) * sizeof(short))); + (nshifts - 1) * sizeof(short))); p->number = this_state->number; p->nshifts = nshifts; @@ -447,7 +449,7 @@ save_shifts() /* find which rules can be used for reduction transitions from the current state and make a reductions structure for the state to record their rule numbers. */ void -save_reductions() +save_reductions (void) { register short *isp; register short *rp1; @@ -475,7 +477,7 @@ save_reductions() if (count) { p = (reductions *) xmalloc((unsigned) (sizeof(reductions) + - (count - 1) * sizeof(short))); + (count - 1) * sizeof(short))); p->number = this_state->number; p->nreds = count; @@ -508,7 +510,7 @@ which has a shift going to the final state, which has a shift to the termination state. Create such states and shifts if they don't happen to exist already. */ void -augment_automaton() +augment_automaton (void) { register int i; register int k; @@ -548,7 +550,7 @@ augment_automaton() if (sp && sp->number == k) { sp2 = (shifts *) xmalloc((unsigned) (sizeof(shifts) - + sp->nshifts * sizeof(short))); + + sp->nshifts * sizeof(short))); sp2->number = k; sp2->nshifts = sp->nshifts + 1; sp2->shifts[0] = nstates; @@ -681,7 +683,7 @@ augment_automaton() Create the next-to-final state, to which a shift has already been made in the initial state. */ void -insert_start_shift() +insert_start_shift (void) { register core *statep; register shifts *sp; diff --git a/src/alloc.h b/src/alloc.h index ab045b36..47542dfa 100644 --- a/src/alloc.h +++ b/src/alloc.h @@ -27,5 +27,5 @@ the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */ #define FREE(x) ((x) != 0 && (free ((char *) (x)), 0)) #endif -extern char *xmalloc(); -extern char *xrealloc(); +extern char *xmalloc PARAMS((register unsigned)); +extern char *xrealloc PARAMS((register char *, register unsigned)); diff --git a/src/allocate.c b/src/allocate.c index 9f07b016..c79cae16 100644 --- a/src/allocate.c +++ b/src/allocate.c @@ -29,13 +29,15 @@ extern char *calloc (); extern char *realloc (); #endif -extern void done (); +char *xmalloc PARAMS((register unsigned)); +char *xrealloc PARAMS((register char *, register unsigned)); + +extern void done PARAMS((int)); extern char *program_name; char * -xmalloc (n) - register unsigned n; +xmalloc (register unsigned n) { register char *block; @@ -53,9 +55,7 @@ xmalloc (n) } char * -xrealloc (block, n) - register char *block; - register unsigned n; +xrealloc (register char *block, register unsigned n) { /* Avoid uncertainty about what an arg of 0 will do. */ if (n == 0) diff --git a/src/closure.c b/src/closure.c index 6255538f..01076946 100644 --- a/src/closure.c +++ b/src/closure.c @@ -58,10 +58,13 @@ Frees itemset, ruleset and internal data. extern short **derives; extern char **tags; -void set_fderives(); -void set_firsts(); +void initialize_closure PARAMS((int)); +void set_fderives PARAMS((void)); +void set_firsts PARAMS((void)); +void closure PARAMS((short *, int)); +void finalize_closure PARAMS((void)); -extern void RTC(); +extern void RTC PARAMS((unsigned *, int)); short *itemset; short *itemsetend; @@ -79,8 +82,7 @@ static int varsetsize; void -initialize_closure(n) -int n; +initialize_closure (int n) { itemset = NEW2(n, short); @@ -98,7 +100,7 @@ int n; the sequence of symbols 8 3 20, and one of the rules for deriving symbol 8 is rule 4, then the [5 - ntokens, 4] bit in fderives is set. */ void -set_fderives() +set_fderives (void) { register unsigned *rrow; register unsigned *vrow; @@ -158,7 +160,7 @@ set_fderives() the symbol 8 can be the beginning of the data for symbol 5, so the bit [8 - ntokens, 5 - ntokens] in firsts is set. */ void -set_firsts() +set_firsts (void) { register unsigned *row; /* register int done; JF unused */ @@ -198,9 +200,7 @@ set_firsts() void -closure(core, n) -short *core; -int n; +closure (short *core, int n) { register int ruleno; register unsigned word; @@ -282,7 +282,7 @@ int n; void -finalize_closure() +finalize_closure (void) { FREE(itemset); FREE(ruleset); @@ -304,8 +304,8 @@ int n; } - -print_firsts() +void +print_firsts (void) { register int i; register int j; @@ -326,8 +326,8 @@ print_firsts() } - -print_fderives() +void +print_fderives (void) { register int i; register int j; diff --git a/src/conflicts.c b/src/conflicts.c index c2521909..cb0e67db 100644 --- a/src/conflicts.c +++ b/src/conflicts.c @@ -35,14 +35,20 @@ extern unsigned *LA; extern short *LAruleno; extern short *lookaheads; extern int verboseflag; - -void set_conflicts(); -void resolve_sr_conflict(); -void flush_shift(); -void log_resolution(); -void total_conflicts(); -void count_sr_conflicts(); -void count_rr_conflicts(); +extern int fixed_outfiles; + +void initialize_conflicts PARAMS((void)); +void set_conflicts PARAMS((int)); +void resolve_sr_conflict PARAMS((int, int)); +void flush_shift PARAMS((int, int)); +void log_resolution PARAMS((int, int, int, char *)); +void conflict_log PARAMS((void)); +void verbose_conflict_log PARAMS((void)); +void total_conflicts PARAMS((void)); +void count_sr_conflicts PARAMS((int)); +void count_rr_conflicts PARAMS((int)); +void print_reductions PARAMS((int)); +void finalize_conflicts PARAMS((void)); char any_conflicts; char *conflicts; @@ -59,7 +65,7 @@ static int rrc_count; void -initialize_conflicts() +initialize_conflicts (void) { register int i; /* register errs *sp; JF unused */ @@ -78,8 +84,7 @@ initialize_conflicts() void -set_conflicts(state) -int state; +set_conflicts (int state) { register int i; register int k; @@ -165,9 +170,7 @@ A conflict is resolved by modifying the shift or reduce tables so that there is no longer a conflict. */ void -resolve_sr_conflict(state, lookaheadnum) -int state; -int lookaheadnum; +resolve_sr_conflict (int state, int lookaheadnum) { register int i; register int mask; @@ -268,9 +271,7 @@ int lookaheadnum; Used when we resolve a shift-reduce conflict in favor of the reduction. */ void -flush_shift(state, token) -int state; -int token; +flush_shift (int state, int token) { register shifts *shiftp; register int k, i; @@ -291,9 +292,7 @@ int token; void -log_resolution(state, LAno, token, resolution) -int state, LAno, token; -char *resolution; +log_resolution (int state, int LAno, int token, char *resolution) { fprintf(foutput, _("Conflict in state %d between rule %d and token %s resolved as %s.\n"), @@ -302,7 +301,7 @@ char *resolution; void -conflict_log() +conflict_log (void) { register int i; @@ -325,7 +324,7 @@ conflict_log() void -verbose_conflict_log() +verbose_conflict_log (void) { register int i; @@ -366,10 +365,8 @@ verbose_conflict_log() void -total_conflicts() +total_conflicts (void) { - extern int fixed_outfiles; - if (src_total == expected_conflicts && rrc_total == 0) return; @@ -410,8 +407,7 @@ total_conflicts() void -count_sr_conflicts(state) -int state; +count_sr_conflicts (int state) { register int i; register int k; @@ -478,8 +474,7 @@ int state; void -count_rr_conflicts(state) -int state; +count_rr_conflicts (int state) { register int i; register int j; @@ -525,8 +520,7 @@ int state; void -print_reductions(state) -int state; +print_reductions (int state) { register int i; register int j; @@ -745,7 +739,7 @@ int state; void -finalize_conflicts() +finalize_conflicts (void) { FREE(conflicts); FREE(shiftset); diff --git a/src/derives.c b/src/derives.c index 7a95050c..e8c70402 100644 --- a/src/derives.c +++ b/src/derives.c @@ -29,11 +29,13 @@ the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */ #include "types.h" #include "gram.h" +void set_derives PARAMS((void)); +void free_derives PARAMS((void)); short **derives; void -set_derives() +set_derives (void) { register int i; register int lhs; @@ -82,7 +84,7 @@ set_derives() } void -free_derives() +free_derives (void) { FREE(derives[ntokens]); FREE(derives + ntokens); @@ -92,7 +94,8 @@ free_derives() #ifdef DEBUG -print_derives() +void +print_derives (void) { register int i; register short *sp; @@ -115,4 +118,3 @@ print_derives() } #endif - diff --git a/src/getargs.c b/src/getargs.c index eb48a5ee..35cac38f 100644 --- a/src/getargs.c +++ b/src/getargs.c @@ -34,10 +34,13 @@ char *spec_name_prefix; /* for -p. */ char *spec_file_prefix; /* for -b. */ extern int fixed_outfiles;/* for -y */ +void usage PARAMS((FILE *)); +void getargs PARAMS((int, char *[])); + extern char *program_name; extern char *version_string; -extern void warns(); /* main.c */ +extern void warns PARAMS((char *, char *)); /* main.c */ struct option longopts[] = { @@ -60,8 +63,7 @@ struct option longopts[] = }; void -usage (stream) - FILE *stream; +usage (FILE *stream) { fprintf (stream, _("\ Usage: %s [-dhklntvyV] [-b file-prefix] [-o outfile] [-p name-prefix]\n\ @@ -75,9 +77,7 @@ Report bugs to bug-bison@gnu.org\n"), } void -getargs(argc, argv) - int argc; - char *argv[]; +getargs (int argc, char *argv[]) { register int c; diff --git a/src/gram.c b/src/gram.c index cc1418d9..6b487376 100644 --- a/src/gram.c +++ b/src/gram.c @@ -52,7 +52,7 @@ int error_token_number; /* This is to avoid linker problems which occur on VMS when using GCC, when the file in question contains data definitions only. */ -void -dummy() +static void +dummy (void) { } diff --git a/src/lalr.c b/src/lalr.c index 31ca44da..dc0b043c 100644 --- a/src/lalr.c +++ b/src/lalr.c @@ -73,24 +73,26 @@ short *goto_map; short *from_state; short *to_state; -short **transpose(); -void set_state_table(); -void set_accessing_symbol(); -void set_shift_table(); -void set_reduction_table(); -void set_maxrhs(); -void initialize_LA(); -void set_goto_map(); -void initialize_F(); -void build_relations(); -void add_lookback_edge(); -void compute_FOLLOWS(); -void compute_lookaheads(); -void digraph(); -void traverse(); - -extern void toomany(); -extern void berror(); +void lalr PARAMS((void)); +short **transpose PARAMS((short **, int)); +void set_state_table PARAMS((void)); +void set_accessing_symbol PARAMS((void)); +void set_shift_table PARAMS((void)); +void set_reduction_table PARAMS((void)); +void set_maxrhs PARAMS((void)); +void initialize_LA PARAMS((void)); +void set_goto_map PARAMS((void)); +int map_goto PARAMS((int, int)); +void initialize_F PARAMS((void)); +void build_relations PARAMS((void)); +void add_lookback_edge PARAMS((int, int, int)); +void compute_FOLLOWS PARAMS((void)); +void compute_lookaheads PARAMS((void)); +void digraph PARAMS((short **)); +void traverse PARAMS((register int)); + +extern void toomany PARAMS((char *)); +extern void berror PARAMS((char *)); static int infinity; static int maxrhs; @@ -105,7 +107,7 @@ static int top; void -lalr() +lalr (void) { tokensetsize = WORDSIZE(ntokens); @@ -124,7 +126,7 @@ lalr() void -set_state_table() +set_state_table (void) { register core *sp; @@ -136,7 +138,7 @@ set_state_table() void -set_accessing_symbol() +set_accessing_symbol (void) { register core *sp; @@ -148,7 +150,7 @@ set_accessing_symbol() void -set_shift_table() +set_shift_table (void) { register shifts *sp; @@ -160,7 +162,7 @@ set_shift_table() void -set_reduction_table() +set_reduction_table (void) { register reductions *rp; @@ -172,7 +174,7 @@ set_reduction_table() void -set_maxrhs() +set_maxrhs (void) { register short *itemp; register int length; @@ -198,7 +200,7 @@ set_maxrhs() void -initialize_LA() +initialize_LA (void) { register int i; register int j; @@ -256,7 +258,7 @@ initialize_LA() { if (!consistent[i]) { - if (rp = reduction_table[i]) + if ((rp = reduction_table[i])) for (j = 0; j < rp->nreds; j++) *np++ = rp->rules[j]; } @@ -265,7 +267,7 @@ initialize_LA() void -set_goto_map() +set_goto_map (void) { register shifts *sp; register int i; @@ -335,9 +337,7 @@ set_goto_map() /* Map_goto maps a state/symbol pair into its numeric representation. */ int -map_goto(state, symbol) -int state; -int symbol; +map_goto (int state, int symbol) { register int high; register int low; @@ -366,7 +366,7 @@ int symbol; void -initialize_F() +initialize_F (void) { register int i; register int j; @@ -442,7 +442,7 @@ initialize_F() void -build_relations() +build_relations (void) { register int i; register int j; @@ -537,10 +537,7 @@ build_relations() void -add_lookback_edge(stateno, ruleno, gotono) -int stateno; -int ruleno; -int gotono; +add_lookback_edge (int stateno, int ruleno, int gotono) { register int i; register int k; @@ -570,9 +567,7 @@ int gotono; short ** -transpose(R_arg, n) -short **R_arg; -int n; +transpose (short **R_arg, int n) { register short **new_R; register short **temp_R; @@ -627,7 +622,7 @@ int n; void -compute_FOLLOWS() +compute_FOLLOWS (void) { register int i; @@ -643,7 +638,7 @@ compute_FOLLOWS() void -compute_lookaheads() +compute_lookaheads (void) { register int i; register int n; @@ -686,8 +681,7 @@ compute_lookaheads() void -digraph(relation) -short **relation; +digraph (short **relation) { register int i; @@ -713,8 +707,7 @@ short **relation; void -traverse(i) -register int i; +traverse (register int i) { register unsigned *fp1; register unsigned *fp2; diff --git a/src/lex.c b/src/lex.c index c73bc40f..f0fbf485 100644 --- a/src/lex.c +++ b/src/lex.c @@ -26,7 +26,6 @@ the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */ symval is set to a pointer to the entry found. */ #include -#include #include "system.h" #include "files.h" #include "getopt.h" /* for optarg */ @@ -50,19 +49,27 @@ extern char *spec_file_prefix; /* for -b */ extern int lineno; extern int translations; -int parse_percent_token(); +void init_lex PARAMS((void)); +char *grow_token_buffer PARAMS((char *)); +int skip_white_space PARAMS((void)); +int safegetc PARAMS((FILE *)); +int literalchar PARAMS((char **, int *, char)); +void unlex PARAMS((int)); +int lex PARAMS((void)); +int parse_percent_token PARAMS((void)); /* functions from main.c */ -extern char *printable_version(); -extern void fatal(); -extern void warni(); -extern void warn(); +extern char *printable_version PARAMS((int)); +extern void fatal PARAMS((char *)); +extern void warn PARAMS((char *)); +extern void warni PARAMS((char *, int)); +extern void warns PARAMS((char *, char *)); /* Buffer for storing the current token. */ char *token_buffer; /* Allocated size of token_buffer, not including space for terminator. */ -static int maxtoken; +int maxtoken; bucket *symval; int numval; @@ -72,7 +79,7 @@ static bucket *unlexed_symval; /* by the next call to lex */ void -init_lex() +init_lex (void) { maxtoken = 100; token_buffer = NEW2 (maxtoken + 1, char); @@ -80,9 +87,8 @@ init_lex() } -static char * -grow_token_buffer (p) - char *p; +char * +grow_token_buffer (char *p) { int offset = p - token_buffer; maxtoken *= 2; @@ -92,7 +98,7 @@ grow_token_buffer (p) int -skip_white_space() +skip_white_space (void) { register int c; register int inside; @@ -162,8 +168,7 @@ skip_white_space() /* do a getc, but give error message if EOF encountered */ int -safegetc(f) - FILE *f; +safegetc (FILE *f) { register int c = getc(f); if (c == EOF) @@ -178,10 +183,7 @@ safegetc(f) report error for \n */ int -literalchar(pp, pcode, term) - char **pp; - int *pcode; - char term; +literalchar (char **pp, int *pcode, char term) { register int c; register char *p; @@ -211,7 +213,7 @@ literalchar(pp, pcode, term) else if (c == 'r') code = '\r'; else if (c == 'f') code = '\f'; else if (c == 'b') code = '\b'; - else if (c == 'v') code = 013; + else if (c == 'v') code = '\013'; else if (c == '\\') code = '\\'; else if (c == '\'') code = '\''; else if (c == '\"') code = '\"'; @@ -293,8 +295,7 @@ literalchar(pp, pcode, term) void -unlex(token) - int token; +unlex (int token) { unlexed = token; unlexed_symval = symval; @@ -302,7 +303,7 @@ unlex(token) int -lex() +lex (void) { register int c; char *p; @@ -542,8 +543,8 @@ struct percent_table_struct { /* These would be acceptable, but they do not affect processing */ {"verbose", &verboseflag, NOOP}, /* -v */ {"debug", &debugflag, NOOP}, /* -t */ - /* {"help", , NOOP}, /* -h */ - /* {"version", , NOOP}, /* -V */ + /* {"help", , NOOP},*/ /* -h */ + /* {"version", , NOOP},*/ /* -V */ #endif {NULL, NULL, ILLEGAL} @@ -553,7 +554,7 @@ struct percent_table_struct { Assumes the % has already been read and discarded. */ int -parse_percent_token () +parse_percent_token (void) { register int c; register char *p; diff --git a/src/main.c b/src/main.c index 4482286f..88444a18 100644 --- a/src/main.c +++ b/src/main.c @@ -24,6 +24,7 @@ the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */ extern int lineno; extern int verboseflag; +extern char *infile; /* Nonzero means failure has been detected; don't write a parser file. */ int failure; @@ -31,18 +32,37 @@ int failure; /* The name this program was run with, for messages. */ char *program_name; -extern void getargs(), openfiles(), reader(), reduce_grammar(); -extern void set_derives(), set_nullable(), generate_states(); -extern void lalr(), initialize_conflicts(), verbose(), terse(); -extern void output(), done(); +char *printable_version PARAMS((int)); +char *int_to_string PARAMS((int)); +void fatal PARAMS((char *)); +void fatals PARAMS((char *, char *)); +void warn PARAMS((char *)); +void warni PARAMS((char *, int)); +void warns PARAMS((char *, char *)); +void warnss PARAMS((char *, char *, char *)); +void warnsss PARAMS((char *, char *, char *, char *)); +void toomany PARAMS((char *)); +void berror PARAMS((char *)); + +extern void getargs PARAMS((int, char *[])); +extern void openfiles PARAMS((void)); +extern void reader PARAMS((void)); +extern void reduce_grammar PARAMS((void)); +extern void set_derives PARAMS((void)); +extern void set_nullable PARAMS((void)); +extern void generate_states PARAMS((void)); +extern void lalr PARAMS((void)); +extern void initialize_conflicts PARAMS((void)); +extern void verbose PARAMS((void)); +extern void terse PARAMS((void)); +extern void output PARAMS((void)); +extern void done PARAMS((int)); /* VMS complained about using `int'. */ int -main(argc, argv) - int argc; - char *argv[]; +main (int argc, char *argv[]) { program_name = argv[0]; setlocale (LC_ALL, ""); @@ -100,8 +120,7 @@ main(argc, argv) either C itself, or the corresponding \DDD code. */ char * -printable_version(c) - int c; +printable_version (int c) { static char buf[10]; if (c < ' ' || c >= '\177') @@ -118,8 +137,7 @@ printable_version(c) Return a ptr to internal memory containing the string. */ char * -int_to_string(i) - int i; +int_to_string (int i) { static char buf[20]; sprintf(buf, "%d", i); @@ -129,11 +147,8 @@ int_to_string(i) /* Print the message S for a fatal error. */ void -fatal(s) - char *s; +fatal (char *s) { - extern char *infile; - if (infile == 0) fprintf(stderr, _("%s: fatal error: %s\n"), program_name, s); else @@ -146,8 +161,7 @@ fatal(s) and incorporate string X1. */ void -fatals(fmt, x1) - char *fmt, *x1; +fatals (char *fmt, char *x1) { char buffer[200]; sprintf(buffer, fmt, x1); @@ -157,11 +171,8 @@ fatals(fmt, x1) /* Print a warning message S. */ void -warn(s) - char *s; +warn (char *s) { - extern char *infile; - if (infile == 0) fprintf(stderr, _("%s: %s\n"), program_name, s); else @@ -175,9 +186,7 @@ warn(s) The message is given by the format FMT. */ void -warni(fmt, x1) - char *fmt; - int x1; +warni (char *fmt, int x1) { char buffer[200]; sprintf(buffer, fmt, x1); @@ -188,8 +197,7 @@ warni(fmt, x1) The message is given by the format FMT. */ void -warns(fmt, x1) - char *fmt, *x1; +warns (char *fmt, char *x1) { char buffer[200]; sprintf(buffer, fmt, x1); @@ -200,8 +208,7 @@ warns(fmt, x1) The message is given by the format FMT. */ void -warnss(fmt, x1, x2) - char *fmt, *x1, *x2; +warnss (char *fmt, char *x1, char *x2) { char buffer[200]; sprintf(buffer, fmt, x1, x2); @@ -212,8 +219,7 @@ warnss(fmt, x1, x2) The message is given by the format FMT. */ void -warnsss(fmt, x1, x2, x3) - char *fmt, *x1, *x2, *x3; +warnsss (char *fmt, char *x1, char *x2, char *x3) { char buffer[200]; sprintf(buffer, fmt, x1, x2, x3); @@ -224,8 +230,7 @@ warnsss(fmt, x1, x2, x3) instances of whatever is denoted by the string S. */ void -toomany(s) - char *s; +toomany (char *s) { char buffer[200]; sprintf(buffer, _("too many %s (max %d)"), s, MAXSHORT); @@ -235,8 +240,7 @@ toomany(s) /* Abort for an internal error denoted by string S. */ void -berror(s) - char *s; +berror (char *s) { fprintf(stderr, _("%s: internal error: %s\n"), program_name, s); abort(); diff --git a/src/nullable.c b/src/nullable.c index c3c96d7d..f931f4a9 100644 --- a/src/nullable.c +++ b/src/nullable.c @@ -30,9 +30,11 @@ the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */ char *nullable; +void free_nullable PARAMS((void)); +void set_nullable PARAMS((void)); void -set_nullable() +set_nullable (void) { register short *r; register short *s1; @@ -130,7 +132,7 @@ set_nullable() void -free_nullable() +free_nullable (void) { FREE(nullable + ntokens); } diff --git a/src/output.c b/src/output.c index 6d96d50f..d7a8301c 100644 --- a/src/output.c +++ b/src/output.c @@ -132,37 +132,40 @@ extern char *consistent; extern short *goto_map; extern short *from_state; extern short *to_state; - -void output_token_translations(); -void output_gram(); -void output_stos(); -void output_rule_data(); -void output_defines(); -void output_actions(); -void token_actions(); -void save_row(); -void goto_actions(); -void save_column(); -void sort_actions(); -void pack_table(); -void output_base(); -void output_table(); -void output_check(); -void output_parser(); -void output_program(); -void free_itemset(); -void free_shifts(); -void free_reductions(); -void free_itemsets(); -int action_row(); -int default_goto(); -int matching_state(); -int pack_vector(); - -extern void berror(); -extern void fatals(); -extern char *int_to_string(); -extern void reader_output_yylsp(); +extern int lineno; + +void output_headers PARAMS((void)); +void output_trailers PARAMS((void)); +void output PARAMS((void)); +void output_token_translations PARAMS((void)); +void output_gram PARAMS((void)); +void output_stos PARAMS((void)); +void output_rule_data PARAMS((void)); +void output_defines PARAMS((void)); +void output_actions PARAMS((void)); +void token_actions PARAMS((void)); +void save_row PARAMS((int)); +void goto_actions PARAMS((void)); +void save_column PARAMS((int, int)); +void sort_actions PARAMS((void)); +void pack_table PARAMS((void)); +void output_base PARAMS((void)); +void output_table PARAMS((void)); +void output_check PARAMS((void)); +void output_parser PARAMS((void)); +void output_program PARAMS((void)); +void free_shifts PARAMS((void)); +void free_reductions PARAMS((void)); +void free_itemsets PARAMS((void)); +int action_row PARAMS((int)); +int default_goto PARAMS((int)); +int matching_state PARAMS((int)); +int pack_vector PARAMS((int)); + +extern void berror PARAMS((char *)); +extern void fatals PARAMS((char *, char *)); +extern char *int_to_string PARAMS((int)); +extern void reader_output_yylsp PARAMS((FILE *)); static int nvectors; static int nentries; @@ -197,7 +200,7 @@ register YYLTYPE *yylsp;\n{\n switch (n)\n{" void -output_headers() +output_headers (void) { if (semantic_parser) fprintf(fguard, GUARDSTR, attrsfile); @@ -226,7 +229,7 @@ output_headers() void -output_trailers() +output_trailers (void) { if (semantic_parser) fprintf(fguard, "\n }\n}\n"); @@ -243,7 +246,7 @@ output_trailers() void -output() +output (void) { int c; @@ -286,7 +289,7 @@ output() void -output_token_translations() +output_token_translations (void) { register int i, j; /* register short *sp; JF unused */ @@ -330,7 +333,7 @@ output_token_translations() void -output_gram() +output_gram (void) { register int i; register int j; @@ -395,7 +398,7 @@ output_gram() void -output_stos() +output_stos (void) { register int i; register int j; @@ -425,7 +428,7 @@ output_stos() void -output_rule_data() +output_rule_data (void) { register int i; register int j; @@ -600,7 +603,7 @@ output_rule_data() void -output_defines() +output_defines (void) { fprintf(ftable, "\n\n#define\tYYFINAL\t\t%d\n", final_state); fprintf(ftable, "#define\tYYFLAG\t\t%d\n", MINSHORT); @@ -612,7 +615,7 @@ output_defines() /* compute and output yydefact, yydefgoto, yypact, yypgoto, yytable and yycheck. */ void -output_actions() +output_actions (void) { nvectors = nstates + nvars; @@ -649,7 +652,7 @@ output_actions() is saved for putting into yytable later. */ void -token_actions() +token_actions (void) { register int i; register int j; @@ -699,8 +702,7 @@ token_actions() a token gets to handle it. */ int -action_row(state) -int state; +action_row (int state) { register int i; register int j; @@ -863,8 +865,7 @@ int state; void -save_row(state) -int state; +save_row (int state) { register int i; register int count; @@ -908,7 +909,7 @@ int state; is saved for putting into yytable later. */ void -goto_actions() +goto_actions (void) { register int i; register int j; @@ -947,8 +948,7 @@ goto_actions() int -default_goto(symbol) -int symbol; +default_goto (int symbol) { register int i; register int m; @@ -985,9 +985,7 @@ int symbol; void -save_column(symbol, default_state) -int symbol; -int default_state; +save_column (int symbol, int default_state) { register int i; register int m; @@ -1035,7 +1033,7 @@ int default_state; the actions and gotos information into yytable. */ void -sort_actions() +sort_actions (void) { register int i; register int j; @@ -1071,7 +1069,7 @@ sort_actions() void -pack_table() +pack_table (void) { register int i; register int place; @@ -1120,8 +1118,7 @@ pack_table() int -matching_state(vector) -int vector; +matching_state (int vector) { register int i; register int j; @@ -1161,8 +1158,7 @@ int vector; int -pack_vector(vector) -int vector; +pack_vector (int vector) { register int i; register int j; @@ -1231,7 +1227,7 @@ int vector; and the vectors whose elements index the portion starts */ void -output_base() +output_base (void) { register int i; register int j; @@ -1282,7 +1278,7 @@ output_base() void -output_table() +output_table (void) { register int i; register int j; @@ -1314,7 +1310,7 @@ output_table() void -output_check() +output_check (void) { register int i; register int j; @@ -1348,7 +1344,7 @@ output_check() /* copy the parser code into the ftable file at the end. */ void -output_parser() +output_parser (void) { register int c; #ifdef DONTDEF @@ -1407,7 +1403,7 @@ output_parser() /* now write out the line... */ for (; c != '\n' && c != EOF; c = getc(fpars)) - if (write_line) + if (write_line) { if (c == '$') { /* `$' in the parser file indicates where to put the actions. @@ -1418,6 +1414,7 @@ output_parser() } else putc(c, ftable); + } if (c == EOF) break; putc(c, ftable); @@ -1425,10 +1422,9 @@ output_parser() } void -output_program() +output_program (void) { register int c; - extern int lineno; if (!nolinesflag) fprintf(ftable, "#line %d \"%s\"\n", lineno, infile); @@ -1443,7 +1439,7 @@ output_program() void -free_itemsets() +free_itemsets (void) { register core *cp,*cptmp; @@ -1457,7 +1453,7 @@ free_itemsets() void -free_shifts() +free_shifts (void) { register shifts *sp,*sptmp;/* JF derefrenced freed ptr */ @@ -1471,7 +1467,7 @@ free_shifts() void -free_reductions() +free_reductions (void) { register reductions *rp,*rptmp;/* JF fixed freed ptr */ diff --git a/src/print.c b/src/print.c index f6817223..3ea8b425 100644 --- a/src/print.c +++ b/src/print.c @@ -39,18 +39,20 @@ extern char any_conflicts; extern char *conflicts; extern int final_state; -extern void conflict_log(); -extern void verbose_conflict_log(); -extern void print_reductions(); - -void print_token(); -void print_state(); -void print_core(); -void print_actions(); -void print_grammar(); +extern void conflict_log PARAMS((void)); +extern void verbose_conflict_log PARAMS((void)); +extern void print_reductions PARAMS((int)); + +void terse PARAMS((void)); +void verbose PARAMS((void)); +void print_token PARAMS((int, int)); +void print_state PARAMS((int)); +void print_core PARAMS((int)); +void print_actions PARAMS((int)); +void print_grammar PARAMS((void)); void -terse() +terse (void) { if (any_conflicts) { @@ -60,7 +62,7 @@ terse() void -verbose() +verbose (void) { register int i; @@ -77,16 +79,14 @@ verbose() void -print_token(extnum, token) -int extnum, token; +print_token (int extnum, int token) { fprintf(foutput, _(" type %d is %s\n"), extnum, tags[token]); } void -print_state(state) -int state; +print_state (int state) { fprintf(foutput, _("\n\nstate %d\n\n"), state); print_core(state); @@ -95,8 +95,7 @@ int state; void -print_core(state) -int state; +print_core (int state) { register int i; register int k; @@ -142,8 +141,7 @@ int state; void -print_actions(state) -int state; +print_actions (int state) { register int i; register int k; @@ -243,7 +241,7 @@ int state; else void -print_grammar() +print_grammar (void) { int i, j; short* rule; diff --git a/src/reduce.c b/src/reduce.c index 201864de..6d811252 100644 --- a/src/reduce.c +++ b/src/reduce.c @@ -39,6 +39,7 @@ the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */ 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,22 @@ 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(); +bool bits_equal PARAMS((BSet, BSet, int)); +int nbits PARAMS((unsigned)); +int bits_size PARAMS((BSet, int)); +void reduce_grammar PARAMS((void)); +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)); +void dump_grammar PARAMS((void)); -extern void fatals (); +extern void fatals PARAMS((char *, char *)); bool -bits_equal (L, R, n) -BSet L; -BSet R; -int n; +bits_equal (BSet L, BSet R, int n) { int i; @@ -87,8 +89,7 @@ int n; int -nbits (i) -unsigned i; +nbits (unsigned i) { int count = 0; @@ -101,9 +102,7 @@ unsigned i; int -bits_size (S, n) -BSet S; -int n; +bits_size (BSet S, int n) { int i, count = 0; @@ -113,7 +112,7 @@ int n; } void -reduce_grammar () +reduce_grammar (void) { bool reduced; @@ -169,14 +168,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 +185,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 +194,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 +251,7 @@ useless_nonterminals () } static void -inaccessable_symbols () +inaccessable_symbols (void) { BSet Vp, Vs, Pp; int i, n; @@ -353,7 +350,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 +479,7 @@ reduce_grammar_tables () } static void -print_results () +print_results (void) { int i; /* short j; JF unused */ @@ -532,7 +529,7 @@ print_results () } void -dump_grammar () +dump_grammar (void) { int i; rule r; @@ -569,10 +566,8 @@ dump_grammar () 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); diff --git a/src/symtab.c b/src/symtab.c index 6f325fc3..5dc1ccf0 100644 --- a/src/symtab.c +++ b/src/symtab.c @@ -29,11 +29,12 @@ bucket **symtab; bucket *firstsymbol; bucket *lastsymbol; +void tabinit PARAMS((void)); +void free_symtab PARAMS((void)); -int -hash(key) -char *key; +static int +hash (char *key) { register char *cp; register int k; @@ -48,9 +49,8 @@ char *key; -char * -copys(s) -char *s; +static char * +copys (char *s) { register int i; register char *cp; @@ -67,7 +67,7 @@ char *s; void -tabinit() +tabinit (void) { /* register int i; JF unused */ @@ -79,8 +79,7 @@ tabinit() bucket * -getsym(key) -char *key; +getsym (char *key) { register int hashval; register bucket *bp; @@ -127,7 +126,7 @@ char *key; void -free_symtab() +free_symtab (void) { register int i; register bucket *bp,*bptmp;/* JF don't use ptr after free */ diff --git a/src/symtab.h b/src/symtab.h index f515721d..142587c9 100644 --- a/src/symtab.h +++ b/src/symtab.h @@ -53,4 +53,4 @@ typedef extern bucket **symtab; extern bucket *firstsymbol; -extern bucket *getsym(); +extern bucket *getsym PARAMS((char *)); diff --git a/src/warshall.c b/src/warshall.c index 65487cbf..dc2e3ac5 100644 --- a/src/warshall.c +++ b/src/warshall.c @@ -22,14 +22,14 @@ the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */ #include "system.h" #include "machine.h" +void RTC PARAMS((unsigned *, int)); + /* given n by n matrix of bits R, modify its contents to be the transive closure of what was given. */ -void -TC(R, n) -unsigned *R; -int n; +static void +TC (unsigned *R, int n) { register int rowsize; register unsigned mask; @@ -87,9 +87,7 @@ int n; and then set all the bits on the diagonal of R. */ void -RTC(R, n) -unsigned *R; -int n; +RTC (unsigned *R, int n) { register int rowsize; register unsigned mask; -- 2.45.2