Imported Upstream version 5.12.0.220

Former-commit-id: c477e03582759447177c6d4bf412cd2355aad476
This commit is contained in:
Xamarin Public Jenkins (auto-signing)
2018-04-24 09:31:23 +00:00
parent 8bd104cef2
commit 8fc30896db
1200 changed files with 29534 additions and 26161 deletions

View File

@@ -47,8 +47,17 @@ unsigned *ruleset;
static unsigned *first_derives;
static unsigned *EFF;
void
print_first_derives (void);
set_EFF()
void
print_closure (int n);
void
print_EFF (void);
static void
set_EFF (void)
{
register unsigned *row;
register int symbol;
@@ -83,8 +92,8 @@ set_EFF()
#endif
}
set_first_derives()
void
set_first_derives (void)
{
register unsigned *rrow;
register unsigned *vrow;
@@ -138,10 +147,8 @@ set_first_derives()
FREE(EFF);
}
closure(nucleus, n)
short *nucleus;
int n;
void
closure (short *nucleus, int n)
{
register int ruleno;
register unsigned word;
@@ -207,20 +214,18 @@ int n;
#endif
}
finalize_closure()
void
finalize_closure (void)
{
FREE(itemset);
FREE(ruleset);
FREE(first_derives + ntokens * WORDSIZE(nrules));
}
#ifdef DEBUG
print_closure(n)
int n;
void
print_closure (int n)
{
register short *isp;
@@ -229,8 +234,8 @@ int n;
printf(" %d\n", *isp);
}
print_EFF()
void
print_EFF (void)
{
register int i, j;
register unsigned *rowp;
@@ -260,8 +265,8 @@ print_EFF()
}
}
print_first_derives()
void
print_first_derives (void)
{
register int i;
register int j;

View File

@@ -162,6 +162,7 @@ struct bucket
short value;
short index;
short prec;
#define class clas
char class;
char assoc;
};
@@ -248,11 +249,10 @@ extern int nrules;
extern int nsyms;
extern int ntokens;
extern int nvars;
extern int ntags;
extern int nmethods;
extern char *line_format;
extern char *default_line_format;
extern const char *line_format;
extern const char *default_line_format;
extern int start_symbol;
extern char **symbol_name;
@@ -300,8 +300,155 @@ extern short final_state;
/* global functions */
extern char *allocate();
extern bucket *lookup();
extern bucket *make_bucket();
char *
allocate (unsigned);
bucket *
lookup (const char *);
bucket *
make_bucket (const char *);
void
reflexive_transitive_closure (unsigned *R, int n);
void
done (int);
void
fatal (const char*);
void
no_space (void);
void
finalize_closure (void);
void
closure (short *nucleus, int n);
void
set_first_derives (void);
void
open_error (const char *filename);
void
make_parser (void);
void
free_parser (void);
void
lr0 (void);
void
output (void);
void
verbose (void);
void
xxlr0 (void);
void
reader (void);
void
lalr (void);
void
free_symbols (void);
void
free_symbol_table (void);
void
create_symbol_table (void);
void
fatal (const char *msg);
void
no_space (void);
void
open_error (const char *filename);
void
unexpected_EOF (void);
void
syntax_error (int st_lineno, const char *st_line, const char *st_cptr);
void
unterminated_comment (int c_lineno, const char *c_line, const char *c_cptr);
void
unterminated_string (int s_lineno, const char *s_line, const char *s_cptr);
void
unterminated_text (int t_lineno, const char *t_line, const char *t_cptr);
void
illegal_tag (int t_lineno, const char *t_line, const char *t_cptr);
void
illegal_character (const char *c_cptr);
void
used_reserved (const char *s);
void
tokenized_start (const char *s);
void
retyped_warning (const char *s);
void
reprec_warning (const char *s);
void
revalued_warning (const char *s);
void
terminal_start (const char *s);
void
restarted_warning (void);
void
no_grammar (void);
void
terminal_lhs (int s_lineno);
void
prec_redeclared (void);
void
unterminated_action (int a_lineno, const char *a_line, const char *a_cptr);
void
dollar_warning (int a_lineno, int i);
void
dollar_error (int a_lineno, const char *a_line, char *a_cptr);
void
untyped_lhs (void);
void
untyped_rhs (int i, const char *s);
void
unknown_rhs (int i);
void
default_action_warning (void);
void
undefined_goal (const char *s);
void
undefined_symbol_warning (const char *s);

View File

@@ -42,43 +42,39 @@ static char sccsid[] = "@(#)error.c 5.3 (Berkeley) 6/1/90";
#include "defs.h"
fatal(msg)
char *msg;
void
fatal (const char *msg)
{
fprintf(stderr, "%s: f - %s\n", myname, msg);
done(2);
}
no_space()
void
no_space (void)
{
fprintf(stderr, "%s: f - out of space\n", myname);
done(2);
}
open_error(filename)
char *filename;
void
open_error (const char *filename)
{
fprintf(stderr, "%s: f - cannot open \"%s\"\n", myname, filename);
done(2);
}
unexpected_EOF()
void
unexpected_EOF (void)
{
fprintf(stderr, "%s: e - line %d of \"%s\", unexpected end-of-file\n",
myname, lineno, input_file_name);
done(1);
}
print_pos(st_line, st_cptr)
char *st_line;
char *st_cptr;
static void
print_pos (const char *st_line, const char *st_cptr)
{
register char *s;
const char *s;
if (st_line == 0) return;
for (s = st_line; *s != '\n'; ++s)
@@ -100,11 +96,8 @@ char *st_cptr;
putc('\n', stderr);
}
syntax_error(st_lineno, st_line, st_cptr)
int st_lineno;
char *st_line;
char *st_cptr;
void
syntax_error (int st_lineno, const char *st_line, const char *st_cptr)
{
fprintf(stderr, "%s: e - line %d of \"%s\", syntax error\n",
myname, st_lineno, input_file_name);
@@ -112,11 +105,8 @@ char *st_cptr;
done(1);
}
unterminated_comment(c_lineno, c_line, c_cptr)
int c_lineno;
char *c_line;
char *c_cptr;
void
unterminated_comment (int c_lineno, const char *c_line, const char *c_cptr)
{
fprintf(stderr, "%s: e - line %d of \"%s\", unmatched /*\n",
myname, c_lineno, input_file_name);
@@ -124,11 +114,8 @@ char *c_cptr;
done(1);
}
unterminated_string(s_lineno, s_line, s_cptr)
int s_lineno;
char *s_line;
char *s_cptr;
void
unterminated_string (int s_lineno, const char *s_line, const char *s_cptr)
{
fprintf(stderr, "%s: e - line %d of \"%s\", unterminated string\n",
myname, s_lineno, input_file_name);
@@ -136,11 +123,8 @@ char *s_cptr;
done(1);
}
unterminated_text(t_lineno, t_line, t_cptr)
int t_lineno;
char *t_line;
char *t_cptr;
void
unterminated_text (int t_lineno, const char *t_line, const char *t_cptr)
{
fprintf(stderr, "%s: e - line %d of \"%s\", unmatched %%{\n",
myname, t_lineno, input_file_name);
@@ -148,11 +132,8 @@ char *t_cptr;
done(1);
}
illegal_tag(t_lineno, t_line, t_cptr)
int t_lineno;
char *t_line;
char *t_cptr;
void
illegal_tag (int t_lineno, const char *t_line, const char *t_cptr)
{
fprintf(stderr, "%s: e - line %d of \"%s\", illegal tag\n",
myname, t_lineno, input_file_name);
@@ -160,9 +141,8 @@ char *t_cptr;
done(1);
}
illegal_character(c_cptr)
char *c_cptr;
void
illegal_character (const char *c_cptr)
{
fprintf(stderr, "%s: e - line %d of \"%s\", illegal character\n",
myname, lineno, input_file_name);
@@ -170,93 +150,83 @@ char *c_cptr;
done(1);
}
used_reserved(s)
char *s;
void
used_reserved (const char *s)
{
fprintf(stderr, "%s: e - line %d of \"%s\", illegal use of reserved symbol \
%s\n", myname, lineno, input_file_name, s);
done(1);
}
tokenized_start(s)
char *s;
void
tokenized_start (const char *s)
{
fprintf(stderr, "%s: e - line %d of \"%s\", the start symbol %s cannot be \
declared to be a token\n", myname, lineno, input_file_name, s);
done(1);
}
retyped_warning(s)
char *s;
void
retyped_warning (const char *s)
{
fprintf(stderr, "%s: w - line %d of \"%s\", the type of %s has been \
redeclared\n", myname, lineno, input_file_name, s);
}
reprec_warning(s)
char *s;
void
reprec_warning (const char *s)
{
fprintf(stderr, "%s: w - line %d of \"%s\", the precedence of %s has been \
redeclared\n", myname, lineno, input_file_name, s);
}
revalued_warning(s)
char *s;
void
revalued_warning (const char *s)
{
fprintf(stderr, "%s: w - line %d of \"%s\", the value of %s has been \
redeclared\n", myname, lineno, input_file_name, s);
}
terminal_start(s)
char *s;
void
terminal_start (const char *s)
{
fprintf(stderr, "%s: e - line %d of \"%s\", the start symbol %s is a \
token\n", myname, lineno, input_file_name, s);
done(1);
}
restarted_warning()
void
restarted_warning (void)
{
fprintf(stderr, "%s: w - line %d of \"%s\", the start symbol has been \
redeclared\n", myname, lineno, input_file_name);
}
no_grammar()
void
no_grammar (void)
{
fprintf(stderr, "%s: e - line %d of \"%s\", no grammar has been \
specified\n", myname, lineno, input_file_name);
done(1);
}
terminal_lhs(s_lineno)
int s_lineno;
void
terminal_lhs (int s_lineno)
{
fprintf(stderr, "%s: e - line %d of \"%s\", a token appears on the lhs \
of a production\n", myname, s_lineno, input_file_name);
done(1);
}
prec_redeclared()
void
prec_redeclared (void)
{
fprintf(stderr, "%s: w - line %d of \"%s\", conflicting %%prec \
specifiers\n", myname, lineno, input_file_name);
}
unterminated_action(a_lineno, a_line, a_cptr)
int a_lineno;
char *a_line;
char *a_cptr;
void
unterminated_action (int a_lineno, const char *a_line, const char *a_cptr)
{
fprintf(stderr, "%s: e - line %d of \"%s\", unterminated action\n",
myname, a_lineno, input_file_name);
@@ -264,20 +234,15 @@ char *a_cptr;
done(1);
}
dollar_warning(a_lineno, i)
int a_lineno;
int i;
void
dollar_warning (int a_lineno, int i)
{
fprintf(stderr, "%s: w - line %d of \"%s\", $%d references beyond the \
end of the current rule\n", myname, a_lineno, input_file_name, i);
}
dollar_error(a_lineno, a_line, a_cptr)
int a_lineno;
char *a_line;
char *a_cptr;
void
dollar_error (int a_lineno, const char *a_line, char *a_cptr)
{
fprintf(stderr, "%s: e - line %d of \"%s\", illegal $-name\n",
myname, a_lineno, input_file_name);
@@ -285,51 +250,46 @@ char *a_cptr;
done(1);
}
untyped_lhs()
void
untyped_lhs (void)
{
fprintf(stderr, "%s: w - line %d of \"%s\", $$ is untyped\n",
myname, lineno, input_file_name);
/** done(1); */
}
untyped_rhs(i, s)
int i;
char *s;
void
untyped_rhs (int i, const char *s)
{
fprintf(stderr, "%s: w - line %d of \"%s\", $%d (%s) is untyped\n",
myname, lineno, input_file_name, i, s);
/** done(1); */
}
unknown_rhs(i)
int i;
void
unknown_rhs (int i)
{
fprintf(stderr, "%s: e - line %d of \"%s\", $%d is untyped\n",
myname, lineno, input_file_name, i);
done(1);
}
default_action_warning()
void
default_action_warning (void)
{
fprintf(stderr, "%s: w - line %d of \"%s\", the default action assigns an \
undefined value to $$\n", myname, lineno, input_file_name);
}
undefined_goal(s)
char *s;
void
undefined_goal (const char *s)
{
fprintf(stderr, "%s: e - the start symbol %s is undefined\n", myname, s);
done(1);
}
undefined_symbol_warning(s)
char *s;
void
undefined_symbol_warning (const char *s)
{
fprintf(stderr, "%s: w - the symbol %s is undefined\n", myname, s);
}

View File

@@ -60,7 +60,8 @@ short *goto_map;
short *from_state;
short *to_state;
short **transpose();
static short **
transpose (short **R, int n);
static int infinity;
static int maxrhs;
@@ -73,8 +74,50 @@ static short *INDEX;
static short *VERTICES;
static int top;
static void
set_state_table (void);
lalr()
static void
set_accessing_symbol (void);
static void
set_shift_table (void);
static void
set_reduction_table (void);
static void
set_maxrhs (void);
static void
initialize_LA (void);
static void
set_goto_map (void);
static void
initialize_F (void);
static void
build_relations (void);
static void
compute_FOLLOWS (void);
static void
compute_lookaheads (void);
static void
traverse (int i);
static void
digraph (short **relation);
static void
add_lookback_edge (int stateno, int ruleno, int gotono);
void
lalr (void)
{
tokensetsize = WORDSIZE(ntokens);
@@ -91,9 +134,8 @@ lalr()
compute_lookaheads();
}
set_state_table()
static void
set_state_table (void)
{
register core *sp;
@@ -102,9 +144,8 @@ set_state_table()
state_table[sp->number] = sp;
}
set_accessing_symbol()
static void
set_accessing_symbol (void)
{
register core *sp;
@@ -113,9 +154,8 @@ set_accessing_symbol()
accessing_symbol[sp->number] = sp->accessing_symbol;
}
set_shift_table()
static void
set_shift_table (void)
{
register shifts *sp;
@@ -124,9 +164,8 @@ set_shift_table()
shift_table[sp->number] = sp;
}
set_reduction_table()
static void
set_reduction_table (void)
{
register reductions *rp;
@@ -135,9 +174,8 @@ set_reduction_table()
reduction_table[rp->number] = rp;
}
set_maxrhs()
static void
set_maxrhs (void)
{
register short *itemp;
register short *item_end;
@@ -163,9 +201,8 @@ set_maxrhs()
maxrhs = max;
}
initialize_LA()
static void
initialize_LA (void)
{
register int i, j, k;
register reductions *rp;
@@ -201,8 +238,8 @@ initialize_LA()
}
}
set_goto_map()
static void
set_goto_map (void)
{
register shifts *sp;
register int i;
@@ -271,10 +308,8 @@ set_goto_map()
/* Map_goto maps a state/symbol pair into its numeric representation. */
int
map_goto(state, symbol)
int state;
int symbol;
static int
map_goto (int state, int symbol)
{
register int high;
register int low;
@@ -298,9 +333,8 @@ int symbol;
}
}
initialize_F()
static void
initialize_F (void)
{
register int i;
register int j;
@@ -375,9 +409,8 @@ initialize_F()
FREE(edge);
}
build_relations()
static void
build_relations (void)
{
register int i;
register int j;
@@ -468,9 +501,8 @@ build_relations()
FREE(states);
}
add_lookback_edge(stateno, ruleno, gotono)
int stateno, ruleno, gotono;
static void
add_lookback_edge (int stateno, int ruleno, int gotono)
{
register int i, k;
register int found;
@@ -494,12 +526,8 @@ int stateno, ruleno, gotono;
lookback[i] = sp;
}
short **
transpose(R, n)
short **R;
int n;
static short **
transpose (short **R, int n)
{
register short **new_R;
register short **temp_R;
@@ -552,15 +580,14 @@ int n;
return (new_R);
}
compute_FOLLOWS()
static void
compute_FOLLOWS (void)
{
digraph(includes);
}
compute_lookaheads()
static void
compute_lookaheads (void)
{
register int i, n;
register unsigned *fp1, *fp2, *fp3;
@@ -593,9 +620,8 @@ compute_lookaheads()
FREE(F);
}
digraph(relation)
short **relation;
static void
digraph (short **relation)
{
register int i;
@@ -619,10 +645,8 @@ short **relation;
FREE(VERTICES);
}
traverse(i)
register int i;
static void
traverse (int i)
{
register unsigned *fp1;
register unsigned *fp2;

View File

@@ -49,8 +49,11 @@ core *first_state;
shifts *first_shift;
reductions *first_reduction;
int get_state();
core *new_state();
static int
get_state (int symbol);
static core *
new_state (int symbol);
static core **state_set;
static core *this_state;
@@ -68,8 +71,25 @@ static short **kernel_base;
static short **kernel_end;
static short *kernel_items;
#ifdef DEBUG
static void
print_derives (void);
#endif
allocate_itemsets()
static void
save_reductions (void);
static void
save_shifts (void);
static void
new_itemsets (void);
static void
initialize_states (void);
static void
allocate_itemsets (void)
{
register short *itemp;
register short *item_end;
@@ -110,8 +130,8 @@ allocate_itemsets()
kernel_end = NEW2(nsyms, short *);
}
allocate_storage()
static void
allocate_storage (void)
{
allocate_itemsets();
shiftset = NEW2(nsyms, short);
@@ -119,8 +139,8 @@ allocate_storage()
state_set = NEW2(nitems, core *);
}
append_states()
static void
append_states (void)
{
register int i;
register int j;
@@ -148,8 +168,8 @@ append_states()
}
}
free_storage()
static void
free_storage (void)
{
FREE(shift_symbol);
FREE(redset);
@@ -160,9 +180,8 @@ free_storage()
FREE(state_set);
}
generate_states()
static void
generate_states (void)
{
allocate_storage();
itemset = NEW2(nitems, short);
@@ -187,11 +206,8 @@ generate_states()
free_storage();
}
int
get_state(symbol)
int symbol;
get_state (int symbol)
{
register int key;
register short *isp1;
@@ -252,9 +268,8 @@ int symbol;
return (sp->number);
}
initialize_states()
static void
initialize_states (void)
{
register int i;
register short *start_derives;
@@ -280,8 +295,8 @@ initialize_states()
nstates = 1;
}
new_itemsets()
static void
new_itemsets (void)
{
register int i;
register int shiftcount;
@@ -315,11 +330,8 @@ new_itemsets()
nshifts = shiftcount;
}
core *
new_state(symbol)
int symbol;
static core *
new_state (int symbol)
{
register int n;
register core *p;
@@ -355,10 +367,10 @@ int symbol;
return (p);
}
/* show_cores is used for debugging */
show_cores()
void
show_cores (void)
{
core *p;
int i, j, k, n;
@@ -393,7 +405,8 @@ show_cores()
/* show_ritems is used for debugging */
show_ritems()
void
show_ritems (void)
{
int i;
@@ -401,9 +414,9 @@ show_ritems()
printf("ritem[%d] = %d\n", i, ritem[i]);
}
/* show_rrhs is used for debugging */
show_rrhs()
void
show_rrhs (void)
{
int i;
@@ -414,7 +427,8 @@ show_rrhs()
/* show_shifts is used for debugging */
show_shifts()
void
show_shifts (void)
{
shifts *p;
int i, j, k;
@@ -431,8 +445,8 @@ show_shifts()
}
}
save_shifts()
static void
save_shifts (void)
{
register shifts *p;
register short *sp1;
@@ -464,9 +478,8 @@ save_shifts()
}
}
save_reductions()
static void
save_reductions (void)
{
register short *isp;
register short *rp1;
@@ -514,8 +527,8 @@ save_reductions()
}
}
set_derives()
static void
set_derives (void)
{
register int i, k;
register int lhs;
@@ -545,14 +558,18 @@ set_derives()
#endif
}
free_derives()
#if 0
void
free_derives (void)
{
FREE(derives[start_symbol]);
FREE(derives);
}
#endif
#ifdef DEBUG
print_derives()
static void
print_derives (void)
{
register int i;
register short *sp;
@@ -573,14 +590,14 @@ print_derives()
}
#endif
set_nullable()
static void
set_nullable (void)
{
register int i, j;
register int empty;
int done;
nullable = MALLOC(nsyms);
nullable = (char*)MALLOC(nsyms);
if (nullable == 0) no_space();
for (i = 0; i < nsyms; ++i)
@@ -622,14 +639,14 @@ set_nullable()
#endif
}
free_nullable()
void
free_nullable (void)
{
FREE(nullable);
}
lr0()
void
lr0 (void)
{
set_derives();
set_nullable();

View File

@@ -47,19 +47,26 @@ static char sccsid[] = "@(#)main.c 5.5 (Berkeley) 5/24/93";
#include <signal.h>
#include "defs.h"
// FIXME autoconf or use remove instead of unlink
#ifdef _MSC_VER
#include <io.h>
#else
#include <unistd.h>
#endif
char tflag;
char vflag;
int csharp = 0;
char *file_prefix = "y";
char *myname = "yacc";
char *temp_form = "yacc.XXXXXXX";
const char *file_prefix = (char*)"y";
char *myname = (char*)"yacc";
const char *temp_form = "yacc.XXXXXXX";
int lineno;
int outline;
char *action_file_name;
char *input_file_name = "";
char *input_file_name = (char*)"";
char *prolog_file_name;
char *local_file_name;
char *verbose_file_name;
@@ -100,8 +107,8 @@ extern char* mktemp();
extern char *getenv();
done(k)
int k;
void
done (int k)
{
if (action_file) { fclose(action_file); unlink(action_file_name); }
if (prolog_file) { fclose(prolog_file); unlink(prolog_file_name); }
@@ -109,16 +116,15 @@ int k;
exit(k);
}
void
onintr(signo)
int signo;
static void
onintr (int signo)
{
(void)signo; // unused
done(1);
}
set_signals()
static void
set_signals (void)
{
#ifdef SIGINT
if (signal(SIGINT, SIG_IGN) != SIG_IGN)
@@ -134,23 +140,22 @@ set_signals()
#endif
}
usage()
static void
usage (void)
{
fprintf(stderr, "usage: %s [-tvcp] [-b file_prefix] filename\n", myname);
exit(1);
}
void
static void
print_skel_dir(void)
{
printf ("%s\n", SKEL_DIRECTORY);
exit (0);
}
getargs(argc, argv)
int argc;
char *argv[];
static void
getargs (int argc, char *argv[])
{
register int i;
register char *s;
@@ -240,17 +245,15 @@ no_more_options:;
input_file_name = argv[i];
}
char *
allocate(n)
unsigned n;
allocate (unsigned n)
{
register char *p;
p = NULL;
if (n)
{
p = CALLOC(1, n);
p = (char*)CALLOC(1, n);
if (!p) no_space();
}
return (p);
@@ -262,10 +265,11 @@ unsigned n;
#define GNUC_UNUSED
#endif
create_file_names()
static void
create_file_names (void)
{
int i, len;
char *tmpdir;
const char *tmpdir;
int mkstemp_res GNUC_UNUSED;
#if defined(_WIN32) && !defined(__CYGWIN32__) && !defined(__CYGWIN__)
@@ -282,11 +286,11 @@ create_file_names()
if (len && tmpdir[len-1] != '/')
++i;
action_file_name = MALLOC(i);
action_file_name = (char*)MALLOC(i);
if (action_file_name == 0) no_space();
prolog_file_name = MALLOC(i);
prolog_file_name = (char*)MALLOC(i);
if (prolog_file_name == 0) no_space();
local_file_name = MALLOC(i);
local_file_name = (char*)MALLOC(i);
if (local_file_name == 0) no_space();
strcpy(action_file_name, tmpdir);
@@ -317,7 +321,7 @@ create_file_names()
if (vflag)
{
verbose_file_name = MALLOC(len + 8);
verbose_file_name = (char*)MALLOC(len + 8);
if (verbose_file_name == 0)
no_space();
strcpy(verbose_file_name, file_prefix);
@@ -325,8 +329,8 @@ create_file_names()
}
}
open_files()
static void
open_files (void)
{
create_file_names();
@@ -359,9 +363,7 @@ open_files()
int
main(argc, argv)
int argc;
char *argv[];
main (int argc, char *argv[])
{
set_signals();
getargs(argc, argv);

View File

@@ -53,13 +53,35 @@ short final_state;
static int SRcount;
static int RRcount;
extern action *parse_actions();
extern action *get_shifts();
extern action *add_reductions();
extern action *add_reduce();
static action *
parse_actions (int stateno);
static action *
get_shifts (int stateno);
make_parser()
static action *
add_reductions (int stateno, action *actions);
static action *
add_reduce (action *actions, int ruleno, int symbol);
static void
defreds (void);
static void
remove_conflicts (void);
static void
total_conflicts (void);
static void
find_final_state (void);
static void
unused_rules (void);
void
make_parser (void)
{
register int i;
@@ -74,10 +96,8 @@ make_parser()
defreds();
}
action *
parse_actions(stateno)
register int stateno;
static action *
parse_actions (int stateno)
{
register action *actions;
@@ -86,10 +106,8 @@ register int stateno;
return (actions);
}
action *
get_shifts(stateno)
int stateno;
static action *
get_shifts (int stateno)
{
register action *actions, *temp;
register shifts *sp;
@@ -122,10 +140,8 @@ int stateno;
return (actions);
}
action *
add_reductions(stateno, actions)
int stateno;
register action *actions;
static action *
add_reductions (int stateno, action *actions)
{
register int i, j, m, n;
register int ruleno, tokensetsize;
@@ -147,11 +163,8 @@ register action *actions;
return (actions);
}
action *
add_reduce(actions, ruleno, symbol)
register action *actions;
register int ruleno, symbol;
static action *
add_reduce (action *actions, int ruleno, int symbol)
{
register action *temp, *prev, *next;
@@ -188,8 +201,8 @@ register int ruleno, symbol;
return (actions);
}
find_final_state()
static void
find_final_state (void)
{
register int goal, i;
register short *to_state;
@@ -205,8 +218,8 @@ find_final_state()
}
}
unused_rules()
static void
unused_rules (void)
{
register int i;
register action *p;
@@ -231,14 +244,16 @@ unused_rules()
if (!rules_used[i]) ++nunused;
if (nunused)
{
if (nunused == 1)
fprintf(stderr, "%s: 1 rule never reduced\n", myname);
else
fprintf(stderr, "%s: %d rules never reduced\n", myname, nunused);
}
}
remove_conflicts()
static void
remove_conflicts (void)
{
register int i;
register int symbol;
@@ -312,8 +327,8 @@ remove_conflicts()
}
}
total_conflicts()
static void
total_conflicts (void)
{
fprintf(stderr, "%s: ", myname);
if (SRtotal == 1)
@@ -332,10 +347,8 @@ total_conflicts()
fprintf(stderr, ".\n");
}
int
sole_reduction(stateno)
int stateno;
static int
sole_reduction (int stateno)
{
register int count, ruleno;
register action *p;
@@ -361,8 +374,8 @@ int stateno;
return (ruleno);
}
defreds()
static void
defreds (void)
{
register int i;
@@ -371,8 +384,8 @@ defreds()
defred[i] = sole_reduction(i);
}
free_action_row(p)
register action *p;
static void
free_action_row (action *p)
{
register action *q;
@@ -384,7 +397,8 @@ register action *p;
}
}
free_parser()
void
free_parser (void)
{
register int i;

View File

@@ -58,7 +58,75 @@ static int lowzero;
static int high;
extern int csharp;
output () {
static void
free_itemsets (void);
static void
free_reductions (void);
static void
free_shifts (void);
static void
goto_actions (void);
static void
output_actions (void);
static void
output_base (void);
static void
output_check (void);
static void
output_debug (void);
static void
output_defines (const char *prefix);
static void
output_rule_data (void);
static void
output_semantic_actions (void);
static void
output_stored_text (FILE *file, const char *name);
static void
output_table (void);
static void
output_trailing_text (void);
static void
save_column (int symbol, int default_state);
static void
sort_actions (void);
static void
output_yydefred (void);
static int
default_goto (int symbol);
static int
matching_vector (int vector);
static int
pack_vector (int vector);
static void
token_actions (void);
static void
pack_table (void);
void
output (void)
{
int lno = 0;
char buf [128];
@@ -77,7 +145,7 @@ output () {
case '.': break;
default:
cp = strtok(buf, " \t\r\n");
if (cp)
if (cp) {
if (strcmp(cp, "actions") == 0) output_semantic_actions();
else if (strcmp(cp, "debug") == 0) output_debug();
else if (strcmp(cp, "epilog") == 0) output_trailing_text();
@@ -91,6 +159,7 @@ output () {
output_defines(strtok(NULL, "\r\n"));
else
fprintf(stderr, "jay: unknown call (%s) in line %d\n", cp, lno);
}
continue;
}
fputs(buf+1, stdout), ++ outline;
@@ -98,7 +167,8 @@ output () {
free_parser();
}
output_rule_data()
static void
output_rule_data (void)
{
register int i;
register int j;
@@ -160,8 +230,8 @@ output_rule_data()
printf("\n };\n");
}
output_yydefred()
static void
output_yydefred (void)
{
register int i, j;
@@ -189,8 +259,8 @@ output_yydefred()
printf("\n };\n");
}
output_actions()
static void
output_actions (void)
{
nvectors = 2*nstates + nvars;
@@ -217,8 +287,8 @@ output_actions()
output_check();
}
token_actions()
static void
token_actions (void)
{
register int i, j;
register int shiftcount, reducecount;
@@ -302,7 +372,8 @@ token_actions()
FREE(actionrow);
}
goto_actions()
static void
goto_actions (void)
{
register int i, j, k;
@@ -334,9 +405,8 @@ goto_actions()
FREE(state_count);
}
int
default_goto(symbol)
int symbol;
static int
default_goto (int symbol)
{
register int i;
register int m;
@@ -369,11 +439,8 @@ int symbol;
return (default_state);
}
save_column(symbol, default_state)
int symbol;
int default_state;
static void
save_column (int symbol, int default_state)
{
register int i;
register int m;
@@ -413,7 +480,8 @@ int default_state;
width[symno] = sp1[-1] - sp[0] + 1;
}
sort_actions()
static void
sort_actions (void)
{
register int i;
register int j;
@@ -447,8 +515,8 @@ sort_actions()
}
}
pack_table()
static void
pack_table (void)
{
register int i;
register int place;
@@ -510,9 +578,8 @@ pack_table()
/* faster. Also, it depends on the vectors being in a specific */
/* order. */
int
matching_vector(vector)
int vector;
static int
matching_vector (int vector)
{
register int i;
register int j;
@@ -549,11 +616,8 @@ int vector;
return (-1);
}
int
pack_vector(vector)
int vector;
static int
pack_vector (int vector)
{
register int i, j, k, l;
register int t;
@@ -627,9 +691,8 @@ int vector;
}
}
output_base()
static void
output_base (void)
{
register int i, j;
@@ -695,9 +758,8 @@ output_base()
FREE(base);
}
output_table()
static void
output_table (void)
{
register int i;
register int j;
@@ -724,9 +786,8 @@ output_table()
FREE(table);
}
output_check()
static void
output_check (void)
{
register int i;
register int j;
@@ -755,12 +816,10 @@ output_check()
FREE(check);
}
int
is_C_identifier(name)
char *name;
static int
is_C_identifier (const char *name)
{
register char *s;
const char *s;
register int c;
s = name;
@@ -780,7 +839,7 @@ char *name;
if (!isalpha(c) && c != '_' && c != '$')
return (0);
while (c = *++s)
while ((c = *++s))
{
if (!isalnum(c) && c != '_' && c != '$')
return (0);
@@ -788,12 +847,11 @@ char *name;
return (1);
}
output_defines(prefix)
char *prefix;
static void
output_defines (const char *prefix)
{
register int c, i;
register char *s;
const char *s;
for (i = 2; i < ntokens; ++i)
{
@@ -816,7 +874,7 @@ char *prefix;
{
putchar(c);
}
while (c = *++s);
while ((c = *++s));
}
++outline;
printf(" = %d%s\n", symbol_value[i], csharp ? ";" : ";");
@@ -827,10 +885,8 @@ char *prefix;
printf(" %s yyErrorCode = %d%s\n", prefix ? prefix : "", symbol_value[1], csharp ? ";" : ";");
}
output_stored_text(file, name)
FILE *file;
char *name;
static void
output_stored_text (FILE *file, const char *name)
{
register int c;
register FILE *in;
@@ -854,12 +910,12 @@ char *name;
fclose(in);
}
output_debug()
static void
output_debug (void)
{
register int i, j, k, max;
char **symnam, *s;
char * prefix = tflag ? "" : "//t";
const char * prefix = tflag ? "" : "//t";
++outline;
printf(" protected %s int yyFinal = %d;\n", csharp ? "const" : "static final", final_state);
@@ -941,12 +997,12 @@ output_debug()
symnam[i] = 0;
for (i = ntokens - 1; i >= 2; --i)
symnam[symbol_value[i]] = symbol_name[i];
symnam[0] = "end-of-file";
symnam[0] = (char*)"end-of-file";
j = 70; fputs(" ", stdout);
for (i = 0; i <= max; ++i)
{
if (s = symnam[i])
if ((s = symnam[i]))
{
if (s[0] == '"')
{
@@ -1068,7 +1124,8 @@ output_debug()
FREE(symnam);
}
output_trailing_text()
static void
output_trailing_text (void)
{
register int c, last;
register FILE *in;
@@ -1116,8 +1173,8 @@ output_trailing_text()
printf(default_line_format, ++outline + 1);
}
output_semantic_actions()
static void
output_semantic_actions (void)
{
register int c, last;
@@ -1150,8 +1207,8 @@ output_semantic_actions()
printf(default_line_format, ++outline + 1);
}
free_itemsets()
static void
free_itemsets (void)
{
register core *cp, *next;
@@ -1163,8 +1220,8 @@ free_itemsets()
}
}
free_shifts()
static void
free_shifts (void)
{
register shifts *sp, *next;
@@ -1176,9 +1233,8 @@ free_shifts()
}
}
free_reductions()
static void
free_reductions (void)
{
register reductions *rp, *next;

File diff suppressed because it is too large Load Diff

View File

@@ -50,27 +50,23 @@ bucket **symbol_table;
bucket *first_symbol;
bucket *last_symbol;
int
hash(name)
char *name;
static int
hash (const char *name)
{
register char *s;
const char *s;
register int c, k;
assert(name && *name);
s = name;
k = *s;
while (c = *++s)
while ((c = *++s))
k = (31*k + c) & (TABLE_SIZE - 1);
return (k);
}
bucket *
make_bucket(name)
char *name;
make_bucket (const char *name)
{
register bucket *bp;
@@ -79,7 +75,7 @@ char *name;
if (bp == 0) no_space();
bp->link = 0;
bp->next = 0;
bp->name = MALLOC(strlen(name) + 1);
bp->name = (char*)MALLOC(strlen(name) + 1);
if (bp->name == 0) no_space();
bp->tag = 0;
bp->value = UNDEFINED;
@@ -94,10 +90,8 @@ char *name;
return (bp);
}
bucket *
lookup(name)
char *name;
lookup (const char *name)
{
register bucket *bp, **bpp;
@@ -118,8 +112,8 @@ char *name;
return (bp);
}
create_symbol_table()
void
create_symbol_table (void)
{
register int i;
register bucket *bp;
@@ -138,15 +132,15 @@ create_symbol_table()
symbol_table[hash("error")] = bp;
}
free_symbol_table()
void
free_symbol_table (void)
{
FREE(symbol_table);
symbol_table = 0;
}
free_symbols()
void
free_symbols (void)
{
register bucket *p, *q;

View File

@@ -42,7 +42,38 @@ static char sccsid[] = "@(#)verbose.c 5.3 (Berkeley) 1/20/91";
static short *null_rules;
verbose()
static void
print_gotos (int stateno);
static void
print_shifts (action *p);
static void
print_reductions (action *p, int defred);
static void
print_core (int state);
static void
print_actions (int stateno);
static void
print_nulls (int state);
static void
log_unused (void);
static void
print_conflicts (int state);
static void
print_state (int state);
static void
log_conflicts (void);
void
verbose (void)
{
register int i;
@@ -65,8 +96,8 @@ verbose()
fprintf(verbose_file, "%d grammar rules, %d states\n", nrules - 2, nstates);
}
log_unused()
static void
log_unused (void)
{
register int i;
register short *p;
@@ -84,8 +115,8 @@ log_unused()
}
}
log_conflicts()
static void
log_conflicts (void)
{
register int i;
@@ -112,9 +143,8 @@ log_conflicts()
}
}
print_state(state)
int state;
static void
print_state (int state)
{
if (state)
fprintf(verbose_file, "\n\n");
@@ -126,9 +156,8 @@ int state;
print_actions(state);
}
print_conflicts(state)
int state;
static void
print_conflicts (int state)
{
register int symbol, act, number;
register action *p;
@@ -174,9 +203,8 @@ int state;
}
}
print_core(state)
int state;
static void
print_core (int state)
{
register int i;
register int k;
@@ -210,9 +238,8 @@ int state;
}
}
print_nulls(state)
int state;
static void
print_nulls (int state)
{
register action *p;
register int i, j, k, nnulls;
@@ -254,9 +281,8 @@ int state;
fprintf(verbose_file, "\n");
}
print_actions(stateno)
int stateno;
static void
print_actions (int stateno)
{
register action *p;
register shifts *sp;
@@ -281,9 +307,8 @@ int stateno;
}
}
print_shifts(p)
register action *p;
static void
print_shifts (action *p)
{
register int count;
register action *q;
@@ -306,10 +331,8 @@ register action *p;
}
}
print_reductions(p, defred)
register action *p;
register int defred;
static void
print_reductions (action *p, int defred)
{
register int k, anyreds;
register action *q;
@@ -344,9 +367,8 @@ register int defred;
}
}
print_gotos(stateno)
int stateno;
static void
print_gotos (int stateno)
{
register int i, k;
register int as;

View File

@@ -40,9 +40,8 @@ static char sccsid[] = "@(#)warshall.c 5.4 (Berkeley) 5/24/93";
#include "defs.h"
transitive_closure(R, n)
unsigned *R;
int n;
static void
transitive_closure (unsigned *R, int n)
{
register int rowsize;
register unsigned i;
@@ -92,9 +91,8 @@ int n;
}
}
reflexive_transitive_closure(R, n)
unsigned *R;
int n;
void
reflexive_transitive_closure (unsigned *R, int n)
{
register int rowsize;
register unsigned i;