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