diff options
| author | Philippe Charnier <charnier@FreeBSD.org> | 1997-08-29 11:40:46 +0000 |
|---|---|---|
| committer | Philippe Charnier <charnier@FreeBSD.org> | 1997-08-29 11:40:46 +0000 |
| commit | b6b01994bd99e1f06c27f95fd548a18f47f366b7 (patch) | |
| tree | 4cf3ed3b29df7d1ef82c14c3196d768f693dcd85 | |
| parent | ee41216cbef4876941f47273db6ba7266a6d9683 (diff) | |
Notes
| -rw-r--r-- | usr.bin/yacc/defs.h | 1 | ||||
| -rw-r--r-- | usr.bin/yacc/error.c | 113 | ||||
| -rw-r--r-- | usr.bin/yacc/main.c | 10 | ||||
| -rw-r--r-- | usr.bin/yacc/mkpar.c | 22 | ||||
| -rw-r--r-- | usr.bin/yacc/yacc.1 | 147 |
5 files changed, 140 insertions, 153 deletions
diff --git a/usr.bin/yacc/defs.h b/usr.bin/yacc/defs.h index e5e96d2fe571..cc9f88a90b8a 100644 --- a/usr.bin/yacc/defs.h +++ b/usr.bin/yacc/defs.h @@ -38,6 +38,7 @@ #include <assert.h> #include <ctype.h> +#include <err.h> #include <stdio.h> diff --git a/usr.bin/yacc/error.c b/usr.bin/yacc/error.c index 54a49ad01b43..8cf7dbab1f14 100644 --- a/usr.bin/yacc/error.c +++ b/usr.bin/yacc/error.c @@ -35,7 +35,11 @@ */ #ifndef lint +#if 0 static char sccsid[] = "@(#)error.c 5.3 (Berkeley) 6/1/90"; +#endif +static const char rcsid[] = + "$Id$"; #endif /* not lint */ /* routines for printing error messages */ @@ -46,14 +50,14 @@ static char sccsid[] = "@(#)error.c 5.3 (Berkeley) 6/1/90"; fatal(msg) char *msg; { - fprintf(stderr, "%s: f - %s\n", myname, msg); + warnx("f - %s", msg); done(2); } no_space() { - fprintf(stderr, "%s: f - out of space\n", myname); + warnx("f - out of space"); done(2); } @@ -61,15 +65,15 @@ no_space() open_error(filename) char *filename; { - fprintf(stderr, "%s: f - cannot open \"%s\"\n", myname, filename); + warnx("f - cannot open \"%s\"", filename); done(2); } unexpected_EOF() { - fprintf(stderr, "%s: e - line %d of \"%s\", unexpected end-of-file\n", - myname, lineno, input_file_name); + warnx("e - line %d of \"%s\", unexpected end-of-file", + lineno, input_file_name); done(1); } @@ -106,8 +110,8 @@ int st_lineno; char *st_line; char *st_cptr; { - fprintf(stderr, "%s: e - line %d of \"%s\", syntax error\n", - myname, st_lineno, input_file_name); + warnx("e - line %d of \"%s\", syntax error", + st_lineno, input_file_name); print_pos(st_line, st_cptr); done(1); } @@ -118,8 +122,8 @@ int c_lineno; char *c_line; char *c_cptr; { - fprintf(stderr, "%s: e - line %d of \"%s\", unmatched /*\n", - myname, c_lineno, input_file_name); + warnx("e - line %d of \"%s\", unmatched /*", + c_lineno, input_file_name); print_pos(c_line, c_cptr); done(1); } @@ -130,8 +134,8 @@ int s_lineno; char *s_line; char *s_cptr; { - fprintf(stderr, "%s: e - line %d of \"%s\", unterminated string\n", - myname, s_lineno, input_file_name); + warnx("e - line %d of \"%s\", unterminated string", + s_lineno, input_file_name); print_pos(s_line, s_cptr); done(1); } @@ -142,8 +146,8 @@ int t_lineno; char *t_line; char *t_cptr; { - fprintf(stderr, "%s: e - line %d of \"%s\", unmatched %%{\n", - myname, t_lineno, input_file_name); + warnx("e - line %d of \"%s\", unmatched %%{", + t_lineno, input_file_name); print_pos(t_line, t_cptr); done(1); } @@ -154,8 +158,8 @@ int u_lineno; char *u_line; char *u_cptr; { - fprintf(stderr, "%s: e - line %d of \"%s\", unterminated %%union \ -declaration\n", myname, u_lineno, input_file_name); + warnx("e - line %d of \"%s\", unterminated %%union declaration", + u_lineno, input_file_name); print_pos(u_line, u_cptr); done(1); } @@ -164,8 +168,8 @@ declaration\n", myname, u_lineno, input_file_name); over_unionized(u_cptr) char *u_cptr; { - fprintf(stderr, "%s: e - line %d of \"%s\", too many %%union \ -declarations\n", myname, lineno, input_file_name); + warnx("e - line %d of \"%s\", too many %%union declarations", + lineno, input_file_name); print_pos(line, u_cptr); done(1); } @@ -176,8 +180,7 @@ int t_lineno; char *t_line; char *t_cptr; { - fprintf(stderr, "%s: e - line %d of \"%s\", illegal tag\n", - myname, t_lineno, input_file_name); + warnx("e - line %d of \"%s\", illegal tag", t_lineno, input_file_name); print_pos(t_line, t_cptr); done(1); } @@ -186,8 +189,7 @@ char *t_cptr; illegal_character(c_cptr) char *c_cptr; { - fprintf(stderr, "%s: e - line %d of \"%s\", illegal character\n", - myname, lineno, input_file_name); + warnx("e - line %d of \"%s\", illegal character", lineno, input_file_name); print_pos(line, c_cptr); done(1); } @@ -196,8 +198,8 @@ char *c_cptr; used_reserved(s) char *s; { - fprintf(stderr, "%s: e - line %d of \"%s\", illegal use of reserved symbol \ -%s\n", myname, lineno, input_file_name, s); + warnx("e - line %d of \"%s\", illegal use of reserved symbol %s", + lineno, input_file_name, s); done(1); } @@ -205,8 +207,8 @@ char *s; tokenized_start(s) char *s; { - fprintf(stderr, "%s: e - line %d of \"%s\", the start symbol %s cannot be \ -declared to be a token\n", myname, lineno, input_file_name, s); + warnx("e - line %d of \"%s\", the start symbol %s cannot be \ +declared to be a token", lineno, input_file_name, s); done(1); } @@ -214,47 +216,47 @@ declared to be a token\n", myname, lineno, input_file_name, s); retyped_warning(s) char *s; { - fprintf(stderr, "%s: w - line %d of \"%s\", the type of %s has been \ -redeclared\n", myname, lineno, input_file_name, s); + warnx("w - line %d of \"%s\", the type of %s has been redeclared", + lineno, input_file_name, s); } reprec_warning(s) char *s; { - fprintf(stderr, "%s: w - line %d of \"%s\", the precedence of %s has been \ -redeclared\n", myname, lineno, input_file_name, s); + warnx("w - line %d of \"%s\", the precedence of %s has been redeclared", + lineno, input_file_name, s); } revalued_warning(s) char *s; { - fprintf(stderr, "%s: w - line %d of \"%s\", the value of %s has been \ -redeclared\n", myname, lineno, input_file_name, s); + warnx("w - line %d of \"%s\", the value of %s has been redeclared", + lineno, input_file_name, s); } terminal_start(s) char *s; { - fprintf(stderr, "%s: e - line %d of \"%s\", the start symbol %s is a \ -token\n", myname, lineno, input_file_name, s); + warnx("e - line %d of \"%s\", the start symbol %s is a token", + lineno, input_file_name, s); done(1); } restarted_warning() { - fprintf(stderr, "%s: w - line %d of \"%s\", the start symbol has been \ -redeclared\n", myname, lineno, input_file_name); + warnx("w - line %d of \"%s\", the start symbol has been redeclared", + lineno, input_file_name); } no_grammar() { - fprintf(stderr, "%s: e - line %d of \"%s\", no grammar has been \ -specified\n", myname, lineno, input_file_name); + warnx("e - line %d of \"%s\", no grammar has been specified", + lineno, input_file_name); done(1); } @@ -262,16 +264,16 @@ specified\n", myname, lineno, input_file_name); terminal_lhs(s_lineno) int s_lineno; { - fprintf(stderr, "%s: e - line %d of \"%s\", a token appears on the lhs \ -of a production\n", myname, s_lineno, input_file_name); + warnx("e - line %d of \"%s\", a token appears on the lhs of a production", + s_lineno, input_file_name); done(1); } prec_redeclared() { - fprintf(stderr, "%s: w - line %d of \"%s\", conflicting %%prec \ -specifiers\n", myname, lineno, input_file_name); + warnx("w - line %d of \"%s\", conflicting %%prec specifiers", + lineno, input_file_name); } @@ -280,8 +282,8 @@ int a_lineno; char *a_line; char *a_cptr; { - fprintf(stderr, "%s: e - line %d of \"%s\", unterminated action\n", - myname, a_lineno, input_file_name); + warnx("e - line %d of \"%s\", unterminated action", + a_lineno, input_file_name); print_pos(a_line, a_cptr); done(1); } @@ -291,8 +293,8 @@ dollar_warning(a_lineno, i) int a_lineno; int i; { - fprintf(stderr, "%s: w - line %d of \"%s\", $%d references beyond the \ -end of the current rule\n", myname, a_lineno, input_file_name, i); + warnx("w - line %d of \"%s\", $%d references beyond the \ +end of the current rule", a_lineno, input_file_name, i); } @@ -301,8 +303,7 @@ int a_lineno; char *a_line; char *a_cptr; { - fprintf(stderr, "%s: e - line %d of \"%s\", illegal $-name\n", - myname, a_lineno, input_file_name); + warnx("e - line %d of \"%s\", illegal $-name", a_lineno, input_file_name); print_pos(a_line, a_cptr); done(1); } @@ -310,8 +311,7 @@ char *a_cptr; untyped_lhs() { - fprintf(stderr, "%s: e - line %d of \"%s\", $$ is untyped\n", - myname, lineno, input_file_name); + warnx("e - line %d of \"%s\", $$ is untyped", lineno, input_file_name); done(1); } @@ -320,8 +320,8 @@ untyped_rhs(i, s) int i; char *s; { - fprintf(stderr, "%s: e - line %d of \"%s\", $%d (%s) is untyped\n", - myname, lineno, input_file_name, i, s); + warnx("e - line %d of \"%s\", $%d (%s) is untyped", + lineno, input_file_name, i, s); done(1); } @@ -329,23 +329,22 @@ char *s; unknown_rhs(i) int i; { - fprintf(stderr, "%s: e - line %d of \"%s\", $%d is untyped\n", - myname, lineno, input_file_name, i); + warnx("e - line %d of \"%s\", $%d is untyped", lineno, input_file_name, i); done(1); } default_action_warning() { - fprintf(stderr, "%s: w - line %d of \"%s\", the default action assigns an \ -undefined value to $$\n", myname, lineno, input_file_name); + warnx("w - line %d of \"%s\", the default action assigns an \ +undefined value to $$", lineno, input_file_name); } undefined_goal(s) char *s; { - fprintf(stderr, "%s: e - the start symbol %s is undefined\n", myname, s); + warnx("e - the start symbol %s is undefined", s); done(1); } @@ -353,5 +352,5 @@ char *s; undefined_symbol_warning(s) char *s; { - fprintf(stderr, "%s: w - the symbol %s is undefined\n", myname, s); + warnx("w - the symbol %s is undefined", s); } diff --git a/usr.bin/yacc/main.c b/usr.bin/yacc/main.c index 79b332a237e7..ac28f5ca2659 100644 --- a/usr.bin/yacc/main.c +++ b/usr.bin/yacc/main.c @@ -41,7 +41,11 @@ char copyright[] = #endif /* not lint */ #ifndef lint +#if 0 static char sccsid[] = "@(#)main.c 5.5 (Berkeley) 5/24/93"; +#endif +static const char rcsid[] = + "$Id$"; #endif /* not lint */ #include <signal.h> @@ -55,7 +59,6 @@ char vflag; char *symbol_prefix; char *file_prefix = "y"; -char *myname = "yacc"; char *temp_form = "yacc.XXXXXXX"; int lineno; @@ -142,9 +145,11 @@ set_signals() } +static void usage() { - fprintf(stderr, "usage: %s [-dlrtv] [-b file_prefix] [-p symbol_prefix] filename\n", myname); + fprintf(stderr, + "usage: yacc [-dlrtv] [-b file_prefix] [-p symbol_prefix] filename\n"); exit(1); } @@ -156,7 +161,6 @@ char *argv[]; register int i; register char *s; - if (argc > 0) myname = argv[0]; for (i = 1; i < argc; ++i) { s = argv[i]; diff --git a/usr.bin/yacc/mkpar.c b/usr.bin/yacc/mkpar.c index b0f94b4d9fed..9846b37b7a2e 100644 --- a/usr.bin/yacc/mkpar.c +++ b/usr.bin/yacc/mkpar.c @@ -35,7 +35,11 @@ */ #ifndef lint +#if 0 static char sccsid[] = "@(#)mkpar.c 5.3 (Berkeley) 1/20/91"; +#endif +static const char rcsid[] = + "$Id$"; #endif /* not lint */ #include "defs.h" @@ -232,9 +236,9 @@ unused_rules() if (nunused) if (nunused == 1) - fprintf(stderr, "%s: 1 rule never reduced\n", myname); + warnx("1 rule never reduced"); else - fprintf(stderr, "%s: %d rules never reduced\n", myname, nunused); + warnx("%d rules never reduced", nunused); } @@ -315,21 +319,15 @@ remove_conflicts() total_conflicts() { - fprintf(stderr, "%s: ", myname); if (SRtotal == 1) - fprintf(stderr, "1 shift/reduce conflict"); + warnx("1 shift/reduce conflict"); else if (SRtotal > 1) - fprintf(stderr, "%d shift/reduce conflicts", SRtotal); - - if (SRtotal && RRtotal) - fprintf(stderr, ", "); + warnx("%d shift/reduce conflicts", SRtotal); if (RRtotal == 1) - fprintf(stderr, "1 reduce/reduce conflict"); + warnx("1 reduce/reduce conflict"); else if (RRtotal > 1) - fprintf(stderr, "%d reduce/reduce conflicts", RRtotal); - - fprintf(stderr, ".\n"); + warnx("%d reduce/reduce conflicts", RRtotal); } diff --git a/usr.bin/yacc/yacc.1 b/usr.bin/yacc/yacc.1 index 787dc0043fe0..f3abfc5a01f6 100644 --- a/usr.bin/yacc/yacc.1 +++ b/usr.bin/yacc/yacc.1 @@ -34,111 +34,96 @@ .\" .\" @(#)yacc.1 5.8 (Berkeley) 5/24/93 .\" -.TH YACC 1 "May 24, 1993" -.UC 6 -.SH NAME -yacc \- an LALR(1) parser generator -.SH SYNOPSIS -.B yacc [ -dlrtv ] [ -b -.I file_prefix -.B ] [ -p -.I symbol_prefix -.B ] -.I filename -.SH DESCRIPTION -.I Yacc +.Dd May 24, 1993 +.Dt YACC 1 +.Os +.Sh NAME +.Nm yacc +.Nd an LALR(1) parser generator +.Sh SYNOPSIS +.Nm +.Op Fl dlrtv +.Op Fl b Ar file_prefix +.Op Fl p Ar symbol_prefix +.Ar filename +.Sh DESCRIPTION +.Nm Yacc reads the grammar specification in the file -.I filename +.Ar filename and generates an LR(1) parser for it. The parsers consist of a set of LALR(1) parsing tables and a driver routine written in the C programming language. -.I Yacc +.Nm Yacc normally writes the parse tables and the driver routine to the file -.IR y.tab.c. -.PP +.Pa y.tab.c . +.Pp The following options are available: -.RS -.TP -\fB-b \fIfile_prefix\fR -The -.B -b -option changes the prefix prepended to the output file names to +.Bl -tag -width indent +.It Fl b Ar file_prefix +Change the prefix prepended to the output file names to the string denoted by -.IR file_prefix. +.Ar file_prefix . The default prefix is the character -.IR y. -.TP -.B -d -The \fB-d\fR option causes the header file -.IR y.tab.h +.Pa y . +.It Fl d +Cause the header file +.Pa y.tab.h to be written. -.TP -.B -l +.It Fl l If the -.B -l +.Fl l option is not specified, -.I yacc +.Nm will insert #line directives in the generated code. The #line directives let the C compiler relate errors in the generated code to the user's original code. -If the \fB-l\fR option is specified, -.I yacc +If the +.Fl l +option is specified, +.Nm will not insert the #line directives. Any #line directives specified by the user will be retained. -.TP -\fB-p \fIsymbol_prefix\fR -The -.B -p -option changes the prefix prepended to yacc-generated symbols to +.It Fl p Ar symbol_prefix +Change the prefix prepended to yacc-generated symbols to the string denoted by -.IR symbol_prefix. +.Ar symbol_prefix . The default prefix is the string -.IR yy. -.TP -.B -r -The -.B -r -option causes -.I yacc +.Pa yy . +.It Fl r +Cause +.Nm to produce separate files for code and tables. The code file is named -.IR y.code.c, +.Pa y.code.c , and the tables file is named -.IR y.tab.c. -.TP -.B -t -The -.B -t -option changes the preprocessor directives generated by -.I yacc +.Pa y.tab.c . +.It Fl t +Change the preprocessor directives generated by +.Nm so that debugging statements will be incorporated in the compiled code. -.TP -.B -v -The -.B -v -option causes a human-readable description of the generated parser to +.It Fl v +Cause a human-readable description of the generated parser to be written to the file -.IR y.output. -.RE -.PP -If the environment variable TMPDIR is set, the string denoted by -TMPDIR will be used as the name of the directory where the temporary +.Pa y.output . +.El +.Pp +If the environment variable +.Ev TMPDIR +is set, the string denoted by +.Ev TMPDIR +will be used as the name of the directory where the temporary files are created. -.SH FILES -.IR y.code.c -.br -.IR y.tab.c -.br -.IR y.tab.h -.br -.IR y.output -.br -.IR /tmp/yacc.aXXXXXX -.br -.IR /tmp/yacc.tXXXXXX -.br -.IR /tmp/yacc.uXXXXXX -.SH DIAGNOSTICS +.Sh FILES +.Bl -tag -width /tmp/yacc.aXXXXXX -compact +.It Pa y.code.c +.It Pa y.tab.c +.It Pa y.tab.h +.It Pa y.output +.It Pa /tmp/yacc.aXXXXXX +.It Pa /tmp/yacc.tXXXXXX +.It Pa /tmp/yacc.uXXXXXX +.El +.Sh DIAGNOSTICS If there are rules that are never reduced, the number of such rules is reported on standard error. If there are any LALR(1) conflicts, the number of conflicts is reported |
