More explicit use of "const", "extern", and "static", particularly to

limit the scope of many local variables and functions.
This commit is contained in:
Jesse Thilo
2000-07-04 03:29:02 +00:00
parent 27821bff0f
commit 4a120d45e6
20 changed files with 345 additions and 298 deletions

View File

@@ -42,20 +42,20 @@ core *first_state;
shifts *first_shift; shifts *first_shift;
reductions *first_reduction; reductions *first_reduction;
int get_state PARAMS((int)); extern void generate_states PARAMS((void));
core *new_state PARAMS((int));
void allocate_itemsets PARAMS((void)); static int get_state PARAMS((int));
void allocate_storage PARAMS((void)); static core *new_state PARAMS((int));
void free_storage PARAMS((void)); static void allocate_itemsets PARAMS((void));
void generate_states PARAMS((void)); static void allocate_storage PARAMS((void));
void new_itemsets PARAMS((void)); static void free_storage PARAMS((void));
void append_states PARAMS((void)); static void new_itemsets PARAMS((void));
void initialize_states PARAMS((void)); static void append_states PARAMS((void));
void save_shifts PARAMS((void)); static void initialize_states PARAMS((void));
void save_reductions PARAMS((void)); static void save_shifts PARAMS((void));
void augment_automaton PARAMS((void)); static void save_reductions PARAMS((void));
void insert_start_shift PARAMS((void)); static void augment_automaton PARAMS((void));
static void insert_start_shift PARAMS((void));
extern void initialize_closure PARAMS((int)); extern void initialize_closure PARAMS((int));
extern void closure PARAMS((short *, int)); extern void closure PARAMS((short *, int));
extern void finalize_closure PARAMS((void)); extern void finalize_closure PARAMS((void));
@@ -82,7 +82,7 @@ static core **state_table;
void static void
allocate_itemsets (void) allocate_itemsets (void)
{ {
register short *itemp; register short *itemp;
@@ -127,7 +127,7 @@ allocate_itemsets (void)
} }
void static void
allocate_storage (void) allocate_storage (void)
{ {
allocate_itemsets(); allocate_itemsets();
@@ -138,7 +138,7 @@ allocate_storage (void)
} }
void static void
free_storage (void) free_storage (void)
{ {
FREE(shift_symbol); FREE(shift_symbol);
@@ -200,7 +200,7 @@ generate_states (void)
For each symbol in the grammar, kernel_base[symbol] points to For each symbol in the grammar, kernel_base[symbol] points to
a vector of item numbers activated if that symbol is shifted, a vector of item numbers activated if that symbol is shifted,
and kernel_end[symbol] points after the end of that vector. */ and kernel_end[symbol] points after the end of that vector. */
void static void
new_itemsets (void) new_itemsets (void)
{ {
register int i; register int i;
@@ -248,7 +248,7 @@ new_itemsets (void)
reached by each shift transition from the current state. reached by each shift transition from the current state.
shiftset is set up as a vector of state numbers of those states. */ shiftset is set up as a vector of state numbers of those states. */
void static void
append_states (void) append_states (void)
{ {
register int i; register int i;
@@ -287,7 +287,7 @@ append_states (void)
Create a new state if no equivalent one exists already. Create a new state if no equivalent one exists already.
Used by append_states */ Used by append_states */
int static int
get_state (int symbol) get_state (int symbol)
{ {
register int key; register int key;
@@ -360,7 +360,7 @@ get_state (int symbol)
/* subroutine of get_state. create a new state for those items, if necessary. */ /* subroutine of get_state. create a new state for those items, if necessary. */
core * static core *
new_state (int symbol) new_state (int symbol)
{ {
register int n; register int n;
@@ -398,7 +398,7 @@ new_state (int symbol)
} }
void static void
initialize_states (void) initialize_states (void)
{ {
register core *p; register core *p;
@@ -412,7 +412,7 @@ initialize_states (void)
} }
void static void
save_shifts (void) save_shifts (void)
{ {
register shifts *p; register shifts *p;
@@ -449,7 +449,7 @@ save_shifts (void)
/* find which rules can be used for reduction transitions from the current state /* 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. */ and make a reductions structure for the state to record their rule numbers. */
void static void
save_reductions (void) save_reductions (void)
{ {
register short *isp; register short *isp;
@@ -510,7 +510,7 @@ grammar's start symbol and goes to the next-to-final state,
which has a shift going to the final state, which has a shift which has a shift going to the final state, which has a shift
to the termination state. to the termination state.
Create such states and shifts if they don't happen to exist already. */ Create such states and shifts if they don't happen to exist already. */
void static void
augment_automaton (void) augment_automaton (void)
{ {
register int i; register int i;
@@ -683,7 +683,7 @@ augment_automaton (void)
/* subroutine of augment_automaton. /* subroutine of augment_automaton.
Create the next-to-final state, to which a shift has already been made in Create the next-to-final state, to which a shift has already been made in
the initial state. */ the initial state. */
void static void
insert_start_shift (void) insert_start_shift (void)
{ {
register core *statep; register core *statep;

View File

@@ -38,8 +38,8 @@ extern char *realloc ();
#endif #endif
#endif /* NEED_DECLARATION_REALLOC */ #endif /* NEED_DECLARATION_REALLOC */
char *xmalloc PARAMS((register unsigned)); extern char *xmalloc PARAMS((register unsigned));
char *xrealloc PARAMS((register char *, register unsigned)); extern char *xrealloc PARAMS((register char *, register unsigned));
extern void done PARAMS((int)); extern void done PARAMS((int));

View File

@@ -59,11 +59,12 @@ Frees itemset, ruleset and internal data.
extern short **derives; extern short **derives;
extern char **tags; extern char **tags;
void initialize_closure PARAMS((int)); extern void initialize_closure PARAMS((int));
void set_fderives PARAMS((void)); extern void closure PARAMS((short *, int));
void set_firsts PARAMS((void)); extern void finalize_closure PARAMS((void));
void closure PARAMS((short *, int));
void finalize_closure PARAMS((void)); static void set_fderives PARAMS((void));
static void set_firsts PARAMS((void));
extern void RTC PARAMS((unsigned *, int)); extern void RTC PARAMS((unsigned *, int));
@@ -81,6 +82,11 @@ static int rulesetsize;
/* number of words required to hold a bit for each variable */ /* number of words required to hold a bit for each variable */
static int varsetsize; static int varsetsize;
#ifdef DEBUG
static void print_closure PARAMS((int));
static void print_fderives PARAMS((void));
static void print_firsts PARAMS((void));
#endif
void void
initialize_closure (int n) initialize_closure (int n)
@@ -100,7 +106,7 @@ initialize_closure (int n)
for each nonterminal. For example, if symbol 5 can be derived as for each nonterminal. For example, if symbol 5 can be derived as
the sequence of symbols 8 3 20, and one of the rules for deriving 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. */ symbol 8 is rule 4, then the [5 - ntokens, 4] bit in fderives is set. */
void static void
set_fderives (void) set_fderives (void)
{ {
register unsigned *rrow; register unsigned *rrow;
@@ -164,7 +170,7 @@ set_fderives (void)
symbol 5, so the bit [8 - ntokens, 5 - ntokens] in firsts is symbol 5, so the bit [8 - ntokens, 5 - ntokens] in firsts is
set. */ set. */
void static void
set_firsts (void) set_firsts (void)
{ {
register unsigned *row; register unsigned *row;
@@ -298,8 +304,8 @@ finalize_closure (void)
#ifdef DEBUG #ifdef DEBUG
print_closure(n) static void
int n; print_closure(int n)
{ {
register short *isp; register short *isp;
@@ -309,7 +315,7 @@ int n;
} }
void static void
print_firsts (void) print_firsts (void)
{ {
register int i; register int i;
@@ -331,7 +337,7 @@ print_firsts (void)
} }
void static void
print_fderives (void) print_fderives (void)
{ {
register int i; register int i;

View File

@@ -90,7 +90,7 @@ warn (message, va_alist)
if (error_one_per_line) if (error_one_per_line)
{ {
static const char *old_infile; static const char *old_infile;
static unsigned int old_lineno; static int old_lineno;
if (old_lineno == lineno && if (old_lineno == lineno &&
(infile == old_infile || !strcmp (old_infile, infile))) (infile == old_infile || !strcmp (old_infile, infile)))
@@ -142,7 +142,7 @@ complain (message, va_alist)
if (error_one_per_line) if (error_one_per_line)
{ {
static const char *old_infile; static const char *old_infile;
static unsigned int old_lineno; static int old_lineno;
if (old_lineno == lineno && if (old_lineno == lineno &&
(infile == old_infile || !strcmp (old_infile, infile))) (infile == old_infile || !strcmp (old_infile, infile)))

View File

@@ -38,23 +38,24 @@ extern short *lookaheads;
extern int verboseflag; extern int verboseflag;
extern int fixed_outfiles; extern int fixed_outfiles;
void initialize_conflicts PARAMS((void)); extern void initialize_conflicts PARAMS((void));
void set_conflicts PARAMS((int)); extern void conflict_log PARAMS((void));
void resolve_sr_conflict PARAMS((int, int)); extern void verbose_conflict_log PARAMS((void));
void flush_shift PARAMS((int, int)); extern void print_reductions PARAMS((int));
void log_resolution PARAMS((int, int, int, char *)); extern void finalize_conflicts PARAMS((void));
void conflict_log PARAMS((void));
void verbose_conflict_log PARAMS((void)); static void set_conflicts PARAMS((int));
void total_conflicts PARAMS((void)); static void resolve_sr_conflict PARAMS((int, int));
void count_sr_conflicts PARAMS((int)); static void flush_shift PARAMS((int, int));
void count_rr_conflicts PARAMS((int)); static void log_resolution PARAMS((int, int, int, char *));
void print_reductions PARAMS((int)); static void total_conflicts PARAMS((void));
void finalize_conflicts PARAMS((void)); static void count_sr_conflicts PARAMS((int));
static void count_rr_conflicts PARAMS((int));
char any_conflicts; char any_conflicts;
char *conflicts;
errs **err_table; errs **err_table;
int expected_conflicts; int expected_conflicts;
static char *conflicts;
static unsigned *shiftset; static unsigned *shiftset;
@@ -84,7 +85,7 @@ initialize_conflicts (void)
} }
void static void
set_conflicts (int state) set_conflicts (int state)
{ {
register int i; register int i;
@@ -170,7 +171,7 @@ It has already been checked that the rule has a precedence.
A conflict is resolved by modifying the shift or reduce tables A conflict is resolved by modifying the shift or reduce tables
so that there is no longer a conflict. */ so that there is no longer a conflict. */
void static void
resolve_sr_conflict (int state, int lookaheadnum) resolve_sr_conflict (int state, int lookaheadnum)
{ {
register int i; register int i;
@@ -271,7 +272,7 @@ resolve_sr_conflict (int state, int lookaheadnum)
/* turn off the shift recorded for the specified token in the specified state. /* turn off the shift recorded for the specified token in the specified state.
Used when we resolve a shift-reduce conflict in favor of the reduction. */ Used when we resolve a shift-reduce conflict in favor of the reduction. */
void static void
flush_shift (int state, int token) flush_shift (int state, int token)
{ {
register shifts *shiftp; register shifts *shiftp;
@@ -292,7 +293,7 @@ flush_shift (int state, int token)
} }
void static void
log_resolution (int state, int LAno, int token, char *resolution) log_resolution (int state, int LAno, int token, char *resolution)
{ {
fprintf(foutput, fprintf(foutput,
@@ -365,7 +366,7 @@ verbose_conflict_log (void)
} }
void static void
total_conflicts (void) total_conflicts (void)
{ {
if (src_total == expected_conflicts && rrc_total == 0) if (src_total == expected_conflicts && rrc_total == 0)
@@ -407,7 +408,7 @@ total_conflicts (void)
} }
void static void
count_sr_conflicts (int state) count_sr_conflicts (int state)
{ {
register int i; register int i;
@@ -474,7 +475,7 @@ count_sr_conflicts (int state)
} }
void static void
count_rr_conflicts (int state) count_rr_conflicts (int state)
{ {
register int i; register int i;

View File

@@ -30,8 +30,13 @@ Boston, MA 02111-1307, USA. */
#include "types.h" #include "types.h"
#include "gram.h" #include "gram.h"
void set_derives PARAMS((void)); extern void set_derives PARAMS((void));
void free_derives PARAMS((void)); extern void free_derives PARAMS((void));
#if DEBUG
static void print_derives PARAMS((void));
extern char **tags;
#endif
short **derives; short **derives;
@@ -95,14 +100,12 @@ free_derives (void)
#ifdef DEBUG #ifdef DEBUG
void static void
print_derives (void) print_derives (void)
{ {
register int i; register int i;
register short *sp; register short *sp;
extern char **tags;
printf(_("\n\n\nDERIVES\n\n")); printf(_("\n\n\nDERIVES\n\n"));
for (i = ntokens; i < nsyms; i++) for (i = ntokens; i < nsyms; i++)

View File

@@ -65,40 +65,44 @@ FILE *fparser = NULL;
char *spec_outfile; char *spec_outfile;
char *infile; char *infile;
char *outfile;
char *defsfile;
char *tabfile;
char *attrsfile; char *attrsfile;
char *guardfile;
char *actfile; static char *outfile;
char *tmpattrsfile; static char *defsfile;
char *tmptabfile; static char *tabfile;
char *tmpdefsfile; static char *guardfile;
static char *actfile;
static char *tmpattrsfile;
static char *tmptabfile;
static char *tmpdefsfile;
extern int noparserflag; extern int noparserflag;
extern char *mktemp(); /* So the compiler won't complain */ extern char *mktemp(); /* So the compiler won't complain */
extern char *getenv(); extern char *getenv();
char *stringappend PARAMS((char *, int, char *)); extern char *stringappend PARAMS((const char *, int, const char *));
void openfiles PARAMS((void)); extern void openfiles PARAMS((void));
void open_extra_files PARAMS((void)); extern void open_extra_files PARAMS((void));
int fixed_outfiles = 0;
extern char *program_name; extern char *program_name;
extern int verboseflag; extern int verboseflag;
extern int definesflag; extern int definesflag;
int fixed_outfiles = 0;
char * char *
stringappend (char *string1, int end1, char *string2) stringappend (const char *string1, int end1, const char *string2)
{ {
register char *ostring; register char *ostring;
register char *cp, *cp1; register char *cp;
register const char *cp1;
register int i; register int i;
cp = string2; i = 0; cp1 = string2;
while (*cp++) i++; i = 0;
while (*cp1++) i++;
ostring = NEW2(i+end1+1, char); ostring = NEW2(i+end1+1, char);
@@ -120,7 +124,7 @@ stringappend (char *string1, int end1, char *string2)
`-----------------------------------------------------------------*/ `-----------------------------------------------------------------*/
static FILE * static FILE *
tryopen (char *name, char *mode) tryopen (const char *name, const char *mode)
{ {
FILE *ptr; FILE *ptr;
@@ -164,9 +168,9 @@ openfiles (void)
int short_base_length; int short_base_length;
#if defined (VMS) & !defined (__VMS_POSIX) #if defined (VMS) & !defined (__VMS_POSIX)
char *tmp_base = "sys$scratch:b_"; const char *tmp_base = "sys$scratch:b_";
#else #else
char *tmp_base = "/tmp/b."; const char *tmp_base = "/tmp/b.";
#endif #endif
int tmp_len; int tmp_len;
@@ -240,7 +244,9 @@ openfiles (void)
/* -o was not specified; compute output file name from input /* -o was not specified; compute output file name from input
or use y.tab.c, etc., if -y was specified. */ or use y.tab.c, etc., if -y was specified. */
name_base = fixed_outfiles ? "y.y" : infile; static char FIXED_NAME_BASE[] = "y.y";
name_base = fixed_outfiles ? FIXED_NAME_BASE : infile;
/* BASE_LENGTH gets length of NAME_BASE, sans ".y" suffix if any. */ /* BASE_LENGTH gets length of NAME_BASE, sans ".y" suffix if any. */

View File

@@ -53,4 +53,4 @@ extern char *attrsfile;
extern char *guardfile; extern char *guardfile;
extern char *actfile; extern char *actfile;
void done PARAMS((void)); extern void done PARAMS((void));

View File

@@ -37,8 +37,10 @@ extern int fixed_outfiles;/* for -y */
extern char *program_name; extern char *program_name;
extern void warns PARAMS((char *, char *)); /* main.c */ extern void warns PARAMS((char *, char *)); /* main.c */
static void usage PARAMS((FILE *));
extern void getargs PARAMS((int argc, char *[]));
struct option longopts[] = static struct option longopts[] =
{ {
{"debug", 0, &debugflag, 1}, {"debug", 0, &debugflag, 1},
{"defines", 0, &definesflag, 1}, {"defines", 0, &definesflag, 1},
@@ -61,7 +63,7 @@ struct option longopts[] =
/*---------------------------. /*---------------------------.
| Display the help message. | | Display the help message. |
`---------------------------*/ `---------------------------*/
void static void
usage (FILE *stream) usage (FILE *stream)
{ {
/* Some efforts were made to ease the translators' task, please /* Some efforts were made to ease the translators' task, please

View File

@@ -19,6 +19,10 @@ the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA. */ Boston, MA 02111-1307, USA. */
#include "system.h"
void dummy PARAMS((void));
/* comments for these variables are in gram.h */ /* comments for these variables are in gram.h */
int nitems; int nitems;

View File

@@ -74,25 +74,26 @@ short *goto_map;
short *from_state; short *from_state;
short *to_state; short *to_state;
void lalr PARAMS((void)); extern 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 berror PARAMS((char *)); static short **transpose PARAMS((short **, int));
static void set_state_table PARAMS((void));
static void set_accessing_symbol PARAMS((void));
static void set_shift_table PARAMS((void));
static void set_reduction_table PARAMS((void));
static void set_maxrhs PARAMS((void));
static void initialize_LA PARAMS((void));
static void set_goto_map PARAMS((void));
static int map_goto PARAMS((int, int));
static void initialize_F PARAMS((void));
static void build_relations PARAMS((void));
static void add_lookback_edge PARAMS((int, int, int));
static void compute_FOLLOWS PARAMS((void));
static void compute_lookaheads PARAMS((void));
static void digraph PARAMS((short **));
static void traverse PARAMS((register int));
extern void berror PARAMS((const char *));
static int infinity; static int infinity;
static int maxrhs; static int maxrhs;
@@ -125,7 +126,7 @@ lalr (void)
} }
void static void
set_state_table (void) set_state_table (void)
{ {
register core *sp; register core *sp;
@@ -137,7 +138,7 @@ set_state_table (void)
} }
void static void
set_accessing_symbol (void) set_accessing_symbol (void)
{ {
register core *sp; register core *sp;
@@ -149,7 +150,7 @@ set_accessing_symbol (void)
} }
void static void
set_shift_table (void) set_shift_table (void)
{ {
register shifts *sp; register shifts *sp;
@@ -161,7 +162,7 @@ set_shift_table (void)
} }
void static void
set_reduction_table (void) set_reduction_table (void)
{ {
register reductions *rp; register reductions *rp;
@@ -173,7 +174,7 @@ set_reduction_table (void)
} }
void static void
set_maxrhs (void) set_maxrhs (void)
{ {
register short *itemp; register short *itemp;
@@ -199,7 +200,7 @@ set_maxrhs (void)
} }
void static void
initialize_LA (void) initialize_LA (void)
{ {
register int i; register int i;
@@ -266,7 +267,7 @@ initialize_LA (void)
} }
void static void
set_goto_map (void) set_goto_map (void)
{ {
register shifts *sp; register shifts *sp;
@@ -336,7 +337,7 @@ set_goto_map (void)
/* Map_goto maps a state/symbol pair into its numeric representation. */ /* Map_goto maps a state/symbol pair into its numeric representation. */
int static int
map_goto (int state, int symbol) map_goto (int state, int symbol)
{ {
register int high; register int high;
@@ -365,7 +366,7 @@ map_goto (int state, int symbol)
} }
void static void
initialize_F (void) initialize_F (void)
{ {
register int i; register int i;
@@ -441,7 +442,7 @@ initialize_F (void)
} }
void static void
build_relations (void) build_relations (void)
{ {
register int i; register int i;
@@ -536,7 +537,7 @@ build_relations (void)
} }
void static void
add_lookback_edge (int stateno, int ruleno, int gotono) add_lookback_edge (int stateno, int ruleno, int gotono)
{ {
register int i; register int i;
@@ -566,7 +567,7 @@ add_lookback_edge (int stateno, int ruleno, int gotono)
short ** static short **
transpose (short **R_arg, int n) transpose (short **R_arg, int n)
{ {
register short **new_R; register short **new_R;
@@ -621,7 +622,7 @@ transpose (short **R_arg, int n)
} }
void static void
compute_FOLLOWS (void) compute_FOLLOWS (void)
{ {
register int i; register int i;
@@ -637,7 +638,7 @@ compute_FOLLOWS (void)
} }
void static void
compute_lookaheads (void) compute_lookaheads (void)
{ {
register int i; register int i;
@@ -680,7 +681,7 @@ compute_lookaheads (void)
} }
void static void
digraph (short **relation) digraph (short **relation)
{ {
register int i; register int i;
@@ -706,7 +707,7 @@ digraph (short **relation)
} }
void static void
traverse (register int i) traverse (register int i)
{ {
register unsigned *fp1; register unsigned *fp1;

View File

@@ -50,14 +50,15 @@ extern char *spec_file_prefix; /* for -b */
extern int translations; extern int translations;
void init_lex PARAMS((void)); extern void init_lex PARAMS((void));
char *grow_token_buffer PARAMS((char *)); extern char *grow_token_buffer PARAMS((char *));
int skip_white_space PARAMS((void)); extern int skip_white_space PARAMS((void));
int safegetc PARAMS((FILE *)); extern void unlex PARAMS((int));
int literalchar PARAMS((char **, int *, char)); extern int lex PARAMS((void));
void unlex PARAMS((int)); extern int parse_percent_token PARAMS((void));
int lex PARAMS((void));
int parse_percent_token PARAMS((void)); static int safegetc PARAMS((FILE *));
static int literalchar PARAMS((char **, int *, char));
/* functions from main.c */ /* functions from main.c */
extern char *printable_version PARAMS((int)); extern char *printable_version PARAMS((int));
@@ -164,7 +165,7 @@ skip_white_space (void)
} }
/* do a getc, but give error message if EOF encountered */ /* do a getc, but give error message if EOF encountered */
int static int
safegetc (FILE *f) safegetc (FILE *f)
{ {
register int c = getc(f); register int c = getc(f);
@@ -179,7 +180,7 @@ safegetc (FILE *f)
return 1 unless the character is an unescaped `term' or \n return 1 unless the character is an unescaped `term' or \n
report error for \n report error for \n
*/ */
int static int
literalchar (char **pp, int *pcode, char term) literalchar (char **pp, int *pcode, char term)
{ {
register int c; register int c;
@@ -501,7 +502,7 @@ lex (void)
set. A retval action returns the code. set. A retval action returns the code.
*/ */
struct percent_table_struct { struct percent_table_struct {
char *name; const char *name;
void *setflag; void *setflag;
int retval; int retval;
} percent_table[] = } percent_table[] =

View File

@@ -27,25 +27,28 @@
extern int verboseflag; extern int verboseflag;
#if 0 /* XXX currently unused. */
/* Nonzero means failure has been detected; don't write a parser file. */ /* Nonzero means failure has been detected; don't write a parser file. */
int failure; static int failure;
#endif
/* The name this program was run with, for messages. */ /* The name this program was run with, for messages. */
char *program_name; char *program_name;
char *printable_version PARAMS((int)); extern char *printable_version PARAMS((int));
void toomany PARAMS((char *)); extern void berror PARAMS((const char *));
void berror PARAMS((char *));
extern void getargs PARAMS((int, char *[])); extern void getargs PARAMS((int, char *[]));
extern void openfiles PARAMS((void)); extern void openfiles PARAMS((void));
extern void reader PARAMS((void)); extern void reader PARAMS((void));
extern void reduce_grammar PARAMS((void)); extern void reduce_grammar PARAMS((void));
extern void set_derives PARAMS((void)); extern void set_derives PARAMS((void));
extern void free_derives PARAMS((void));
extern void set_nullable PARAMS((void)); extern void set_nullable PARAMS((void));
extern void generate_states PARAMS((void)); extern void generate_states PARAMS((void));
extern void lalr PARAMS((void)); extern void lalr PARAMS((void));
extern void initialize_conflicts PARAMS((void)); extern void initialize_conflicts PARAMS((void));
extern void finalize_conflicts PARAMS((void));
extern void verbose PARAMS((void)); extern void verbose PARAMS((void));
extern void terse PARAMS((void)); extern void terse PARAMS((void));
extern void output PARAMS((void)); extern void output PARAMS((void));
@@ -105,6 +108,9 @@ main (int argc, char *argv[])
/* output the tables and the parser to ftable. In file output. */ /* output the tables and the parser to ftable. In file output. */
output(); output();
finalize_conflicts();
free_derives();
exit (complain_message_count ? 1 : 0); exit (complain_message_count ? 1 : 0);
} }
@@ -131,7 +137,7 @@ printable_version (int c)
/* Abort for an internal error denoted by string S. */ /* Abort for an internal error denoted by string S. */
void void
berror (char *s) berror (const char *s)
{ {
fprintf (stderr, _("%s: internal error: %s\n"), program_name, s); fprintf (stderr, _("%s: internal error: %s\n"), program_name, s);
abort(); abort();

View File

@@ -31,8 +31,8 @@ Boston, MA 02111-1307, USA. */
char *nullable; char *nullable;
void free_nullable PARAMS((void)); extern void free_nullable PARAMS((void));
void set_nullable PARAMS((void)); extern void set_nullable PARAMS((void));
void void
set_nullable (void) set_nullable (void)

View File

@@ -135,35 +135,36 @@ extern short *goto_map;
extern short *from_state; extern short *from_state;
extern short *to_state; extern short *to_state;
void output_headers PARAMS((void)); extern void output_headers PARAMS((void));
void output_trailers PARAMS((void)); extern void output_trailers PARAMS((void));
void output PARAMS((void)); extern 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 *)); static void output_token_translations PARAMS((void));
static void output_gram PARAMS((void));
static void output_stos PARAMS((void));
static void output_rule_data PARAMS((void));
static void output_defines PARAMS((void));
static void output_actions PARAMS((void));
static void token_actions PARAMS((void));
static void save_row PARAMS((int));
static void goto_actions PARAMS((void));
static void save_column PARAMS((int, int));
static void sort_actions PARAMS((void));
static void pack_table PARAMS((void));
static void output_base PARAMS((void));
static void output_table PARAMS((void));
static void output_check PARAMS((void));
static void output_parser PARAMS((void));
static void output_program PARAMS((void));
static void free_shifts PARAMS((void));
static void free_reductions PARAMS((void));
static void free_itemsets PARAMS((void));
static int action_row PARAMS((int));
static int default_goto PARAMS((int));
static int matching_state PARAMS((int));
static int pack_vector PARAMS((int));
extern void berror PARAMS((const char *));
extern void reader_output_yylsp PARAMS((FILE *)); extern void reader_output_yylsp PARAMS((FILE *));
static int nvectors; static int nvectors;
@@ -287,7 +288,7 @@ output (void)
} }
void static void
output_token_translations (void) output_token_translations (void)
{ {
register int i, j; register int i, j;
@@ -331,7 +332,7 @@ output_token_translations (void)
} }
void static void
output_gram (void) output_gram (void)
{ {
register int i; register int i;
@@ -396,7 +397,7 @@ output_gram (void)
} }
void static void
output_stos (void) output_stos (void)
{ {
register int i; register int i;
@@ -426,7 +427,7 @@ output_stos (void)
} }
void static void
output_rule_data (void) output_rule_data (void)
{ {
register int i; register int i;
@@ -612,7 +613,7 @@ static const short yyr2[] = { 0", ftable);
} }
void static void
output_defines (void) output_defines (void)
{ {
fprintf(ftable, "\n\n#define\tYYFINAL\t\t%d\n", final_state); fprintf(ftable, "\n\n#define\tYYFINAL\t\t%d\n", final_state);
@@ -624,7 +625,7 @@ output_defines (void)
/* compute and output yydefact, yydefgoto, yypact, yypgoto, yytable and yycheck. */ /* compute and output yydefact, yydefgoto, yypact, yypgoto, yytable and yycheck. */
void static void
output_actions (void) output_actions (void)
{ {
nvectors = nstates + nvars; nvectors = nstates + nvars;
@@ -662,7 +663,7 @@ output_actions (void)
The yydefact table is output now. The detailed info is saved for The yydefact table is output now. The detailed info is saved for
putting into yytable later. */ putting into yytable later. */
void static void
token_actions (void) token_actions (void)
{ {
register int i; register int i;
@@ -713,7 +714,7 @@ token_actions (void)
rules considered lower-numbered rules last, and the last rule rules considered lower-numbered rules last, and the last rule
considered that likes a token gets to handle it. */ considered that likes a token gets to handle it. */
int static int
action_row (int state) action_row (int state)
{ {
register int i; register int i;
@@ -882,7 +883,7 @@ action_row (int state)
} }
void static void
save_row (int state) save_row (int state)
{ {
register int i; register int i;
@@ -926,7 +927,7 @@ save_row (int state)
The yydefgoto table is output now. The detailed info The yydefgoto table is output now. The detailed info
is saved for putting into yytable later. */ is saved for putting into yytable later. */
void static void
goto_actions (void) goto_actions (void)
{ {
register int i; register int i;
@@ -965,7 +966,7 @@ goto_actions (void)
int static int
default_goto (int symbol) default_goto (int symbol)
{ {
register int i; register int i;
@@ -1002,7 +1003,7 @@ default_goto (int symbol)
} }
void static void
save_column (int symbol, int default_state) save_column (int symbol, int default_state)
{ {
register int i; register int i;
@@ -1050,7 +1051,7 @@ save_column (int symbol, int default_state)
/* The next few functions decide how to pack the actions and gotos /* The next few functions decide how to pack the actions and gotos
information into yytable. */ information into yytable. */
void static void
sort_actions (void) sort_actions (void)
{ {
register int i; register int i;
@@ -1086,7 +1087,7 @@ sort_actions (void)
} }
void static void
pack_table (void) pack_table (void)
{ {
register int i; register int i;
@@ -1135,7 +1136,7 @@ pack_table (void)
int static int
matching_state (int vector) matching_state (int vector)
{ {
register int i; register int i;
@@ -1175,7 +1176,7 @@ matching_state (int vector)
int static int
pack_vector (int vector) pack_vector (int vector)
{ {
register int i; register int i;
@@ -1244,7 +1245,7 @@ pack_vector (int vector)
/* the following functions output yytable, yycheck /* the following functions output yytable, yycheck
and the vectors whose elements index the portion starts */ and the vectors whose elements index the portion starts */
void static void
output_base (void) output_base (void)
{ {
register int i; register int i;
@@ -1295,7 +1296,7 @@ output_base (void)
} }
void static void
output_table (void) output_table (void)
{ {
register int i; register int i;
@@ -1327,7 +1328,7 @@ output_table (void)
} }
void static void
output_check (void) output_check (void)
{ {
register int i; register int i;
@@ -1361,7 +1362,7 @@ output_check (void)
/* copy the parser code into the ftable file at the end. */ /* copy the parser code into the ftable file at the end. */
void static void
output_parser (void) output_parser (void)
{ {
register int c; register int c;
@@ -1439,7 +1440,7 @@ output_parser (void)
} }
} }
void static void
output_program (void) output_program (void)
{ {
register int c; register int c;
@@ -1456,7 +1457,7 @@ output_program (void)
} }
void static void
free_itemsets (void) free_itemsets (void)
{ {
register core *cp,*cptmp; register core *cp,*cptmp;
@@ -1471,7 +1472,7 @@ free_itemsets (void)
} }
void static void
free_shifts (void) free_shifts (void)
{ {
register shifts *sp,*sptmp;/* JF derefrenced freed ptr */ register shifts *sp,*sptmp;/* JF derefrenced freed ptr */
@@ -1486,7 +1487,7 @@ free_shifts (void)
} }
void static void
free_reductions (void) free_reductions (void)
{ {
register reductions *rp,*rptmp;/* JF fixed freed ptr */ register reductions *rp,*rptmp;/* JF fixed freed ptr */

View File

@@ -44,13 +44,17 @@ extern void conflict_log PARAMS((void));
extern void verbose_conflict_log PARAMS((void)); extern void verbose_conflict_log PARAMS((void));
extern void print_reductions PARAMS((int)); extern void print_reductions PARAMS((int));
void terse PARAMS((void)); extern void terse PARAMS((void));
void verbose PARAMS((void)); extern void verbose PARAMS((void));
void print_token PARAMS((int, int));
void print_state PARAMS((int)); #if 0 /* XXX currently unused. */
void print_core PARAMS((int)); static void print_token PARAMS((int, int));
void print_actions PARAMS((int)); #endif
void print_grammar PARAMS((void));
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 void
terse (void) terse (void)
@@ -79,14 +83,16 @@ verbose (void)
} }
void #if 0 /* XXX currently unused. */
static void
print_token (int extnum, int token) print_token (int extnum, int token)
{ {
fprintf(foutput, _(" type %d is %s\n"), extnum, tags[token]); fprintf(foutput, _(" type %d is %s\n"), extnum, tags[token]);
} }
#endif
void static void
print_state (int state) print_state (int state)
{ {
fprintf(foutput, _("\n\nstate %d\n\n"), state); fprintf(foutput, _("\n\nstate %d\n\n"), state);
@@ -95,7 +101,7 @@ print_state (int state)
} }
void static void
print_core (int state) print_core (int state)
{ {
register int i; register int i;
@@ -141,7 +147,7 @@ print_core (int state)
} }
void static void
print_actions (int state) print_actions (int state)
{ {
register int i; register int i;
@@ -236,12 +242,16 @@ print_actions (int state)
} }
} }
#define END_TEST(end) \ #define END_TEST(end) \
if (column + strlen(buffer) > (end)) \ do { \
{ fprintf (foutput, "%s\n ", buffer); column = 3; buffer[0] = 0; } \ if (column + strlen(buffer) > (end)) { \
else fprintf (foutput, "%s\n ", buffer); \
column = 3; \
buffer[0] = 0; \
} \
} while (0)
void static void
print_grammar (void) print_grammar (void)
{ {
int i, j; int i, j;

View File

@@ -60,7 +60,7 @@ typedef\n\
\n" \n"
/* Number of slots allocated (but not necessarily used yet) in `rline' */ /* Number of slots allocated (but not necessarily used yet) in `rline' */
int rline_allocated; static int rline_allocated;
extern int definesflag; extern int definesflag;
extern int nolinesflag; extern int nolinesflag;
@@ -96,38 +96,39 @@ typedef
symbol_list; symbol_list;
void reader PARAMS((void)); extern void reader PARAMS((void));
void reader_output_yylsp PARAMS((FILE *)); extern void reader_output_yylsp PARAMS((FILE *));
void read_declarations PARAMS((void));
void copy_definition PARAMS((void)); static void read_declarations PARAMS((void));
void parse_token_decl PARAMS((int, int)); static void copy_definition PARAMS((void));
void parse_start_decl PARAMS((void)); static void parse_token_decl PARAMS((int, int));
void parse_type_decl PARAMS((void)); static void parse_start_decl PARAMS((void));
void parse_assoc_decl PARAMS((int)); static void parse_type_decl PARAMS((void));
void parse_union_decl PARAMS((void)); static void parse_assoc_decl PARAMS((int));
void parse_expect_decl PARAMS((void)); static void parse_union_decl PARAMS((void));
char *get_type_name PARAMS((int, symbol_list *)); static void parse_expect_decl PARAMS((void));
void copy_guard PARAMS((symbol_list *, int)); static char *get_type_name PARAMS((int, symbol_list *));
void parse_thong_decl PARAMS((void)); static void copy_guard PARAMS((symbol_list *, int));
void copy_action PARAMS((symbol_list *, int)); static void parse_thong_decl PARAMS((void));
bucket *gensym PARAMS((void)); static void copy_action PARAMS((symbol_list *, int));
void readgram PARAMS((void)); static bucket *gensym PARAMS((void));
void record_rule_line PARAMS((void)); static void readgram PARAMS((void));
void packsymbols PARAMS((void)); static void record_rule_line PARAMS((void));
void output_token_defines PARAMS((FILE *)); static void packsymbols PARAMS((void));
void packgram PARAMS((void)); static void output_token_defines PARAMS((FILE *));
int read_signed_integer PARAMS((FILE *)); static void packgram PARAMS((void));
static int read_signed_integer PARAMS((FILE *));
#if 0 #if 0
static int get_type PARAMS((void)); static int get_type PARAMS((void));
#endif #endif
int lineno; int lineno;
symbol_list *grammar;
int start_flag;
bucket *startval;
char **tags; char **tags;
int *user_toknums; int *user_toknums;
static symbol_list *grammar;
static int start_flag;
static bucket *startval;
/* Nonzero if components of semantic values are used, implying /* Nonzero if components of semantic values are used, implying
they must be unions. */ they must be unions. */
@@ -163,16 +164,16 @@ skip_to_char (int target)
} }
/* Dump the string from FINPUT to FOUTPUT. MATCH is the delimiter of /* Dump the string from FIN to FOUT. MATCH is the delimiter of
the string (either ' or "). */ the string (either ' or "). */
static inline void static inline void
copy_string (FILE *finput, FILE *foutput, int match) copy_string (FILE *fin, FILE *fout, int match)
{ {
int c; int c;
putc (match, foutput); putc (match, fout);
c = getc (finput); c = getc (fin);
while (c != match) while (c != match)
{ {
@@ -181,27 +182,27 @@ copy_string (FILE *finput, FILE *foutput, int match)
if (c == '\n') if (c == '\n')
{ {
complain (_("unterminated string")); complain (_("unterminated string"));
ungetc (c, finput); ungetc (c, fin);
c = match; /* invent terminator */ c = match; /* invent terminator */
continue; continue;
} }
putc(c, foutput); putc(c, fout);
if (c == '\\') if (c == '\\')
{ {
c = getc (finput); c = getc (fin);
if (c == EOF) if (c == EOF)
fatal (_("unterminated string at end of file")); fatal (_("unterminated string at end of file"));
putc (c, foutput); putc (c, fout);
if (c == '\n') if (c == '\n')
lineno++; lineno++;
} }
c = getc(finput); c = getc(fin);
} }
putc(c, foutput); putc(c, fout);
} }
@@ -265,13 +266,13 @@ copy_comment2 (FILE *in, FILE *out1, FILE* out2, int c)
} }
/* Dump the comment from FINPUT to FOUTPUT. C is either `*' or `/', /* Dump the comment from FIN to FOUT. C is either `*' or `/',
depending upon the type of comments used. */ depending upon the type of comments used. */
static inline void static inline void
copy_comment (FILE *finput, FILE *foutput, int c) copy_comment (FILE *fin, FILE *fout, int c)
{ {
copy_comment2 (finput, foutput, NULL, c); copy_comment2 (fin, fout, NULL, c);
} }
@@ -364,7 +365,7 @@ reader_output_yylsp (FILE *f)
`%' declarations, and copy the contents of any `%{ ... %}' groups `%' declarations, and copy the contents of any `%{ ... %}' groups
to fattrs. */ to fattrs. */
void static void
read_declarations (void) read_declarations (void)
{ {
register int c; register int c;
@@ -459,7 +460,7 @@ read_declarations (void)
/* Copy the contents of a `%{ ... %}' into the definitions file. The /* Copy the contents of a `%{ ... %}' into the definitions file. The
`%{' has already been read. Return after reading the `%}'. */ `%{' has already been read. Return after reading the `%}'. */
void static void
copy_definition (void) copy_definition (void)
{ {
register int c; register int c;
@@ -527,7 +528,7 @@ copy_definition (void)
For %token, what_is is STOKEN and what_is_not is SNTERM. For %token, what_is is STOKEN and what_is_not is SNTERM.
For %nterm, the arguments are reversed. */ For %nterm, the arguments are reversed. */
void static void
parse_token_decl (int what_is, int what_is_not) parse_token_decl (int what_is, int what_is_not)
{ {
register int token = 0; register int token = 0;
@@ -625,7 +626,7 @@ parse_token_decl (int what_is, int what_is_not)
it is the literal string that is output to yytname it is the literal string that is output to yytname
*/ */
void static void
parse_thong_decl (void) parse_thong_decl (void)
{ {
register int token; register int token;
@@ -687,7 +688,7 @@ parse_thong_decl (void)
/* Parse what comes after %start */ /* Parse what comes after %start */
void static void
parse_start_decl (void) parse_start_decl (void)
{ {
if (start_flag) if (start_flag)
@@ -705,7 +706,7 @@ parse_start_decl (void)
/* read in a %type declaration and record its information for get_type_name to access */ /* read in a %type declaration and record its information for get_type_name to access */
void static void
parse_type_decl (void) parse_type_decl (void)
{ {
register int k; register int k;
@@ -762,7 +763,7 @@ parse_type_decl (void)
/* read in a %left, %right or %nonassoc declaration and record its information. */ /* read in a %left, %right or %nonassoc declaration and record its information. */
/* assoc is either LEFT_ASSOC, RIGHT_ASSOC or NON_ASSOC. */ /* assoc is either LEFT_ASSOC, RIGHT_ASSOC or NON_ASSOC. */
void static void
parse_assoc_decl (int assoc) parse_assoc_decl (int assoc)
{ {
register int k; register int k;
@@ -845,7 +846,7 @@ parse_assoc_decl (int assoc)
where it is made into the where it is made into the
definition of YYSTYPE, the type of elements of the parser value stack. */ definition of YYSTYPE, the type of elements of the parser value stack. */
void static void
parse_union_decl (void) parse_union_decl (void)
{ {
register int c; register int c;
@@ -915,7 +916,7 @@ parse_union_decl (void)
/* parse the declaration %expect N which says to expect N /* parse the declaration %expect N which says to expect N
shift-reduce conflicts. */ shift-reduce conflicts. */
void static void
parse_expect_decl (void) parse_expect_decl (void)
{ {
register int c; register int c;
@@ -944,29 +945,29 @@ parse_expect_decl (void)
/* that's all of parsing the declaration section */ /* that's all of parsing the declaration section */
/* FINPUT is pointing to a location (i.e., a `@'). Output to FOUTPUT /* FIN is pointing to a location (i.e., a `@'). Output to FOUT
a reference to this location. STACK_OFFSET is the number of values a reference to this location. STACK_OFFSET is the number of values
in the current rule so far, which says where to find `$0' with in the current rule so far, which says where to find `$0' with
respect to the top of the stack. */ respect to the top of the stack. */
static inline void static inline void
copy_at (FILE *finput, FILE *foutput, int stack_offset) copy_at (FILE *fin, FILE *fout, int stack_offset)
{ {
int c; int c;
c = getc (finput); c = getc (fin);
if (c == '$') if (c == '$')
{ {
fprintf (foutput, "yyloc"); fprintf (fout, "yyloc");
yylsp_needed = 1; yylsp_needed = 1;
} }
else if (isdigit(c) || c == '-') else if (isdigit(c) || c == '-')
{ {
int n; int n;
ungetc (c, finput); ungetc (c, fin);
n = read_signed_integer (finput); n = read_signed_integer (fin);
fprintf (foutput, "yylsp[%d]", n - stack_offset); fprintf (fout, "yylsp[%d]", n - stack_offset);
yylsp_needed = 1; yylsp_needed = 1;
} }
else else
@@ -977,7 +978,7 @@ copy_at (FILE *finput, FILE *foutput, int stack_offset)
/* Get the data type (alternative in the union) of the value for /* Get the data type (alternative in the union) of the value for
symbol n in rule rule. */ symbol n in rule rule. */
char * static char *
get_type_name (int n, symbol_list *rule) get_type_name (int n, symbol_list *rule)
{ {
register int i; register int i;
@@ -1015,7 +1016,7 @@ get_type_name (int n, symbol_list *rule)
respect to the top of the stack, for the simple parser in which the respect to the top of the stack, for the simple parser in which the
stack is not popped until after the guard is run. */ stack is not popped until after the guard is run. */
void static void
copy_guard (symbol_list *rule, int stack_offset) copy_guard (symbol_list *rule, int stack_offset)
{ {
register int c; register int c;
@@ -1165,7 +1166,7 @@ copy_guard (symbol_list *rule, int stack_offset)
values in the current rule so far, which says where to find `$0' values in the current rule so far, which says where to find `$0'
with respect to the top of the stack. */ with respect to the top of the stack. */
void static void
copy_action (symbol_list *rule, int stack_offset) copy_action (symbol_list *rule, int stack_offset)
{ {
register int c; register int c;
@@ -1299,7 +1300,7 @@ copy_action (symbol_list *rule, int stack_offset)
/* generate a dummy symbol, a nonterminal, /* generate a dummy symbol, a nonterminal,
whose name cannot conflict with the user's names. */ whose name cannot conflict with the user's names. */
bucket * static bucket *
gensym (void) gensym (void)
{ {
register bucket *sym; register bucket *sym;
@@ -1320,7 +1321,7 @@ The next symbol is the lhs of the following rule.
All guards and actions are copied out to the appropriate files, All guards and actions are copied out to the appropriate files,
labelled by the rule number they apply to. */ labelled by the rule number they apply to. */
void static void
readgram (void) readgram (void)
{ {
register int t; register int t;
@@ -1617,7 +1618,7 @@ readgram (void)
} }
void static void
record_rule_line (void) record_rule_line (void)
{ {
/* Record each rule's source line number in rline table. */ /* Record each rule's source line number in rline table. */
@@ -1686,18 +1687,19 @@ get_type (void)
fdefines. Set up vectors tags and sprec of names and precedences fdefines. Set up vectors tags and sprec of names and precedences
of symbols. */ of symbols. */
void static void
packsymbols (void) packsymbols (void)
{ {
register bucket *bp; register bucket *bp;
register int tokno = 1; register int tokno = 1;
register int i; register int i;
register int last_user_token_number; register int last_user_token_number;
static char DOLLAR[] = "$";
/* int lossage = 0; JF set but not used */ /* int lossage = 0; JF set but not used */
tags = NEW2(nsyms + 1, char *); tags = NEW2(nsyms + 1, char *);
tags[0] = "$"; tags[0] = DOLLAR;
user_toknums = NEW2(nsyms + 1, int); user_toknums = NEW2(nsyms + 1, int);
user_toknums[0] = 0; user_toknums[0] = 0;
@@ -1771,15 +1773,15 @@ packsymbols (void)
if (translations) if (translations)
{ {
register int i; register int j;
token_translations = NEW2(max_user_token_number+1, short); token_translations = NEW2(max_user_token_number+1, short);
/* initialize all entries for literal tokens to 2, the internal /* initialize all entries for literal tokens to 2, the internal
token number for $undefined., which represents all invalid token number for $undefined., which represents all invalid
inputs. */ inputs. */
for (i = 0; i <= max_user_token_number; i++) for (j = 0; j <= max_user_token_number; j++)
token_translations[i] = 2; token_translations[j] = 2;
for (bp = firstsymbol; bp; bp = bp->next) for (bp = firstsymbol; bp; bp = bp->next)
{ {
@@ -1839,7 +1841,7 @@ packsymbols (void)
/* For named tokens, but not literal ones, define the name. The value /* For named tokens, but not literal ones, define the name. The value
is the user token number. */ is the user token number. */
void static void
output_token_defines (FILE *file) output_token_defines (FILE *file)
{ {
bucket *bp; bucket *bp;
@@ -1883,7 +1885,7 @@ output_token_defines (FILE *file)
/* convert the rules into the representation using rrhs, rlhs and ritems. */ /* convert the rules into the representation using rrhs, rlhs and ritems. */
void static void
packgram (void) packgram (void)
{ {
register int itemno; register int itemno;
@@ -1944,7 +1946,7 @@ packgram (void)
/* Read a signed integer from STREAM and return its value. */ /* Read a signed integer from STREAM and return its value. */
int static int
read_signed_integer (FILE *stream) read_signed_integer (FILE *stream)
{ {
register int c = getc(stream); register int c = getc(stream);

View File

@@ -64,20 +64,23 @@ static int nuseful_productions, nuseless_productions,
nuseful_nonterminals, nuseless_nonterminals; nuseful_nonterminals, nuseless_nonterminals;
bool bits_equal PARAMS((BSet, BSet, int)); extern void reduce_grammar PARAMS((void));
int nbits PARAMS((unsigned)); static bool bits_equal PARAMS((BSet, BSet, int));
int bits_size PARAMS((BSet, int)); static int nbits PARAMS((unsigned));
void reduce_grammar PARAMS((void)); static int bits_size PARAMS((BSet, int));
static void useless_nonterminals PARAMS((void)); static void useless_nonterminals PARAMS((void));
static void inaccessable_symbols PARAMS((void)); static void inaccessable_symbols PARAMS((void));
static void reduce_grammar_tables PARAMS((void)); static void reduce_grammar_tables PARAMS((void));
static void print_results PARAMS((void)); static void print_results PARAMS((void));
static void print_notices PARAMS((void)); static void print_notices PARAMS((void));
void dump_grammar PARAMS((void));
#if 0 /* XXX currently unused. */
static void dump_grammar PARAMS((void));
#endif
bool static bool
bits_equal (BSet L, BSet R, int n) bits_equal (BSet L, BSet R, int n)
{ {
int i; int i;
@@ -89,7 +92,7 @@ bits_equal (BSet L, BSet R, int n)
} }
int static int
nbits (unsigned i) nbits (unsigned i)
{ {
int count = 0; int count = 0;
@@ -102,7 +105,7 @@ nbits (unsigned i)
} }
int static int
bits_size (BSet S, int n) bits_size (BSet S, int n)
{ {
int i, count = 0; int i, count = 0;
@@ -142,13 +145,13 @@ reduce_grammar (void)
tags[start_symbol]); tags[start_symbol]);
reduce_grammar_tables(); reduce_grammar_tables();
/* #if 0
if (verboseflag) if (verboseflag)
{ {
fprintf(foutput, "REDUCED GRAMMAR\n\n"); fprintf(foutput, "REDUCED GRAMMAR\n\n");
dump_grammar(); dump_grammar();
} }
*/ #endif
/**/ statisticsflag = FALSE; /* someday getopts should handle this */ /**/ statisticsflag = FALSE; /* someday getopts should handle this */
if (statisticsflag == TRUE) if (statisticsflag == TRUE)
fprintf(stderr, fprintf(stderr,
@@ -530,7 +533,8 @@ print_results (void)
fprintf(foutput, "\n\n"); fprintf(foutput, "\n\n");
} }
void #if 0 /* XXX currently unused. */
static void
dump_grammar (void) dump_grammar (void)
{ {
int i; int i;
@@ -565,6 +569,7 @@ dump_grammar (void)
} }
fprintf(foutput, "\n\n"); fprintf(foutput, "\n\n");
} }
#endif
static void static void

View File

@@ -26,18 +26,18 @@ Boston, MA 02111-1307, USA. */
#include "gram.h" #include "gram.h"
bucket **symtab;
bucket *firstsymbol; bucket *firstsymbol;
bucket *lastsymbol; static bucket *lastsymbol;
static bucket **symtab;
void tabinit PARAMS((void)); extern void tabinit PARAMS((void));
void free_symtab PARAMS((void)); extern void free_symtab PARAMS((void));
static int static int
hash (char *key) hash (const char *key)
{ {
register char *cp; register const char *cp;
register int k; register int k;
cp = key; cp = key;
@@ -51,10 +51,10 @@ hash (char *key)
static char * static char *
copys (char *s) copys (const char *s)
{ {
register int i; register int i;
register char *cp; register const char *cp;
register char *result; register char *result;
i = 1; i = 1;
@@ -80,7 +80,7 @@ tabinit (void)
bucket * bucket *
getsym (char *key) getsym (const char *key)
{ {
register int hashval; register int hashval;
register bucket *bp; register bucket *bp;

View File

@@ -54,7 +54,6 @@ typedef
bucket; bucket;
extern bucket **symtab;
extern bucket *firstsymbol; extern bucket *firstsymbol;
extern bucket *getsym PARAMS((char *)); extern bucket *getsym PARAMS((const char *));