mirror of
https://git.savannah.gnu.org/git/bison.git
synced 2026-03-10 21:03:04 +00:00
More explicit use of "const", "extern", and "static", particularly to
limit the scope of many local variables and functions.
This commit is contained in:
50
src/LR0.c
50
src/LR0.c
@@ -42,20 +42,20 @@ core *first_state;
|
||||
shifts *first_shift;
|
||||
reductions *first_reduction;
|
||||
|
||||
int get_state PARAMS((int));
|
||||
core *new_state PARAMS((int));
|
||||
extern void generate_states PARAMS((void));
|
||||
|
||||
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));
|
||||
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));
|
||||
@@ -82,7 +82,7 @@ static core **state_table;
|
||||
|
||||
|
||||
|
||||
void
|
||||
static void
|
||||
allocate_itemsets (void)
|
||||
{
|
||||
register short *itemp;
|
||||
@@ -127,7 +127,7 @@ allocate_itemsets (void)
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
static void
|
||||
allocate_storage (void)
|
||||
{
|
||||
allocate_itemsets();
|
||||
@@ -138,7 +138,7 @@ allocate_storage (void)
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
static void
|
||||
free_storage (void)
|
||||
{
|
||||
FREE(shift_symbol);
|
||||
@@ -200,7 +200,7 @@ generate_states (void)
|
||||
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;
|
||||
@@ -248,7 +248,7 @@ new_itemsets (void)
|
||||
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;
|
||||
@@ -287,7 +287,7 @@ append_states (void)
|
||||
Create a new state if no equivalent one exists already.
|
||||
Used by append_states */
|
||||
|
||||
int
|
||||
static int
|
||||
get_state (int symbol)
|
||||
{
|
||||
register int key;
|
||||
@@ -360,7 +360,7 @@ get_state (int symbol)
|
||||
|
||||
/* subroutine of get_state. create a new state for those items, if necessary. */
|
||||
|
||||
core *
|
||||
static core *
|
||||
new_state (int symbol)
|
||||
{
|
||||
register int n;
|
||||
@@ -398,7 +398,7 @@ new_state (int symbol)
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
static void
|
||||
initialize_states (void)
|
||||
{
|
||||
register core *p;
|
||||
@@ -412,7 +412,7 @@ initialize_states (void)
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
static void
|
||||
save_shifts (void)
|
||||
{
|
||||
register shifts *p;
|
||||
@@ -449,7 +449,7 @@ save_shifts (void)
|
||||
|
||||
/* 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;
|
||||
@@ -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
|
||||
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;
|
||||
@@ -683,7 +683,7 @@ augment_automaton (void)
|
||||
/* 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;
|
||||
|
||||
@@ -38,8 +38,8 @@ extern char *realloc ();
|
||||
#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));
|
||||
|
||||
|
||||
@@ -59,11 +59,12 @@ Frees itemset, ruleset and internal data.
|
||||
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));
|
||||
|
||||
@@ -81,6 +82,11 @@ static int rulesetsize;
|
||||
/* 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)
|
||||
@@ -100,7 +106,7 @@ 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;
|
||||
@@ -164,7 +170,7 @@ set_fderives (void)
|
||||
symbol 5, so the bit [8 - ntokens, 5 - ntokens] in firsts is
|
||||
set. */
|
||||
|
||||
void
|
||||
static void
|
||||
set_firsts (void)
|
||||
{
|
||||
register unsigned *row;
|
||||
@@ -298,8 +304,8 @@ finalize_closure (void)
|
||||
|
||||
#ifdef DEBUG
|
||||
|
||||
print_closure(n)
|
||||
int n;
|
||||
static void
|
||||
print_closure(int n)
|
||||
{
|
||||
register short *isp;
|
||||
|
||||
@@ -309,7 +315,7 @@ int n;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
static void
|
||||
print_firsts (void)
|
||||
{
|
||||
register int i;
|
||||
@@ -331,7 +337,7 @@ print_firsts (void)
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
static void
|
||||
print_fderives (void)
|
||||
{
|
||||
register int i;
|
||||
|
||||
@@ -90,7 +90,7 @@ warn (message, va_alist)
|
||||
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)))
|
||||
@@ -142,7 +142,7 @@ complain (message, va_alist)
|
||||
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)))
|
||||
|
||||
@@ -38,23 +38,24 @@ extern short *lookaheads;
|
||||
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;
|
||||
@@ -84,7 +85,7 @@ initialize_conflicts (void)
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
static void
|
||||
set_conflicts (int state)
|
||||
{
|
||||
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
|
||||
so that there is no longer a conflict. */
|
||||
|
||||
void
|
||||
static void
|
||||
resolve_sr_conflict (int state, int lookaheadnum)
|
||||
{
|
||||
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.
|
||||
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;
|
||||
@@ -292,7 +293,7 @@ flush_shift (int state, int token)
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
static void
|
||||
log_resolution (int state, int LAno, int token, char *resolution)
|
||||
{
|
||||
fprintf(foutput,
|
||||
@@ -365,7 +366,7 @@ verbose_conflict_log (void)
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
static void
|
||||
total_conflicts (void)
|
||||
{
|
||||
if (src_total == expected_conflicts && rrc_total == 0)
|
||||
@@ -407,7 +408,7 @@ total_conflicts (void)
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
static void
|
||||
count_sr_conflicts (int state)
|
||||
{
|
||||
register int i;
|
||||
@@ -474,7 +475,7 @@ count_sr_conflicts (int state)
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
static void
|
||||
count_rr_conflicts (int state)
|
||||
{
|
||||
register int i;
|
||||
|
||||
@@ -30,8 +30,13 @@ Boston, MA 02111-1307, USA. */
|
||||
#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;
|
||||
|
||||
@@ -95,14 +100,12 @@ free_derives (void)
|
||||
|
||||
#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++)
|
||||
|
||||
46
src/files.c
46
src/files.c
@@ -65,40 +65,44 @@ FILE *fparser = NULL;
|
||||
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;
|
||||
|
||||
|
||||
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);
|
||||
|
||||
@@ -120,7 +124,7 @@ stringappend (char *string1, int end1, char *string2)
|
||||
`-----------------------------------------------------------------*/
|
||||
|
||||
static FILE *
|
||||
tryopen (char *name, char *mode)
|
||||
tryopen (const char *name, const char *mode)
|
||||
{
|
||||
FILE *ptr;
|
||||
|
||||
@@ -164,9 +168,9 @@ openfiles (void)
|
||||
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;
|
||||
|
||||
@@ -240,7 +244,9 @@ openfiles (void)
|
||||
/* -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. */
|
||||
|
||||
|
||||
@@ -53,4 +53,4 @@ extern char *attrsfile;
|
||||
extern char *guardfile;
|
||||
extern char *actfile;
|
||||
|
||||
void done PARAMS((void));
|
||||
extern void done PARAMS((void));
|
||||
|
||||
@@ -37,8 +37,10 @@ extern int fixed_outfiles;/* for -y */
|
||||
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},
|
||||
@@ -61,7 +63,7 @@ struct option longopts[] =
|
||||
/*---------------------------.
|
||||
| Display the help message. |
|
||||
`---------------------------*/
|
||||
void
|
||||
static void
|
||||
usage (FILE *stream)
|
||||
{
|
||||
/* Some efforts were made to ease the translators' task, please
|
||||
|
||||
@@ -19,6 +19,10 @@ the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||
Boston, MA 02111-1307, USA. */
|
||||
|
||||
|
||||
#include "system.h"
|
||||
|
||||
void dummy PARAMS((void));
|
||||
|
||||
/* comments for these variables are in gram.h */
|
||||
|
||||
int nitems;
|
||||
|
||||
69
src/lalr.c
69
src/lalr.c
@@ -74,25 +74,26 @@ short *goto_map;
|
||||
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 lalr PARAMS((void));
|
||||
|
||||
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 maxrhs;
|
||||
@@ -125,7 +126,7 @@ lalr (void)
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
static void
|
||||
set_state_table (void)
|
||||
{
|
||||
register core *sp;
|
||||
@@ -137,7 +138,7 @@ set_state_table (void)
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
static void
|
||||
set_accessing_symbol (void)
|
||||
{
|
||||
register core *sp;
|
||||
@@ -149,7 +150,7 @@ set_accessing_symbol (void)
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
static void
|
||||
set_shift_table (void)
|
||||
{
|
||||
register shifts *sp;
|
||||
@@ -161,7 +162,7 @@ set_shift_table (void)
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
static void
|
||||
set_reduction_table (void)
|
||||
{
|
||||
register reductions *rp;
|
||||
@@ -173,7 +174,7 @@ set_reduction_table (void)
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
static void
|
||||
set_maxrhs (void)
|
||||
{
|
||||
register short *itemp;
|
||||
@@ -199,7 +200,7 @@ set_maxrhs (void)
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
static void
|
||||
initialize_LA (void)
|
||||
{
|
||||
register int i;
|
||||
@@ -266,7 +267,7 @@ initialize_LA (void)
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
static void
|
||||
set_goto_map (void)
|
||||
{
|
||||
register shifts *sp;
|
||||
@@ -336,7 +337,7 @@ set_goto_map (void)
|
||||
|
||||
/* Map_goto maps a state/symbol pair into its numeric representation. */
|
||||
|
||||
int
|
||||
static int
|
||||
map_goto (int state, int symbol)
|
||||
{
|
||||
register int high;
|
||||
@@ -365,7 +366,7 @@ map_goto (int state, int symbol)
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
static void
|
||||
initialize_F (void)
|
||||
{
|
||||
register int i;
|
||||
@@ -441,7 +442,7 @@ initialize_F (void)
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
static void
|
||||
build_relations (void)
|
||||
{
|
||||
register int i;
|
||||
@@ -536,7 +537,7 @@ build_relations (void)
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
static void
|
||||
add_lookback_edge (int stateno, int ruleno, int gotono)
|
||||
{
|
||||
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)
|
||||
{
|
||||
register short **new_R;
|
||||
@@ -621,7 +622,7 @@ transpose (short **R_arg, int n)
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
static void
|
||||
compute_FOLLOWS (void)
|
||||
{
|
||||
register int i;
|
||||
@@ -637,7 +638,7 @@ compute_FOLLOWS (void)
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
static void
|
||||
compute_lookaheads (void)
|
||||
{
|
||||
register int i;
|
||||
@@ -680,7 +681,7 @@ compute_lookaheads (void)
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
static void
|
||||
digraph (short **relation)
|
||||
{
|
||||
register int i;
|
||||
@@ -706,7 +707,7 @@ digraph (short **relation)
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
static void
|
||||
traverse (register int i)
|
||||
{
|
||||
register unsigned *fp1;
|
||||
|
||||
23
src/lex.c
23
src/lex.c
@@ -50,14 +50,15 @@ extern char *spec_file_prefix; /* for -b */
|
||||
|
||||
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));
|
||||
@@ -164,7 +165,7 @@ skip_white_space (void)
|
||||
}
|
||||
|
||||
/* do a getc, but give error message if EOF encountered */
|
||||
int
|
||||
static int
|
||||
safegetc (FILE *f)
|
||||
{
|
||||
register int c = getc(f);
|
||||
@@ -179,7 +180,7 @@ safegetc (FILE *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;
|
||||
@@ -501,7 +502,7 @@ lex (void)
|
||||
set. A retval action returns the code.
|
||||
*/
|
||||
struct percent_table_struct {
|
||||
char *name;
|
||||
const char *name;
|
||||
void *setflag;
|
||||
int retval;
|
||||
} percent_table[] =
|
||||
|
||||
16
src/main.c
16
src/main.c
@@ -27,25 +27,28 @@
|
||||
|
||||
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));
|
||||
@@ -105,6 +108,9 @@ main (int argc, char *argv[])
|
||||
/* output the tables and the parser to ftable. In file output. */
|
||||
output();
|
||||
|
||||
finalize_conflicts();
|
||||
free_derives();
|
||||
|
||||
exit (complain_message_count ? 1 : 0);
|
||||
}
|
||||
|
||||
@@ -131,7 +137,7 @@ printable_version (int c)
|
||||
/* 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();
|
||||
|
||||
@@ -31,8 +31,8 @@ Boston, MA 02111-1307, USA. */
|
||||
|
||||
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)
|
||||
|
||||
105
src/output.c
105
src/output.c
@@ -135,35 +135,36 @@ extern short *goto_map;
|
||||
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 output_headers PARAMS((void));
|
||||
extern void output_trailers PARAMS((void));
|
||||
extern void output PARAMS((void));
|
||||
|
||||
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 *));
|
||||
|
||||
static int nvectors;
|
||||
@@ -287,7 +288,7 @@ output (void)
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
static void
|
||||
output_token_translations (void)
|
||||
{
|
||||
register int i, j;
|
||||
@@ -331,7 +332,7 @@ output_token_translations (void)
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
static void
|
||||
output_gram (void)
|
||||
{
|
||||
register int i;
|
||||
@@ -396,7 +397,7 @@ output_gram (void)
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
static void
|
||||
output_stos (void)
|
||||
{
|
||||
register int i;
|
||||
@@ -426,7 +427,7 @@ output_stos (void)
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
static void
|
||||
output_rule_data (void)
|
||||
{
|
||||
register int i;
|
||||
@@ -612,7 +613,7 @@ static const short yyr2[] = { 0", ftable);
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
static void
|
||||
output_defines (void)
|
||||
{
|
||||
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. */
|
||||
|
||||
void
|
||||
static void
|
||||
output_actions (void)
|
||||
{
|
||||
nvectors = nstates + nvars;
|
||||
@@ -662,7 +663,7 @@ output_actions (void)
|
||||
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;
|
||||
@@ -713,7 +714,7 @@ token_actions (void)
|
||||
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;
|
||||
@@ -882,7 +883,7 @@ action_row (int state)
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
static void
|
||||
save_row (int state)
|
||||
{
|
||||
register int i;
|
||||
@@ -926,7 +927,7 @@ save_row (int state)
|
||||
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;
|
||||
@@ -965,7 +966,7 @@ goto_actions (void)
|
||||
|
||||
|
||||
|
||||
int
|
||||
static int
|
||||
default_goto (int symbol)
|
||||
{
|
||||
register int i;
|
||||
@@ -1002,7 +1003,7 @@ default_goto (int symbol)
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
static void
|
||||
save_column (int symbol, int default_state)
|
||||
{
|
||||
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
|
||||
information into yytable. */
|
||||
|
||||
void
|
||||
static void
|
||||
sort_actions (void)
|
||||
{
|
||||
register int i;
|
||||
@@ -1086,7 +1087,7 @@ sort_actions (void)
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
static void
|
||||
pack_table (void)
|
||||
{
|
||||
register int i;
|
||||
@@ -1135,7 +1136,7 @@ pack_table (void)
|
||||
|
||||
|
||||
|
||||
int
|
||||
static int
|
||||
matching_state (int vector)
|
||||
{
|
||||
register int i;
|
||||
@@ -1175,7 +1176,7 @@ matching_state (int vector)
|
||||
|
||||
|
||||
|
||||
int
|
||||
static int
|
||||
pack_vector (int vector)
|
||||
{
|
||||
register int i;
|
||||
@@ -1244,7 +1245,7 @@ pack_vector (int vector)
|
||||
/* the following functions output yytable, yycheck
|
||||
and the vectors whose elements index the portion starts */
|
||||
|
||||
void
|
||||
static void
|
||||
output_base (void)
|
||||
{
|
||||
register int i;
|
||||
@@ -1295,7 +1296,7 @@ output_base (void)
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
static void
|
||||
output_table (void)
|
||||
{
|
||||
register int i;
|
||||
@@ -1327,7 +1328,7 @@ output_table (void)
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
static void
|
||||
output_check (void)
|
||||
{
|
||||
register int i;
|
||||
@@ -1361,7 +1362,7 @@ output_check (void)
|
||||
|
||||
/* copy the parser code into the ftable file at the end. */
|
||||
|
||||
void
|
||||
static void
|
||||
output_parser (void)
|
||||
{
|
||||
register int c;
|
||||
@@ -1439,7 +1440,7 @@ output_parser (void)
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
static void
|
||||
output_program (void)
|
||||
{
|
||||
register int c;
|
||||
@@ -1456,7 +1457,7 @@ output_program (void)
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
static void
|
||||
free_itemsets (void)
|
||||
{
|
||||
register core *cp,*cptmp;
|
||||
@@ -1471,7 +1472,7 @@ free_itemsets (void)
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
static void
|
||||
free_shifts (void)
|
||||
{
|
||||
register shifts *sp,*sptmp;/* JF derefrenced freed ptr */
|
||||
@@ -1486,7 +1487,7 @@ free_shifts (void)
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
static void
|
||||
free_reductions (void)
|
||||
{
|
||||
register reductions *rp,*rptmp;/* JF fixed freed ptr */
|
||||
|
||||
42
src/print.c
42
src/print.c
@@ -44,13 +44,17 @@ 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));
|
||||
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)
|
||||
@@ -79,14 +83,16 @@ verbose (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);
|
||||
@@ -95,7 +101,7 @@ print_state (int state)
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
static void
|
||||
print_core (int state)
|
||||
{
|
||||
register int i;
|
||||
@@ -141,7 +147,7 @@ print_core (int state)
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
static void
|
||||
print_actions (int state)
|
||||
{
|
||||
register int i;
|
||||
@@ -236,12 +242,16 @@ print_actions (int state)
|
||||
}
|
||||
}
|
||||
|
||||
#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;
|
||||
|
||||
138
src/reader.c
138
src/reader.c
@@ -60,7 +60,7 @@ typedef\n\
|
||||
\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;
|
||||
@@ -96,38 +96,39 @@ typedef
|
||||
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. */
|
||||
@@ -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 "). */
|
||||
|
||||
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)
|
||||
{
|
||||
@@ -181,27 +182,27 @@ copy_string (FILE *finput, FILE *foutput, int 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);
|
||||
}
|
||||
|
||||
|
||||
@@ -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. */
|
||||
|
||||
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
|
||||
to fattrs. */
|
||||
|
||||
void
|
||||
static void
|
||||
read_declarations (void)
|
||||
{
|
||||
register int c;
|
||||
@@ -459,7 +460,7 @@ read_declarations (void)
|
||||
/* 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;
|
||||
@@ -527,7 +528,7 @@ copy_definition (void)
|
||||
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;
|
||||
@@ -625,7 +626,7 @@ parse_token_decl (int what_is, int what_is_not)
|
||||
it is the literal string that is output to yytname
|
||||
*/
|
||||
|
||||
void
|
||||
static void
|
||||
parse_thong_decl (void)
|
||||
{
|
||||
register int token;
|
||||
@@ -687,7 +688,7 @@ parse_thong_decl (void)
|
||||
|
||||
/* Parse what comes after %start */
|
||||
|
||||
void
|
||||
static void
|
||||
parse_start_decl (void)
|
||||
{
|
||||
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 */
|
||||
|
||||
void
|
||||
static void
|
||||
parse_type_decl (void)
|
||||
{
|
||||
register int k;
|
||||
@@ -762,7 +763,7 @@ parse_type_decl (void)
|
||||
/* 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;
|
||||
@@ -845,7 +846,7 @@ parse_assoc_decl (int assoc)
|
||||
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;
|
||||
@@ -915,7 +916,7 @@ parse_union_decl (void)
|
||||
/* parse the declaration %expect N which says to expect N
|
||||
shift-reduce conflicts. */
|
||||
|
||||
void
|
||||
static void
|
||||
parse_expect_decl (void)
|
||||
{
|
||||
register int c;
|
||||
@@ -944,29 +945,29 @@ parse_expect_decl (void)
|
||||
|
||||
/* 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
|
||||
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
|
||||
@@ -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
|
||||
symbol n in rule rule. */
|
||||
|
||||
char *
|
||||
static char *
|
||||
get_type_name (int n, symbol_list *rule)
|
||||
{
|
||||
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
|
||||
stack is not popped until after the guard is run. */
|
||||
|
||||
void
|
||||
static void
|
||||
copy_guard (symbol_list *rule, int stack_offset)
|
||||
{
|
||||
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'
|
||||
with respect to the top of the stack. */
|
||||
|
||||
void
|
||||
static void
|
||||
copy_action (symbol_list *rule, int stack_offset)
|
||||
{
|
||||
register int c;
|
||||
@@ -1299,7 +1300,7 @@ copy_action (symbol_list *rule, int stack_offset)
|
||||
/* generate a dummy symbol, a nonterminal,
|
||||
whose name cannot conflict with the user's names. */
|
||||
|
||||
bucket *
|
||||
static bucket *
|
||||
gensym (void)
|
||||
{
|
||||
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,
|
||||
labelled by the rule number they apply to. */
|
||||
|
||||
void
|
||||
static void
|
||||
readgram (void)
|
||||
{
|
||||
register int t;
|
||||
@@ -1617,7 +1618,7 @@ readgram (void)
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
static void
|
||||
record_rule_line (void)
|
||||
{
|
||||
/* 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
|
||||
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;
|
||||
|
||||
@@ -1771,15 +1773,15 @@ packsymbols (void)
|
||||
|
||||
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)
|
||||
{
|
||||
@@ -1839,7 +1841,7 @@ packsymbols (void)
|
||||
/* 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;
|
||||
@@ -1883,7 +1885,7 @@ output_token_defines (FILE *file)
|
||||
|
||||
/* convert the rules into the representation using rrhs, rlhs and ritems. */
|
||||
|
||||
void
|
||||
static void
|
||||
packgram (void)
|
||||
{
|
||||
register int itemno;
|
||||
@@ -1944,7 +1946,7 @@ packgram (void)
|
||||
|
||||
/* Read a signed integer from STREAM and return its value. */
|
||||
|
||||
int
|
||||
static int
|
||||
read_signed_integer (FILE *stream)
|
||||
{
|
||||
register int c = getc(stream);
|
||||
|
||||
27
src/reduce.c
27
src/reduce.c
@@ -64,20 +64,23 @@ static int nuseful_productions, nuseless_productions,
|
||||
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
|
||||
|
||||
|
||||
|
||||
bool
|
||||
static bool
|
||||
bits_equal (BSet L, BSet R, int n)
|
||||
{
|
||||
int i;
|
||||
@@ -89,7 +92,7 @@ bits_equal (BSet L, BSet R, int n)
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
static int
|
||||
nbits (unsigned i)
|
||||
{
|
||||
int count = 0;
|
||||
@@ -102,7 +105,7 @@ nbits (unsigned i)
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
static int
|
||||
bits_size (BSet S, int n)
|
||||
{
|
||||
int i, count = 0;
|
||||
@@ -142,13 +145,13 @@ reduce_grammar (void)
|
||||
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,
|
||||
@@ -530,7 +533,8 @@ print_results (void)
|
||||
fprintf(foutput, "\n\n");
|
||||
}
|
||||
|
||||
void
|
||||
#if 0 /* XXX currently unused. */
|
||||
static void
|
||||
dump_grammar (void)
|
||||
{
|
||||
int i;
|
||||
@@ -565,6 +569,7 @@ dump_grammar (void)
|
||||
}
|
||||
fprintf(foutput, "\n\n");
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
static void
|
||||
|
||||
18
src/symtab.c
18
src/symtab.c
@@ -26,18 +26,18 @@ Boston, MA 02111-1307, USA. */
|
||||
#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;
|
||||
@@ -51,10 +51,10 @@ hash (char *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;
|
||||
@@ -80,7 +80,7 @@ tabinit (void)
|
||||
|
||||
|
||||
bucket *
|
||||
getsym (char *key)
|
||||
getsym (const char *key)
|
||||
{
|
||||
register int hashval;
|
||||
register bucket *bp;
|
||||
|
||||
@@ -54,7 +54,6 @@ typedef
|
||||
bucket;
|
||||
|
||||
|
||||
extern bucket **symtab;
|
||||
extern bucket *firstsymbol;
|
||||
|
||||
extern bucket *getsym PARAMS((char *));
|
||||
extern bucket *getsym PARAMS((const char *));
|
||||
|
||||
Reference in New Issue
Block a user