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