limit the scope of many local variables and functions.
shifts *first_shift;
reductions *first_reduction;
-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 generate_states PARAMS((void));
+
+static int get_state PARAMS((int));
+static core *new_state PARAMS((int));
+static void allocate_itemsets PARAMS((void));
+static void allocate_storage PARAMS((void));
+static void free_storage PARAMS((void));
+static void new_itemsets PARAMS((void));
+static void append_states PARAMS((void));
+static void initialize_states PARAMS((void));
+static void save_shifts PARAMS((void));
+static void save_reductions PARAMS((void));
+static void augment_automaton PARAMS((void));
+static void insert_start_shift PARAMS((void));
extern void initialize_closure PARAMS((int));
extern void closure PARAMS((short *, int));
extern void finalize_closure PARAMS((void));
-void
+static void
allocate_itemsets (void)
{
register short *itemp;
}
-void
+static void
allocate_storage (void)
{
allocate_itemsets();
}
-void
+static void
free_storage (void)
{
FREE(shift_symbol);
For each symbol in the grammar, kernel_base[symbol] points to
a vector of item numbers activated if that symbol is shifted,
and kernel_end[symbol] points after the end of that vector. */
-void
+static void
new_itemsets (void)
{
register int i;
reached by each shift transition from the current state.
shiftset is set up as a vector of state numbers of those states. */
-void
+static void
append_states (void)
{
register int i;
Create a new state if no equivalent one exists already.
Used by append_states */
-int
+static int
get_state (int symbol)
{
register int key;
/* subroutine of get_state. create a new state for those items, if necessary. */
-core *
+static core *
new_state (int symbol)
{
register int n;
}
-void
+static void
initialize_states (void)
{
register core *p;
}
-void
+static void
save_shifts (void)
{
register shifts *p;
/* 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
+static void
save_reductions (void)
{
register short *isp;
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
+static void
augment_automaton (void)
{
register int i;
/* subroutine of augment_automaton.
Create the next-to-final state, to which a shift has already been made in
the initial state. */
-void
+static void
insert_start_shift (void)
{
register core *statep;
#endif
#endif /* NEED_DECLARATION_REALLOC */
-char *xmalloc PARAMS((register unsigned));
-char *xrealloc PARAMS((register char *, register unsigned));
+extern char *xmalloc PARAMS((register unsigned));
+extern char *xrealloc PARAMS((register char *, register unsigned));
extern void done PARAMS((int));
extern short **derives;
extern char **tags;
-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 initialize_closure PARAMS((int));
+extern void closure PARAMS((short *, int));
+extern void finalize_closure PARAMS((void));
+
+static void set_fderives PARAMS((void));
+static void set_firsts PARAMS((void));
extern void RTC PARAMS((unsigned *, int));
/* number of words required to hold a bit for each variable */
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
initialize_closure (int n)
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
symbol 8 is rule 4, then the [5 - ntokens, 4] bit in fderives is set. */
-void
+static void
set_fderives (void)
{
register unsigned *rrow;
symbol 5, so the bit [8 - ntokens, 5 - ntokens] in firsts is
set. */
-void
+static void
set_firsts (void)
{
register unsigned *row;
#ifdef DEBUG
-print_closure(n)
-int n;
+static void
+print_closure(int n)
{
register short *isp;
}
-void
+static void
print_firsts (void)
{
register int i;
}
-void
+static void
print_fderives (void)
{
register int i;
if (error_one_per_line)
{
static const char *old_infile;
- static unsigned int old_lineno;
+ static int old_lineno;
if (old_lineno == lineno &&
(infile == old_infile || !strcmp (old_infile, infile)))
if (error_one_per_line)
{
static const char *old_infile;
- static unsigned int old_lineno;
+ static int old_lineno;
if (old_lineno == lineno &&
(infile == old_infile || !strcmp (old_infile, infile)))
extern int verboseflag;
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));
+extern void initialize_conflicts PARAMS((void));
+extern void conflict_log PARAMS((void));
+extern void verbose_conflict_log PARAMS((void));
+extern void print_reductions PARAMS((int));
+extern void finalize_conflicts PARAMS((void));
+
+static void set_conflicts PARAMS((int));
+static void resolve_sr_conflict PARAMS((int, int));
+static void flush_shift PARAMS((int, int));
+static void log_resolution PARAMS((int, int, int, char *));
+static void total_conflicts PARAMS((void));
+static void count_sr_conflicts PARAMS((int));
+static void count_rr_conflicts PARAMS((int));
char any_conflicts;
-char *conflicts;
errs **err_table;
int expected_conflicts;
+static char *conflicts;
static unsigned *shiftset;
}
-void
+static void
set_conflicts (int state)
{
register int i;
A conflict is resolved by modifying the shift or reduce tables
so that there is no longer a conflict. */
-void
+static void
resolve_sr_conflict (int state, int lookaheadnum)
{
register int i;
/* 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. */
-void
+static void
flush_shift (int state, int token)
{
register shifts *shiftp;
}
-void
+static void
log_resolution (int state, int LAno, int token, char *resolution)
{
fprintf(foutput,
}
-void
+static void
total_conflicts (void)
{
if (src_total == expected_conflicts && rrc_total == 0)
}
-void
+static void
count_sr_conflicts (int state)
{
register int i;
}
-void
+static void
count_rr_conflicts (int state)
{
register int i;
#include "types.h"
#include "gram.h"
-void set_derives PARAMS((void));
-void free_derives PARAMS((void));
+extern void set_derives PARAMS((void));
+extern void free_derives PARAMS((void));
+
+#if DEBUG
+static void print_derives PARAMS((void));
+extern char **tags;
+#endif
short **derives;
#ifdef DEBUG
-void
+static void
print_derives (void)
{
register int i;
register short *sp;
- extern char **tags;
-
printf(_("\n\n\nDERIVES\n\n"));
for (i = ntokens; i < nsyms; i++)
char *spec_outfile;
char *infile;
-char *outfile;
-char *defsfile;
-char *tabfile;
char *attrsfile;
-char *guardfile;
-char *actfile;
-char *tmpattrsfile;
-char *tmptabfile;
-char *tmpdefsfile;
+
+static char *outfile;
+static char *defsfile;
+static char *tabfile;
+static char *guardfile;
+static char *actfile;
+static char *tmpattrsfile;
+static char *tmptabfile;
+static char *tmpdefsfile;
extern int noparserflag;
extern char *mktemp(); /* So the compiler won't complain */
extern char *getenv();
-char *stringappend PARAMS((char *, int, char *));
-void openfiles PARAMS((void));
-void open_extra_files PARAMS((void));
+extern char *stringappend PARAMS((const char *, int, const char *));
+extern void openfiles PARAMS((void));
+extern void open_extra_files PARAMS((void));
+
+int fixed_outfiles = 0;
extern char *program_name;
extern int verboseflag;
extern int definesflag;
-int fixed_outfiles = 0;
\f
char *
-stringappend (char *string1, int end1, char *string2)
+stringappend (const char *string1, int end1, const char *string2)
{
register char *ostring;
- register char *cp, *cp1;
+ register char *cp;
+ register const char *cp1;
register int i;
- cp = string2; i = 0;
- while (*cp++) i++;
+ cp1 = string2;
+ i = 0;
+ while (*cp1++) i++;
ostring = NEW2(i+end1+1, char);
`-----------------------------------------------------------------*/
static FILE *
-tryopen (char *name, char *mode)
+tryopen (const char *name, const char *mode)
{
FILE *ptr;
int short_base_length;
#if defined (VMS) & !defined (__VMS_POSIX)
- char *tmp_base = "sys$scratch:b_";
+ const char *tmp_base = "sys$scratch:b_";
#else
- char *tmp_base = "/tmp/b.";
+ const char *tmp_base = "/tmp/b.";
#endif
int tmp_len;
/* -o was not specified; compute output file name from input
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. */
extern char *guardfile;
extern char *actfile;
-void done PARAMS((void));
+extern void done PARAMS((void));
extern char *program_name;
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},
{"defines", 0, &definesflag, 1},
/*---------------------------.
| Display the help message. |
`---------------------------*/
-void
+static void
usage (FILE *stream)
{
/* Some efforts were made to ease the translators' task, please
Boston, MA 02111-1307, USA. */
+#include "system.h"
+
+void dummy PARAMS((void));
+
/* comments for these variables are in gram.h */
int nitems;
short *from_state;
short *to_state;
-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 *));
+extern void lalr PARAMS((void));
+
+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 maxrhs;
}
-void
+static void
set_state_table (void)
{
register core *sp;
}
-void
+static void
set_accessing_symbol (void)
{
register core *sp;
}
-void
+static void
set_shift_table (void)
{
register shifts *sp;
}
-void
+static void
set_reduction_table (void)
{
register reductions *rp;
}
-void
+static void
set_maxrhs (void)
{
register short *itemp;
}
-void
+static void
initialize_LA (void)
{
register int i;
}
-void
+static void
set_goto_map (void)
{
register shifts *sp;
/* Map_goto maps a state/symbol pair into its numeric representation. */
-int
+static int
map_goto (int state, int symbol)
{
register int high;
}
-void
+static void
initialize_F (void)
{
register int i;
}
-void
+static void
build_relations (void)
{
register int i;
}
-void
+static void
add_lookback_edge (int stateno, int ruleno, int gotono)
{
register int i;
-short **
+static short **
transpose (short **R_arg, int n)
{
register short **new_R;
}
-void
+static void
compute_FOLLOWS (void)
{
register int i;
}
-void
+static void
compute_lookaheads (void)
{
register int i;
}
-void
+static void
digraph (short **relation)
{
register int i;
}
-void
+static void
traverse (register int i)
{
register unsigned *fp1;
extern int translations;
-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));
+extern void init_lex PARAMS((void));
+extern char *grow_token_buffer PARAMS((char *));
+extern int skip_white_space PARAMS((void));
+extern void unlex PARAMS((int));
+extern int lex PARAMS((void));
+extern int parse_percent_token PARAMS((void));
+
+static int safegetc PARAMS((FILE *));
+static int literalchar PARAMS((char **, int *, char));
/* functions from main.c */
extern char *printable_version PARAMS((int));
}
/* do a getc, but give error message if EOF encountered */
-int
+static int
safegetc (FILE *f)
{
register int c = getc(f);
return 1 unless the character is an unescaped `term' or \n
report error for \n
*/
-int
+static int
literalchar (char **pp, int *pcode, char term)
{
register int c;
set. A retval action returns the code.
*/
struct percent_table_struct {
- char *name;
+ const char *name;
void *setflag;
int retval;
} percent_table[] =
extern int verboseflag;
+#if 0 /* XXX currently unused. */
/* 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. */
char *program_name;
-char *printable_version PARAMS((int));
-void toomany PARAMS((char *));
-void berror PARAMS((char *));
+extern char *printable_version PARAMS((int));
+extern void berror PARAMS((const 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 free_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 finalize_conflicts PARAMS((void));
extern void verbose PARAMS((void));
extern void terse PARAMS((void));
extern void output PARAMS((void));
/* output the tables and the parser to ftable. In file output. */
output();
+ finalize_conflicts();
+ free_derives();
+
exit (complain_message_count ? 1 : 0);
}
\f
/* Abort for an internal error denoted by string S. */
void
-berror (char *s)
+berror (const char *s)
{
fprintf (stderr, _("%s: internal error: %s\n"), program_name, s);
abort();
char *nullable;
-void free_nullable PARAMS((void));
-void set_nullable PARAMS((void));
+extern void free_nullable PARAMS((void));
+extern void set_nullable PARAMS((void));
void
set_nullable (void)
extern short *from_state;
extern short *to_state;
-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 output_headers PARAMS((void));
+extern void output_trailers PARAMS((void));
+extern void output PARAMS((void));
+
+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 *));
static int nvectors;
}
-void
+static void
output_token_translations (void)
{
register int i, j;
}
-void
+static void
output_gram (void)
{
register int i;
}
-void
+static void
output_stos (void)
{
register int i;
}
-void
+static void
output_rule_data (void)
{
register int i;
}
-void
+static void
output_defines (void)
{
fprintf(ftable, "\n\n#define\tYYFINAL\t\t%d\n", final_state);
/* compute and output yydefact, yydefgoto, yypact, yypgoto, yytable and yycheck. */
-void
+static void
output_actions (void)
{
nvectors = nstates + nvars;
The yydefact table is output now. The detailed info is saved for
putting into yytable later. */
-void
+static void
token_actions (void)
{
register int i;
rules considered lower-numbered rules last, and the last rule
considered that likes a token gets to handle it. */
-int
+static int
action_row (int state)
{
register int i;
}
-void
+static void
save_row (int state)
{
register int i;
The yydefgoto table is output now. The detailed info
is saved for putting into yytable later. */
-void
+static void
goto_actions (void)
{
register int i;
-int
+static int
default_goto (int symbol)
{
register int i;
}
-void
+static void
save_column (int symbol, int default_state)
{
register int i;
/* The next few functions decide how to pack the actions and gotos
information into yytable. */
-void
+static void
sort_actions (void)
{
register int i;
}
-void
+static void
pack_table (void)
{
register int i;
-int
+static int
matching_state (int vector)
{
register int i;
-int
+static int
pack_vector (int vector)
{
register int i;
/* the following functions output yytable, yycheck
and the vectors whose elements index the portion starts */
-void
+static void
output_base (void)
{
register int i;
}
-void
+static void
output_table (void)
{
register int i;
}
-void
+static void
output_check (void)
{
register int i;
/* copy the parser code into the ftable file at the end. */
-void
+static void
output_parser (void)
{
register int c;
}
}
-void
+static void
output_program (void)
{
register int c;
}
-void
+static void
free_itemsets (void)
{
register core *cp,*cptmp;
}
-void
+static void
free_shifts (void)
{
register shifts *sp,*sptmp;/* JF derefrenced freed ptr */
}
-void
+static void
free_reductions (void)
{
register reductions *rp,*rptmp;/* JF fixed freed ptr */
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));
+extern void terse PARAMS((void));
+extern void verbose PARAMS((void));
+
+#if 0 /* XXX currently unused. */
+static void print_token PARAMS((int, int));
+#endif
+
+static void print_state PARAMS((int));
+static void print_core PARAMS((int));
+static void print_actions PARAMS((int));
+static void print_grammar PARAMS((void));
void
terse (void)
}
-void
+#if 0 /* XXX currently unused. */
+static void
print_token (int extnum, int token)
{
fprintf(foutput, _(" type %d is %s\n"), extnum, tags[token]);
}
+#endif
-void
+static void
print_state (int state)
{
fprintf(foutput, _("\n\nstate %d\n\n"), state);
}
-void
+static void
print_core (int state)
{
register int i;
}
-void
+static void
print_actions (int state)
{
register int i;
}
}
-#define END_TEST(end) \
- if (column + strlen(buffer) > (end)) \
- { fprintf (foutput, "%s\n ", buffer); column = 3; buffer[0] = 0; } \
- else
+#define END_TEST(end) \
+ do { \
+ if (column + strlen(buffer) > (end)) { \
+ fprintf (foutput, "%s\n ", buffer); \
+ column = 3; \
+ buffer[0] = 0; \
+ } \
+ } while (0)
-void
+static void
print_grammar (void)
{
int i, j;
\n"
/* Number of slots allocated (but not necessarily used yet) in `rline' */
-int rline_allocated;
+static int rline_allocated;
extern int definesflag;
extern int nolinesflag;
symbol_list;
-void reader PARAMS((void));
-void reader_output_yylsp PARAMS((FILE *));
-void read_declarations PARAMS((void));
-void copy_definition PARAMS((void));
-void parse_token_decl PARAMS((int, int));
-void parse_start_decl PARAMS((void));
-void parse_type_decl PARAMS((void));
-void parse_assoc_decl PARAMS((int));
-void parse_union_decl PARAMS((void));
-void parse_expect_decl PARAMS((void));
-char *get_type_name PARAMS((int, symbol_list *));
-void copy_guard PARAMS((symbol_list *, int));
-void parse_thong_decl PARAMS((void));
-void copy_action PARAMS((symbol_list *, int));
-bucket *gensym PARAMS((void));
-void readgram PARAMS((void));
-void record_rule_line PARAMS((void));
-void packsymbols PARAMS((void));
-void output_token_defines PARAMS((FILE *));
-void packgram PARAMS((void));
-int read_signed_integer PARAMS((FILE *));
+extern void reader PARAMS((void));
+extern void reader_output_yylsp PARAMS((FILE *));
+
+static void read_declarations PARAMS((void));
+static void copy_definition PARAMS((void));
+static void parse_token_decl PARAMS((int, int));
+static void parse_start_decl PARAMS((void));
+static void parse_type_decl PARAMS((void));
+static void parse_assoc_decl PARAMS((int));
+static void parse_union_decl PARAMS((void));
+static void parse_expect_decl PARAMS((void));
+static char *get_type_name PARAMS((int, symbol_list *));
+static void copy_guard PARAMS((symbol_list *, int));
+static void parse_thong_decl PARAMS((void));
+static void copy_action PARAMS((symbol_list *, int));
+static bucket *gensym PARAMS((void));
+static void readgram PARAMS((void));
+static void record_rule_line PARAMS((void));
+static void packsymbols PARAMS((void));
+static void output_token_defines PARAMS((FILE *));
+static void packgram PARAMS((void));
+static int read_signed_integer PARAMS((FILE *));
#if 0
static int get_type PARAMS((void));
#endif
int lineno;
-symbol_list *grammar;
-int start_flag;
-bucket *startval;
char **tags;
int *user_toknums;
+static symbol_list *grammar;
+static int start_flag;
+static bucket *startval;
/* Nonzero if components of semantic values are used, implying
they must be unions. */
}
-/* 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 "). */
static inline void
-copy_string (FILE *finput, FILE *foutput, int match)
+copy_string (FILE *fin, FILE *fout, int match)
{
int c;
- putc (match, foutput);
- c = getc (finput);
+ putc (match, fout);
+ c = getc (fin);
while (c != match)
{
if (c == '\n')
{
complain (_("unterminated string"));
- ungetc (c, finput);
+ ungetc (c, fin);
c = match; /* invent terminator */
continue;
}
- putc(c, foutput);
+ putc(c, fout);
if (c == '\\')
{
- c = getc (finput);
+ c = getc (fin);
if (c == EOF)
fatal (_("unterminated string at end of file"));
- putc (c, foutput);
+ putc (c, fout);
if (c == '\n')
lineno++;
}
- c = getc(finput);
+ c = getc(fin);
}
- putc(c, foutput);
+ putc(c, fout);
}
}
-/* 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. */
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);
}
`%' declarations, and copy the contents of any `%{ ... %}' groups
to fattrs. */
-void
+static void
read_declarations (void)
{
register int c;
/* Copy the contents of a `%{ ... %}' into the definitions file. The
`%{' has already been read. Return after reading the `%}'. */
-void
+static void
copy_definition (void)
{
register int c;
For %token, what_is is STOKEN and what_is_not is SNTERM.
For %nterm, the arguments are reversed. */
-void
+static void
parse_token_decl (int what_is, int what_is_not)
{
register int token = 0;
it is the literal string that is output to yytname
*/
-void
+static void
parse_thong_decl (void)
{
register int token;
/* Parse what comes after %start */
-void
+static void
parse_start_decl (void)
{
if (start_flag)
/* read in a %type declaration and record its information for get_type_name to access */
-void
+static void
parse_type_decl (void)
{
register int k;
/* read in a %left, %right or %nonassoc declaration and record its information. */
/* assoc is either LEFT_ASSOC, RIGHT_ASSOC or NON_ASSOC. */
-void
+static void
parse_assoc_decl (int assoc)
{
register int k;
where it is made into the
definition of YYSTYPE, the type of elements of the parser value stack. */
-void
+static void
parse_union_decl (void)
{
register int c;
/* parse the declaration %expect N which says to expect N
shift-reduce conflicts. */
-void
+static void
parse_expect_decl (void)
{
register int c;
/* that's all of parsing the declaration section */
\f
-/* 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
in the current rule so far, which says where to find `$0' with
respect to the top of the stack. */
static inline void
-copy_at (FILE *finput, FILE *foutput, int stack_offset)
+copy_at (FILE *fin, FILE *fout, int stack_offset)
{
int c;
- c = getc (finput);
+ c = getc (fin);
if (c == '$')
{
- fprintf (foutput, "yyloc");
+ fprintf (fout, "yyloc");
yylsp_needed = 1;
}
else if (isdigit(c) || c == '-')
{
int n;
- ungetc (c, finput);
- n = read_signed_integer (finput);
+ ungetc (c, fin);
+ n = read_signed_integer (fin);
- fprintf (foutput, "yylsp[%d]", n - stack_offset);
+ fprintf (fout, "yylsp[%d]", n - stack_offset);
yylsp_needed = 1;
}
else
/* Get the data type (alternative in the union) of the value for
symbol n in rule rule. */
-char *
+static char *
get_type_name (int n, symbol_list *rule)
{
register int i;
respect to the top of the stack, for the simple parser in which the
stack is not popped until after the guard is run. */
-void
+static void
copy_guard (symbol_list *rule, int stack_offset)
{
register int c;
values in the current rule so far, which says where to find `$0'
with respect to the top of the stack. */
-void
+static void
copy_action (symbol_list *rule, int stack_offset)
{
register int c;
/* generate a dummy symbol, a nonterminal,
whose name cannot conflict with the user's names. */
-bucket *
+static bucket *
gensym (void)
{
register bucket *sym;
All guards and actions are copied out to the appropriate files,
labelled by the rule number they apply to. */
-void
+static void
readgram (void)
{
register int t;
}
-void
+static void
record_rule_line (void)
{
/* Record each rule's source line number in rline table. */
fdefines. Set up vectors tags and sprec of names and precedences
of symbols. */
-void
+static void
packsymbols (void)
{
register bucket *bp;
register int tokno = 1;
register int i;
register int last_user_token_number;
+ static char DOLLAR[] = "$";
/* int lossage = 0; JF set but not used */
tags = NEW2(nsyms + 1, char *);
- tags[0] = "$";
+ tags[0] = DOLLAR;
user_toknums = NEW2(nsyms + 1, int);
user_toknums[0] = 0;
if (translations)
{
- register int i;
+ register int j;
token_translations = NEW2(max_user_token_number+1, short);
/* initialize all entries for literal tokens to 2, the internal
token number for $undefined., which represents all invalid
inputs. */
- for (i = 0; i <= max_user_token_number; i++)
- token_translations[i] = 2;
+ for (j = 0; j <= max_user_token_number; j++)
+ token_translations[j] = 2;
for (bp = firstsymbol; bp; bp = bp->next)
{
/* For named tokens, but not literal ones, define the name. The value
is the user token number. */
-void
+static void
output_token_defines (FILE *file)
{
bucket *bp;
/* convert the rules into the representation using rrhs, rlhs and ritems. */
-void
+static void
packgram (void)
{
register int itemno;
\f
/* Read a signed integer from STREAM and return its value. */
-int
+static int
read_signed_integer (FILE *stream)
{
register int c = getc(stream);
nuseful_nonterminals, nuseless_nonterminals;
-bool bits_equal PARAMS((BSet, BSet, int));
-int nbits PARAMS((unsigned));
-int bits_size PARAMS((BSet, int));
-void reduce_grammar PARAMS((void));
+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));
-void dump_grammar PARAMS((void));
+
+#if 0 /* XXX currently unused. */
+static void dump_grammar PARAMS((void));
+#endif
\f
-bool
+static bool
bits_equal (BSet L, BSet R, int n)
{
int i;
}
-int
+static int
nbits (unsigned i)
{
int count = 0;
}
-int
+static int
bits_size (BSet S, int n)
{
int i, count = 0;
tags[start_symbol]);
reduce_grammar_tables();
- /*
+#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,
fprintf(foutput, "\n\n");
}
\f
-void
+#if 0 /* XXX currently unused. */
+static void
dump_grammar (void)
{
int i;
}
fprintf(foutput, "\n\n");
}
+#endif
static void
#include "gram.h"
-bucket **symtab;
bucket *firstsymbol;
-bucket *lastsymbol;
+static bucket *lastsymbol;
+static bucket **symtab;
-void tabinit PARAMS((void));
-void free_symtab PARAMS((void));
+extern void tabinit PARAMS((void));
+extern void free_symtab PARAMS((void));
static int
-hash (char *key)
+hash (const char *key)
{
- register char *cp;
+ register const char *cp;
register int k;
cp = key;
static char *
-copys (char *s)
+copys (const char *s)
{
register int i;
- register char *cp;
+ register const char *cp;
register char *result;
i = 1;
bucket *
-getsym (char *key)
+getsym (const char *key)
{
register int hashval;
register bucket *bp;
bucket;
-extern bucket **symtab;
extern bucket *firstsymbol;
-extern bucket *getsym PARAMS((char *));
+extern bucket *getsym PARAMS((const char *));