aboutsummaryrefslogtreecommitdiff
path: root/usr.bin/yacc
diff options
context:
space:
mode:
authorSteve Price <steve@FreeBSD.org>1997-01-12 21:16:25 +0000
committerSteve Price <steve@FreeBSD.org>1997-01-12 21:16:25 +0000
commit2726ae5b7c832047a482a8734294a711adcf9742 (patch)
tree4a29aa37d9b588ebaa4593890dad7a484f506901 /usr.bin/yacc
parent7af0f32ba65f65565a67cafbf45e77de9fc4cd09 (diff)
downloadsrc-2726ae5b7c832047a482a8734294a711adcf9742.tar.gz
src-2726ae5b7c832047a482a8734294a711adcf9742.zip
Notes
Diffstat (limited to 'usr.bin/yacc')
-rw-r--r--usr.bin/yacc/closure.c19
-rw-r--r--usr.bin/yacc/defs.h68
-rw-r--r--usr.bin/yacc/error.c35
-rw-r--r--usr.bin/yacc/lalr.c39
-rw-r--r--usr.bin/yacc/lr0.c44
-rw-r--r--usr.bin/yacc/main.c24
-rw-r--r--usr.bin/yacc/mkpar.c38
-rw-r--r--usr.bin/yacc/output.c65
-rw-r--r--usr.bin/yacc/reader.c98
-rw-r--r--usr.bin/yacc/skeleton.c7
-rw-r--r--usr.bin/yacc/symtab.c12
-rw-r--r--usr.bin/yacc/verbose.c27
-rw-r--r--usr.bin/yacc/warshall.c6
13 files changed, 404 insertions, 78 deletions
diff --git a/usr.bin/yacc/closure.c b/usr.bin/yacc/closure.c
index 5f63c5f32cdb..36bbe6b99d64 100644
--- a/usr.bin/yacc/closure.c
+++ b/usr.bin/yacc/closure.c
@@ -35,19 +35,28 @@
*/
#ifndef lint
-static char sccsid[] = "@(#)closure.c 5.3 (Berkeley) 5/24/93";
+static char const sccsid[] = "@(#)closure.c 5.3 (Berkeley) 5/24/93";
#endif /* not lint */
+#include <stdlib.h>
#include "defs.h"
short *itemset;
short *itemsetend;
unsigned *ruleset;
+static void set_EFF __P((void));
+#ifdef DEBUG
+static void print_closure __P((int));
+static void print_EFF __P(());
+static void print_first_derives __P(());
+#endif
+
static unsigned *first_derives;
static unsigned *EFF;
+static void
set_EFF()
{
register unsigned *row;
@@ -84,13 +93,14 @@ set_EFF()
}
+void
set_first_derives()
{
register unsigned *rrow;
register unsigned *vrow;
register int j;
register unsigned k;
- register unsigned cword;
+ register unsigned cword = 0;
register short *rp;
int rule;
@@ -139,6 +149,7 @@ set_first_derives()
}
+void
closure(nucleus, n)
short *nucleus;
int n;
@@ -209,6 +220,7 @@ int n;
+void
finalize_closure()
{
FREE(itemset);
@@ -219,6 +231,7 @@ finalize_closure()
#ifdef DEBUG
+static void
print_closure(n)
int n;
{
@@ -230,6 +243,7 @@ int n;
}
+static void
print_EFF()
{
register int i, j;
@@ -261,6 +275,7 @@ print_EFF()
}
+static void
print_first_derives()
{
register int i;
diff --git a/usr.bin/yacc/defs.h b/usr.bin/yacc/defs.h
index e5e96d2fe571..824ca73cc1ee 100644
--- a/usr.bin/yacc/defs.h
+++ b/usr.bin/yacc/defs.h
@@ -36,6 +36,7 @@
* @(#)defs.h 5.6 (Berkeley) 5/24/93
*/
+#include <sys/cdefs.h> /* for __P macro */
#include <assert.h>
#include <ctype.h>
#include <stdio.h>
@@ -308,20 +309,53 @@ extern short final_state;
/* global functions */
-extern char *allocate();
-extern bucket *lookup();
-extern bucket *make_bucket();
-
-
-/* system variables */
-
-extern int errno;
-
-
-/* system functions */
-
-extern void free();
-extern char *calloc();
-extern char *malloc();
-extern char *realloc();
-extern char *strcpy();
+char *allocate __P((unsigned));
+void closure __P((short *, int));
+void create_symbol_table __P((void));
+void default_action_warning __P((void));
+void dollar_error __P((int, char *, char *));
+void dollar_warning __P((int, int));
+void done __P((int));
+void fatal __P((char *msg));
+void finalize_closure __P((void));
+void free_parser __P((void));
+void free_symbols __P((void));
+void free_symbol_table __P((void));
+void illegal_character __P((char *));
+void illegal_tag __P((int, char *, char *));
+void lalr __P((void));
+bucket *lookup __P((char *));
+void lr0 __P((void));
+bucket *make_bucket __P((char *));
+void make_parser __P((void));
+void no_grammar __P((void));
+void no_space __P((void));
+void open_error __P((char *));
+void output __P((void));
+void over_unionized __P((char *));
+void prec_redeclared __P((void));
+void reader __P((void));
+void reflexive_transitive_closure __P((unsigned *, int));
+void reprec_warning __P((char *));
+void restarted_warning __P((void));
+void retyped_warning __P((char *));
+void revalued_warning __P((char *));
+void set_first_derives __P((void));
+void syntax_error __P((int, char *, char *));
+void terminal_lhs __P((int));
+void terminal_start __P((char *));
+void tokenized_start __P((char *));
+void undefined_goal __P((char *));
+void undefined_symbol_warning __P((char *));
+void unexpected_EOF __P((void));
+void unknown_rhs __P((int));
+void unterminated_action __P((int, char *, char *));
+void unterminated_comment __P((int, char *, char *));
+void unterminated_string __P((int, char *, char *));
+void unterminated_text __P((int, char *, char *));
+void unterminated_union __P((int, char *, char *));
+void untyped_lhs __P((void));
+void untyped_rhs __P((int, char *));
+void used_reserved __P((char *));
+void verbose __P((void));
+void write_section __P((char **));
diff --git a/usr.bin/yacc/error.c b/usr.bin/yacc/error.c
index 54a49ad01b43..bc6fc7a2f0d4 100644
--- a/usr.bin/yacc/error.c
+++ b/usr.bin/yacc/error.c
@@ -35,14 +35,16 @@
*/
#ifndef lint
-static char sccsid[] = "@(#)error.c 5.3 (Berkeley) 6/1/90";
+static char const sccsid[] = "@(#)error.c 5.3 (Berkeley) 6/1/90";
#endif /* not lint */
/* routines for printing error messages */
#include "defs.h"
+static void print_pos __P((char *, char *));
+void
fatal(msg)
char *msg;
{
@@ -51,6 +53,7 @@ char *msg;
}
+void
no_space()
{
fprintf(stderr, "%s: f - out of space\n", myname);
@@ -58,6 +61,7 @@ no_space()
}
+void
open_error(filename)
char *filename;
{
@@ -66,6 +70,7 @@ char *filename;
}
+void
unexpected_EOF()
{
fprintf(stderr, "%s: e - line %d of \"%s\", unexpected end-of-file\n",
@@ -74,6 +79,7 @@ unexpected_EOF()
}
+static void
print_pos(st_line, st_cptr)
char *st_line;
char *st_cptr;
@@ -101,6 +107,7 @@ char *st_cptr;
}
+void
syntax_error(st_lineno, st_line, st_cptr)
int st_lineno;
char *st_line;
@@ -113,6 +120,7 @@ char *st_cptr;
}
+void
unterminated_comment(c_lineno, c_line, c_cptr)
int c_lineno;
char *c_line;
@@ -125,6 +133,7 @@ char *c_cptr;
}
+void
unterminated_string(s_lineno, s_line, s_cptr)
int s_lineno;
char *s_line;
@@ -137,6 +146,7 @@ char *s_cptr;
}
+void
unterminated_text(t_lineno, t_line, t_cptr)
int t_lineno;
char *t_line;
@@ -149,6 +159,7 @@ char *t_cptr;
}
+void
unterminated_union(u_lineno, u_line, u_cptr)
int u_lineno;
char *u_line;
@@ -161,6 +172,7 @@ declaration\n", myname, u_lineno, input_file_name);
}
+void
over_unionized(u_cptr)
char *u_cptr;
{
@@ -171,6 +183,7 @@ declarations\n", myname, lineno, input_file_name);
}
+void
illegal_tag(t_lineno, t_line, t_cptr)
int t_lineno;
char *t_line;
@@ -183,6 +196,7 @@ char *t_cptr;
}
+void
illegal_character(c_cptr)
char *c_cptr;
{
@@ -193,6 +207,7 @@ char *c_cptr;
}
+void
used_reserved(s)
char *s;
{
@@ -202,6 +217,7 @@ char *s;
}
+void
tokenized_start(s)
char *s;
{
@@ -211,6 +227,7 @@ declared to be a token\n", myname, lineno, input_file_name, s);
}
+void
retyped_warning(s)
char *s;
{
@@ -219,6 +236,7 @@ redeclared\n", myname, lineno, input_file_name, s);
}
+void
reprec_warning(s)
char *s;
{
@@ -227,6 +245,7 @@ redeclared\n", myname, lineno, input_file_name, s);
}
+void
revalued_warning(s)
char *s;
{
@@ -235,6 +254,7 @@ redeclared\n", myname, lineno, input_file_name, s);
}
+void
terminal_start(s)
char *s;
{
@@ -244,6 +264,7 @@ token\n", myname, lineno, input_file_name, s);
}
+void
restarted_warning()
{
fprintf(stderr, "%s: w - line %d of \"%s\", the start symbol has been \
@@ -251,6 +272,7 @@ redeclared\n", myname, lineno, input_file_name);
}
+void
no_grammar()
{
fprintf(stderr, "%s: e - line %d of \"%s\", no grammar has been \
@@ -259,6 +281,7 @@ specified\n", myname, lineno, input_file_name);
}
+void
terminal_lhs(s_lineno)
int s_lineno;
{
@@ -268,6 +291,7 @@ of a production\n", myname, s_lineno, input_file_name);
}
+void
prec_redeclared()
{
fprintf(stderr, "%s: w - line %d of \"%s\", conflicting %%prec \
@@ -275,6 +299,7 @@ specifiers\n", myname, lineno, input_file_name);
}
+void
unterminated_action(a_lineno, a_line, a_cptr)
int a_lineno;
char *a_line;
@@ -287,6 +312,7 @@ char *a_cptr;
}
+void
dollar_warning(a_lineno, i)
int a_lineno;
int i;
@@ -296,6 +322,7 @@ end of the current rule\n", myname, a_lineno, input_file_name, i);
}
+void
dollar_error(a_lineno, a_line, a_cptr)
int a_lineno;
char *a_line;
@@ -308,6 +335,7 @@ char *a_cptr;
}
+void
untyped_lhs()
{
fprintf(stderr, "%s: e - line %d of \"%s\", $$ is untyped\n",
@@ -316,6 +344,7 @@ untyped_lhs()
}
+void
untyped_rhs(i, s)
int i;
char *s;
@@ -326,6 +355,7 @@ char *s;
}
+void
unknown_rhs(i)
int i;
{
@@ -335,6 +365,7 @@ int i;
}
+void
default_action_warning()
{
fprintf(stderr, "%s: w - line %d of \"%s\", the default action assigns an \
@@ -342,6 +373,7 @@ undefined value to $$\n", myname, lineno, input_file_name);
}
+void
undefined_goal(s)
char *s;
{
@@ -350,6 +382,7 @@ char *s;
}
+void
undefined_symbol_warning(s)
char *s;
{
diff --git a/usr.bin/yacc/lalr.c b/usr.bin/yacc/lalr.c
index 5007e50ac09b..7f8d885f48b7 100644
--- a/usr.bin/yacc/lalr.c
+++ b/usr.bin/yacc/lalr.c
@@ -35,9 +35,10 @@
*/
#ifndef lint
-static char sccsid[] = "@(#)lalr.c 5.3 (Berkeley) 6/1/90";
+static char const sccsid[] = "@(#)lalr.c 5.3 (Berkeley) 6/1/90";
#endif /* not lint */
+#include <stdlib.h>
#include "defs.h"
typedef
@@ -60,7 +61,22 @@ short *goto_map;
short *from_state;
short *to_state;
-short **transpose();
+static void add_lookback_edge __P((int, int, int));
+static void build_relations __P((void));
+static void compute_FOLLOWS __P((void));
+static void compute_lookaheads __P((void));
+static void digraph __P((short **));
+static void initialize_F __P((void));
+static void initialize_LA __P((void));
+static int map_goto __P((int, int));
+static void set_accessing_symbol __P((void));
+static void set_goto_map __P((void));
+static void set_maxrhs __P((void));
+static void set_reduction_table __P((void));
+static void set_shift_table __P((void));
+static void set_state_table __P((void));
+static short **transpose __P((short **, int));
+static void traverse __P((register int));
static int infinity;
static int maxrhs;
@@ -74,6 +90,7 @@ static short *VERTICES;
static int top;
+void
lalr()
{
tokensetsize = WORDSIZE(ntokens);
@@ -93,6 +110,7 @@ lalr()
+static void
set_state_table()
{
register core *sp;
@@ -104,6 +122,7 @@ set_state_table()
+static void
set_accessing_symbol()
{
register core *sp;
@@ -115,6 +134,7 @@ set_accessing_symbol()
+static void
set_shift_table()
{
register shifts *sp;
@@ -126,6 +146,7 @@ set_shift_table()
+static void
set_reduction_table()
{
register reductions *rp;
@@ -137,6 +158,7 @@ set_reduction_table()
+static void
set_maxrhs()
{
register short *itemp;
@@ -165,6 +187,7 @@ set_maxrhs()
+static void
initialize_LA()
{
register int i, j, k;
@@ -202,6 +225,7 @@ initialize_LA()
}
+static void
set_goto_map()
{
register shifts *sp;
@@ -271,7 +295,7 @@ set_goto_map()
/* Map_goto maps a state/symbol pair into its numeric representation. */
-int
+static int
map_goto(state, symbol)
int state;
int symbol;
@@ -300,6 +324,7 @@ int symbol;
+static void
initialize_F()
{
register int i;
@@ -377,6 +402,7 @@ initialize_F()
+static void
build_relations()
{
register int i;
@@ -469,6 +495,7 @@ build_relations()
}
+static void
add_lookback_edge(stateno, ruleno, gotono)
int stateno, ruleno, gotono;
{
@@ -496,7 +523,7 @@ int stateno, ruleno, gotono;
-short **
+static short **
transpose(R, n)
short **R;
int n;
@@ -554,12 +581,14 @@ int n;
+static void
compute_FOLLOWS()
{
digraph(includes);
}
+static void
compute_lookaheads()
{
register int i, n;
@@ -594,6 +623,7 @@ compute_lookaheads()
}
+static void
digraph(relation)
short **relation;
{
@@ -621,6 +651,7 @@ short **relation;
+static void
traverse(i)
register int i;
{
diff --git a/usr.bin/yacc/lr0.c b/usr.bin/yacc/lr0.c
index 43106ea6cf39..3a65effa0f6a 100644
--- a/usr.bin/yacc/lr0.c
+++ b/usr.bin/yacc/lr0.c
@@ -35,9 +35,10 @@
*/
#ifndef lint
-static char sccsid[] = "@(#)lr0.c 5.3 (Berkeley) 1/20/91";
+static char const sccsid[] = "@(#)lr0.c 5.3 (Berkeley) 1/20/91";
#endif /* not lint */
+#include <stdlib.h>
#include "defs.h"
extern short *itemset;
@@ -49,8 +50,22 @@ core *first_state;
shifts *first_shift;
reductions *first_reduction;
-int get_state();
-core *new_state();
+static void allocate_itemsets __P((void));
+static void allocate_storage __P((void));
+static void append_states __P((void));
+static void free_storage __P((void));
+static void generate_states __P((void));
+static int get_state __P((int));
+static void initialize_states __P((void));
+static void new_itemsets __P((void));
+static core *new_state __P((int));
+#ifdef DEBUG
+static void print_derives __P((void));
+#endif
+static void save_reductions __P((void));
+static void save_shifts __P((void));
+static void set_derives __P((void));
+static void set_nullable __P((void));
static core **state_set;
static core *this_state;
@@ -69,6 +84,7 @@ static short **kernel_end;
static short *kernel_items;
+static void
allocate_itemsets()
{
register short *itemp;
@@ -111,6 +127,7 @@ allocate_itemsets()
}
+static void
allocate_storage()
{
allocate_itemsets();
@@ -120,6 +137,7 @@ allocate_storage()
}
+static void
append_states()
{
register int i;
@@ -149,6 +167,7 @@ append_states()
}
+static void
free_storage()
{
FREE(shift_symbol);
@@ -162,6 +181,7 @@ free_storage()
+static void
generate_states()
{
allocate_storage();
@@ -189,7 +209,7 @@ generate_states()
-int
+static int
get_state(symbol)
int symbol;
{
@@ -254,6 +274,7 @@ int symbol;
+static void
initialize_states()
{
register int i;
@@ -281,6 +302,7 @@ initialize_states()
}
+static void
new_itemsets()
{
register int i;
@@ -317,7 +339,7 @@ new_itemsets()
-core *
+static core *
new_state(symbol)
int symbol;
{
@@ -356,6 +378,7 @@ int symbol;
}
+#if 0
/* show_cores is used for debugging */
show_cores()
@@ -430,8 +453,10 @@ show_shifts()
printf("\t%d\n", p->shift[i]);
}
}
+#endif
+static void
save_shifts()
{
register shifts *p;
@@ -466,6 +491,7 @@ save_shifts()
+static void
save_reductions()
{
register short *isp;
@@ -515,6 +541,7 @@ save_reductions()
}
+static void
set_derives()
{
register int i, k;
@@ -545,13 +572,16 @@ set_derives()
#endif
}
+#if 0
free_derives()
{
FREE(derives[start_symbol]);
FREE(derives);
}
+#endif
#ifdef DEBUG
+static void
print_derives()
{
register int i;
@@ -574,6 +604,7 @@ print_derives()
#endif
+static void
set_nullable()
{
register int i, j;
@@ -623,12 +654,15 @@ set_nullable()
}
+#if 0
free_nullable()
{
FREE(nullable);
}
+#endif
+void
lr0()
{
set_derives();
diff --git a/usr.bin/yacc/main.c b/usr.bin/yacc/main.c
index 79b332a237e7..6f5ce4885d11 100644
--- a/usr.bin/yacc/main.c
+++ b/usr.bin/yacc/main.c
@@ -35,16 +35,19 @@
*/
#ifndef lint
-char copyright[] =
+static char const copyright[] =
"@(#) Copyright (c) 1989 The Regents of the University of California.\n\
All rights reserved.\n";
#endif /* not lint */
#ifndef lint
-static char sccsid[] = "@(#)main.c 5.5 (Berkeley) 5/24/93";
+static char const sccsid[] = "@(#)main.c 5.5 (Berkeley) 5/24/93";
#endif /* not lint */
#include <signal.h>
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
#include "defs.h"
char dflag;
@@ -103,10 +106,15 @@ char *rassoc;
short **derives;
char *nullable;
-extern char *mktemp();
-extern char *getenv();
+static void create_file_names __P((void));
+static void getargs __P((int, char **));
+static void onintr __P((int));
+static void open_files __P((void));
+static void set_signals __P((void));
+static void usage __P((void));
+void
done(k)
int k;
{
@@ -117,7 +125,7 @@ int k;
}
-void
+static void
onintr(signo)
int signo;
{
@@ -125,6 +133,7 @@ onintr(signo)
}
+static void
set_signals()
{
#ifdef SIGINT
@@ -142,6 +151,7 @@ set_signals()
}
+static void
usage()
{
fprintf(stderr, "usage: %s [-dlrtv] [-b file_prefix] [-p symbol_prefix] filename\n", myname);
@@ -149,6 +159,7 @@ usage()
}
+static void
getargs(argc, argv)
int argc;
char *argv[];
@@ -270,6 +281,7 @@ unsigned n;
}
+static void
create_file_names()
{
int i, len;
@@ -353,6 +365,7 @@ create_file_names()
}
+static void
open_files()
{
create_file_names();
@@ -420,4 +433,5 @@ char *argv[];
output();
done(0);
/*NOTREACHED*/
+ return (0);
}
diff --git a/usr.bin/yacc/mkpar.c b/usr.bin/yacc/mkpar.c
index b0f94b4d9fed..342749dc33de 100644
--- a/usr.bin/yacc/mkpar.c
+++ b/usr.bin/yacc/mkpar.c
@@ -35,9 +35,10 @@
*/
#ifndef lint
-static char sccsid[] = "@(#)mkpar.c 5.3 (Berkeley) 1/20/91";
+static char const sccsid[] = "@(#)mkpar.c 5.3 (Berkeley) 1/20/91";
#endif /* not lint */
+#include <stdlib.h>
#include "defs.h"
action **parser;
@@ -53,12 +54,20 @@ 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 *add_reduce __P((action *, int, int));
+static action *add_reductions __P((int, action *));
+static void defreds __P((void));
+static void find_final_state __P((void));
+static void free_action_row __P((action *));
+static action *get_shifts __P((int));
+static action *parse_actions __P((int));
+static void remove_conflicts __P((void));
+static int sole_reduction __P((int));
+static void total_conflicts __P((void));
+static void unused_rules __P((void));
+void
make_parser()
{
register int i;
@@ -75,7 +84,7 @@ make_parser()
}
-action *
+static action *
parse_actions(stateno)
register int stateno;
{
@@ -87,7 +96,7 @@ register int stateno;
}
-action *
+static action *
get_shifts(stateno)
int stateno;
{
@@ -122,7 +131,7 @@ int stateno;
return (actions);
}
-action *
+static action *
add_reductions(stateno, actions)
int stateno;
register action *actions;
@@ -148,7 +157,7 @@ register action *actions;
}
-action *
+static action *
add_reduce(actions, ruleno, symbol)
register action *actions;
register int ruleno, symbol;
@@ -189,6 +198,7 @@ register int ruleno, symbol;
}
+static void
find_final_state()
{
register int goal, i;
@@ -206,6 +216,7 @@ find_final_state()
}
+static void
unused_rules()
{
register int i;
@@ -238,11 +249,12 @@ unused_rules()
}
+static void
remove_conflicts()
{
register int i;
register int symbol;
- register action *p, *pref;
+ register action *p, *pref = NULL;
SRtotal = 0;
RRtotal = 0;
@@ -313,6 +325,7 @@ remove_conflicts()
}
+static void
total_conflicts()
{
fprintf(stderr, "%s: ", myname);
@@ -333,7 +346,7 @@ total_conflicts()
}
-int
+static int
sole_reduction(stateno)
int stateno;
{
@@ -362,6 +375,7 @@ int stateno;
}
+static void
defreds()
{
register int i;
@@ -371,6 +385,7 @@ defreds()
defred[i] = sole_reduction(i);
}
+static void
free_action_row(p)
register action *p;
{
@@ -384,6 +399,7 @@ register action *p;
}
}
+void
free_parser()
{
register int i;
diff --git a/usr.bin/yacc/output.c b/usr.bin/yacc/output.c
index 7be96d54b134..d67d2c30a4fe 100644
--- a/usr.bin/yacc/output.c
+++ b/usr.bin/yacc/output.c
@@ -35,11 +35,38 @@
*/
#ifndef lint
-static char sccsid[] = "@(#)output.c 5.7 (Berkeley) 5/24/93";
+static char const sccsid[] = "@(#)output.c 5.7 (Berkeley) 5/24/93";
#endif /* not lint */
+#include <stdlib.h>
#include "defs.h"
+static int default_goto __P((int));
+static void free_itemsets __P((void));
+static void free_reductions __P((void));
+static void free_shifts __P((void));
+static void goto_actions __P((void));
+static int is_C_identifier __P((char *));
+static int matching_vector __P((int));
+static void output_actions __P((void));
+static void output_base __P((void));
+static void output_check __P((void));
+static void output_debug __P((void));
+static void output_defines __P((void));
+static void output_prefix __P((void));
+static void output_rule_data __P((void));
+static void output_semantic_actions __P((void));
+static void output_stored_text __P((void));
+static void output_stype __P((void));
+static void output_table __P((void));
+static void output_trailing_text __P((void));
+static void output_yydefred __P((void));
+static void pack_table __P((void));
+static int pack_vector __P((int));
+static void save_column __P((int, int));
+static void sort_actions __P((void));
+static void token_actions __P((void));
+
static int nvectors;
static int nentries;
static short **froms;
@@ -57,6 +84,7 @@ static int lowzero;
static int high;
+void
output()
{
free_itemsets();
@@ -80,6 +108,7 @@ output()
}
+static void
output_prefix()
{
if (symbol_prefix == NULL)
@@ -140,6 +169,7 @@ output_prefix()
}
+static void
output_rule_data()
{
register int i;
@@ -187,6 +217,7 @@ output_rule_data()
}
+static void
output_yydefred()
{
register int i, j;
@@ -214,6 +245,7 @@ output_yydefred()
}
+static void
output_actions()
{
nvectors = 2*nstates + nvars;
@@ -242,6 +274,7 @@ output_actions()
}
+static void
token_actions()
{
register int i, j;
@@ -326,6 +359,7 @@ token_actions()
FREE(actionrow);
}
+static void
goto_actions()
{
register int i, j, k;
@@ -358,7 +392,7 @@ goto_actions()
FREE(state_count);
}
-int
+static int
default_goto(symbol)
int symbol;
{
@@ -395,6 +429,7 @@ int symbol;
+static void
save_column(symbol, default_state)
int symbol;
int default_state;
@@ -437,6 +472,7 @@ int default_state;
width[symno] = sp1[-1] - sp[0] + 1;
}
+static void
sort_actions()
{
register int i;
@@ -472,6 +508,7 @@ sort_actions()
}
+static void
pack_table()
{
register int i;
@@ -534,7 +571,7 @@ pack_table()
/* faster. Also, it depends on the vectors being in a specific */
/* order. */
-int
+static int
matching_vector(vector)
int vector;
{
@@ -575,7 +612,7 @@ int vector;
-int
+static int
pack_vector(vector)
int vector;
{
@@ -653,6 +690,7 @@ int vector;
+static void
output_base()
{
register int i, j;
@@ -719,6 +757,7 @@ output_base()
+static void
output_table()
{
register int i;
@@ -751,6 +790,7 @@ output_table()
+static void
output_check()
{
register int i;
@@ -780,7 +820,7 @@ output_check()
}
-int
+static int
is_C_identifier(name)
char *name;
{
@@ -804,7 +844,7 @@ char *name;
if (!isalpha(c) && c != '_' && c != '$')
return (0);
- while (c = *++s)
+ while ((c = *++s))
{
if (!isalnum(c) && c != '_' && c != '$')
return (0);
@@ -813,6 +853,7 @@ char *name;
}
+static void
output_defines()
{
register int c, i;
@@ -841,7 +882,7 @@ output_defines()
putc(c, code_file);
if (dflag) putc(c, defines_file);
}
- while (c = *++s);
+ while ((c = *++s));
}
++outline;
fprintf(code_file, " %d\n", symbol_value[i]);
@@ -865,6 +906,7 @@ output_defines()
}
+static void
output_stored_text()
{
register int c;
@@ -892,6 +934,7 @@ output_stored_text()
}
+static void
output_debug()
{
register int i, j, k, max;
@@ -929,7 +972,7 @@ output_debug()
j = 80;
for (i = 0; i <= max; ++i)
{
- if (s = symnam[i])
+ if ((s = symnam[i]))
{
if (s[0] == '"')
{
@@ -1106,6 +1149,7 @@ output_debug()
}
+static void
output_stype()
{
if (!unionized && ntags == 0)
@@ -1116,6 +1160,7 @@ output_stype()
}
+static void
output_trailing_text()
{
register int c, last;
@@ -1173,6 +1218,7 @@ output_trailing_text()
}
+static void
output_semantic_actions()
{
register int c, last;
@@ -1210,6 +1256,7 @@ output_semantic_actions()
}
+static void
free_itemsets()
{
register core *cp, *next;
@@ -1223,6 +1270,7 @@ free_itemsets()
}
+static void
free_shifts()
{
register shifts *sp, *next;
@@ -1237,6 +1285,7 @@ free_shifts()
+static void
free_reductions()
{
register reductions *rp, *next;
diff --git a/usr.bin/yacc/reader.c b/usr.bin/yacc/reader.c
index 0a46f2996478..ac54f96d07f9 100644
--- a/usr.bin/yacc/reader.c
+++ b/usr.bin/yacc/reader.c
@@ -35,9 +35,11 @@
*/
#ifndef lint
-static char sccsid[] = "@(#)reader.c 5.7 (Berkeley) 1/20/91";
+static char const sccsid[] = "@(#)reader.c 5.7 (Berkeley) 1/20/91";
#endif /* not lint */
+#include <stdlib.h>
+#include <string.h>
#include "defs.h"
/* The line size must be a positive integer. One hundred was chosen */
@@ -73,7 +75,44 @@ char *name_pool;
char line_format[] = "#line %d \"%s\"\n";
-
+static void add_symbol __P((void));
+static void advance_to_start __P((void));
+static void cachec __P((int));
+static void check_symbols __P((void));
+static void copy_action __P((void));
+static void copy_ident __P((void));
+static void copy_text __P((void));
+static void copy_union __P((void));
+static void declare_start __P((void));
+static void declare_tokens __P((int));
+static void declare_types __P((void));
+static char *dup_line __P((void));
+static void end_rule __P((void));
+static void expand_items __P((void));
+static void expand_rules __P((void));
+static void free_tags __P((void));
+static void get_line __P((void));
+static bucket *get_literal __P((void));
+static bucket *get_name __P((void));
+static int get_number __P((void));
+static char *get_tag __P((void));
+static int hexval __P((int));
+static void initialize_grammar __P((void));
+static void insert_empty_rule __P((void));
+static int is_reserved __P((char *));
+static int keyword __P((void));
+static int mark_symbol __P((void));
+static int nextc __P((void));
+static void pack_grammar __P((void));
+static void pack_names __P((void));
+static void pack_symbols __P((void));
+static void print_grammar __P((void));
+static void read_declarations __P((void));
+static void read_grammar __P((void));
+static void skip_comment __P((void));
+static void start_rule __P((bucket *, int));
+
+static void
cachec(c)
int c;
{
@@ -89,6 +128,7 @@ int c;
}
+static void
get_line()
{
register FILE *f = input_file;
@@ -135,7 +175,7 @@ get_line()
}
-char *
+static char *
dup_line()
{
register char *p, *s, *t;
@@ -153,6 +193,7 @@ dup_line()
}
+static void
skip_comment()
{
register char *s;
@@ -183,7 +224,7 @@ skip_comment()
}
-int
+static int
nextc()
{
register char *s;
@@ -245,7 +286,7 @@ nextc()
}
-int
+static int
keyword()
{
register int c;
@@ -305,9 +346,11 @@ keyword()
}
syntax_error(lineno, line, t_cptr);
/*NOTREACHED*/
+ return (0);
}
+static void
copy_ident()
{
register int c;
@@ -337,6 +380,7 @@ copy_ident()
}
+static void
copy_text()
{
register int c;
@@ -468,6 +512,7 @@ loop:
}
+static void
copy_union()
{
register int c;
@@ -608,7 +653,7 @@ loop:
}
-int
+static int
hexval(c)
int c;
{
@@ -622,7 +667,7 @@ int c;
}
-bucket *
+static bucket *
get_literal()
{
register int c, quote;
@@ -761,7 +806,7 @@ get_literal()
}
-int
+static int
is_reserved(name)
char *name;
{
@@ -783,7 +828,7 @@ char *name;
}
-bucket *
+static bucket *
get_name()
{
register int c;
@@ -799,7 +844,7 @@ get_name()
}
-int
+static int
get_number()
{
register int c;
@@ -813,7 +858,7 @@ get_number()
}
-char *
+static char *
get_tag()
{
register int c;
@@ -864,6 +909,7 @@ get_tag()
}
+static void
declare_tokens(assoc)
int assoc;
{
@@ -926,6 +972,7 @@ int assoc;
}
+static void
declare_types()
{
register int c;
@@ -954,6 +1001,7 @@ declare_types()
}
+static void
declare_start()
{
register int c;
@@ -972,6 +1020,7 @@ declare_start()
}
+static void
read_declarations()
{
register int c, k;
@@ -1021,6 +1070,7 @@ read_declarations()
}
+static void
initialize_grammar()
{
nitems = 4;
@@ -1052,6 +1102,7 @@ initialize_grammar()
}
+static void
expand_items()
{
maxitems += 300;
@@ -1060,6 +1111,7 @@ expand_items()
}
+static void
expand_rules()
{
maxrules += 100;
@@ -1072,6 +1124,7 @@ expand_rules()
}
+static void
advance_to_start()
{
register int c;
@@ -1122,6 +1175,7 @@ advance_to_start()
}
+static void
start_rule(bp, s_lineno)
register bucket *bp;
int s_lineno;
@@ -1137,6 +1191,7 @@ int s_lineno;
}
+static void
end_rule()
{
register int i;
@@ -1156,6 +1211,7 @@ end_rule()
}
+static void
insert_empty_rule()
{
register bucket *bp, **bpp;
@@ -1172,7 +1228,7 @@ insert_empty_rule()
expand_items();
bpp = pitem + nitems - 1;
*bpp-- = bp;
- while (bpp[0] = bpp[-1]) --bpp;
+ while ((bpp[0] = bpp[-1])) --bpp;
if (++nrules >= maxrules)
expand_rules();
@@ -1185,6 +1241,7 @@ insert_empty_rule()
}
+static void
add_symbol()
{
register int c;
@@ -1216,6 +1273,7 @@ add_symbol()
}
+static void
copy_action()
{
register int c;
@@ -1439,11 +1497,11 @@ loop:
}
-int
+static int
mark_symbol()
{
register int c;
- register bucket *bp;
+ register bucket *bp = NULL;
c = cptr[1];
if (c == '%' || c == '\\')
@@ -1483,6 +1541,7 @@ mark_symbol()
}
+static void
read_grammar()
{
register int c;
@@ -1516,6 +1575,7 @@ read_grammar()
}
+static void
free_tags()
{
register int i;
@@ -1531,6 +1591,7 @@ free_tags()
}
+static void
pack_names()
{
register bucket *bp;
@@ -1549,13 +1610,14 @@ pack_names()
{
p = t;
s = bp->name;
- while (*t++ = *s++) continue;
+ while ((*t++ = *s++)) continue;
FREE(bp->name);
bp->name = p;
}
}
+static void
check_symbols()
{
register bucket *bp;
@@ -1574,6 +1636,7 @@ check_symbols()
}
+static void
pack_symbols()
{
register bucket *bp;
@@ -1698,6 +1761,7 @@ pack_symbols()
}
+static void
pack_grammar()
{
register int i, j;
@@ -1757,10 +1821,11 @@ pack_grammar()
}
+static void
print_grammar()
{
register int i, j, k;
- int spacing;
+ int spacing = 0;
register FILE *f = verbose_file;
if (!vflag) return;
@@ -1793,6 +1858,7 @@ print_grammar()
}
+void
reader()
{
write_section(banner);
diff --git a/usr.bin/yacc/skeleton.c b/usr.bin/yacc/skeleton.c
index e7a4ff31e112..0562e1829db8 100644
--- a/usr.bin/yacc/skeleton.c
+++ b/usr.bin/yacc/skeleton.c
@@ -35,7 +35,7 @@
*/
#ifndef lint
-static char sccsid[] = "@(#)skeleton.c 5.8 (Berkeley) 4/29/95";
+static char const sccsid[] = "@(#)skeleton.c 5.8 (Berkeley) 4/29/95";
#endif /* not lint */
#include "defs.h"
@@ -370,6 +370,7 @@ char *trailer[] =
};
+void
write_section(section)
char *section[];
{
@@ -379,10 +380,10 @@ char *section[];
register FILE *f;
f = code_file;
- for (i = 0; s = section[i]; ++i)
+ for (i = 0; (s = section[i]); ++i)
{
++outline;
- while (c = *s)
+ while ((c = *s))
{
putc(c, f);
++s;
diff --git a/usr.bin/yacc/symtab.c b/usr.bin/yacc/symtab.c
index 0c5f55c535b8..5b0bca027b4b 100644
--- a/usr.bin/yacc/symtab.c
+++ b/usr.bin/yacc/symtab.c
@@ -35,9 +35,11 @@
*/
#ifndef lint
-static char sccsid[] = "@(#)symtab.c 5.3 (Berkeley) 6/1/90";
+static char const sccsid[] = "@(#)symtab.c 5.3 (Berkeley) 6/1/90";
#endif /* not lint */
+#include <stdlib.h>
+#include <string.h>
#include "defs.h"
/* TABLE_SIZE is the number of entries in the symbol table. */
@@ -45,13 +47,14 @@ static char sccsid[] = "@(#)symtab.c 5.3 (Berkeley) 6/1/90";
#define TABLE_SIZE 1024
+static int hash __P((char *));
bucket **symbol_table;
bucket *first_symbol;
bucket *last_symbol;
-int
+static int
hash(name)
char *name;
{
@@ -61,7 +64,7 @@ char *name;
assert(name && *name);
s = name;
k = *s;
- while (c = *++s)
+ while ((c = *++s))
k = (31*k + c) & (TABLE_SIZE - 1);
return (k);
@@ -119,6 +122,7 @@ char *name;
}
+void
create_symbol_table()
{
register int i;
@@ -139,6 +143,7 @@ create_symbol_table()
}
+void
free_symbol_table()
{
FREE(symbol_table);
@@ -146,6 +151,7 @@ free_symbol_table()
}
+void
free_symbols()
{
register bucket *p, *q;
diff --git a/usr.bin/yacc/verbose.c b/usr.bin/yacc/verbose.c
index 33ae265ee2eb..e288eb1fe365 100644
--- a/usr.bin/yacc/verbose.c
+++ b/usr.bin/yacc/verbose.c
@@ -35,13 +35,26 @@
*/
#ifndef lint
-static char sccsid[] = "@(#)verbose.c 5.3 (Berkeley) 1/20/91";
+static char const sccsid[] = "@(#)verbose.c 5.3 (Berkeley) 1/20/91";
#endif /* not lint */
+#include <stdlib.h>
#include "defs.h"
+static void log_unused __P((void));
+static void log_conflicts __P((void));
+static void print_actions __P((int));
+static void print_conflicts __P((int));
+static void print_core __P((int));
+static void print_gotos __P((int));
+static void print_nulls __P((int));
+static void print_reductions __P((register action *, register int));
+static void print_shifts __P((register action *));
+static void print_state __P((int));
+
static short *null_rules;
+void
verbose()
{
register int i;
@@ -66,6 +79,7 @@ verbose()
}
+static void
log_unused()
{
register int i;
@@ -85,6 +99,7 @@ log_unused()
}
+static void
log_conflicts()
{
register int i;
@@ -113,6 +128,7 @@ log_conflicts()
}
+static void
print_state(state)
int state;
{
@@ -127,10 +143,11 @@ int state;
}
+static void
print_conflicts(state)
int state;
{
- register int symbol, act, number;
+ register int symbol, act = 0, number = 0;
register action *p;
symbol = -1;
@@ -175,6 +192,7 @@ int state;
}
+static void
print_core(state)
int state;
{
@@ -211,6 +229,7 @@ int state;
}
+static void
print_nulls(state)
int state;
{
@@ -255,6 +274,7 @@ int state;
}
+static void
print_actions(stateno)
int stateno;
{
@@ -282,6 +302,7 @@ int stateno;
}
+static void
print_shifts(p)
register action *p;
{
@@ -307,6 +328,7 @@ register action *p;
}
+static void
print_reductions(p, defred)
register action *p;
register int defred;
@@ -345,6 +367,7 @@ register int defred;
}
+static void
print_gotos(stateno)
int stateno;
{
diff --git a/usr.bin/yacc/warshall.c b/usr.bin/yacc/warshall.c
index 4672244e3681..1ac491966549 100644
--- a/usr.bin/yacc/warshall.c
+++ b/usr.bin/yacc/warshall.c
@@ -35,11 +35,14 @@
*/
#ifndef lint
-static char sccsid[] = "@(#)warshall.c 5.4 (Berkeley) 5/24/93";
+static char const sccsid[] = "@(#)warshall.c 5.4 (Berkeley) 5/24/93";
#endif /* not lint */
#include "defs.h"
+static void transitive_closure __P((unsigned *, int));
+
+static void
transitive_closure(R, n)
unsigned *R;
int n;
@@ -92,6 +95,7 @@ int n;
}
}
+void
reflexive_transitive_closure(R, n)
unsigned *R;
int n;