summaryrefslogtreecommitdiffstats
path: root/usr.bin
diff options
context:
space:
mode:
authorcharnier <charnier@FreeBSD.org>1997-08-28 06:33:53 +0000
committercharnier <charnier@FreeBSD.org>1997-08-28 06:33:53 +0000
commit0497c512b62944e105314fca99083da5644b48ba (patch)
tree38cf54f3951d6372a5c57233ee94f3828637cf07 /usr.bin
parent301a83d5c0bd9ed745ccf115a2e2a94696a9bf37 (diff)
downloadFreeBSD-src-0497c512b62944e105314fca99083da5644b48ba.zip
FreeBSD-src-0497c512b62944e105314fca99083da5644b48ba.tar.gz
Use err(3). Rewrote man page in mdoc format. The user visible change is that
report of s/r and r/r conflicts is now printed in two separate lines beginning by `yacc: '.
Diffstat (limited to 'usr.bin')
-rw-r--r--usr.bin/yacc/defs.h3
-rw-r--r--usr.bin/yacc/error.c115
-rw-r--r--usr.bin/yacc/main.c12
-rw-r--r--usr.bin/yacc/mkpar.c24
-rw-r--r--usr.bin/yacc/yacc.1165
5 files changed, 148 insertions, 171 deletions
diff --git a/usr.bin/yacc/defs.h b/usr.bin/yacc/defs.h
index 237efe2..229eacc 100644
--- a/usr.bin/yacc/defs.h
+++ b/usr.bin/yacc/defs.h
@@ -34,12 +34,13 @@
* SUCH DAMAGE.
*
* @(#)defs.h 5.6 (Berkeley) 5/24/93
- * $Id$
+ * $Id: defs.h,v 1.5 1997/02/22 19:57:58 peter Exp $
*/
#include <sys/cdefs.h> /* for __P macro */
#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 3ccfb14..0e789ec 100644
--- a/usr.bin/yacc/error.c
+++ b/usr.bin/yacc/error.c
@@ -32,12 +32,14 @@
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
- *
- * $Id$
*/
#ifndef lint
+#if 0
static char const sccsid[] = "@(#)error.c 5.3 (Berkeley) 6/1/90";
+#endif
+static const char rcsid[] =
+ "$Id$";
#endif /* not lint */
/* routines for printing error messages */
@@ -50,7 +52,7 @@ void
fatal(msg)
char *msg;
{
- fprintf(stderr, "%s: f - %s\n", myname, msg);
+ warnx("f - %s", msg);
done(2);
}
@@ -58,7 +60,7 @@ char *msg;
void
no_space()
{
- fprintf(stderr, "%s: f - out of space\n", myname);
+ warnx("f - out of space");
done(2);
}
@@ -67,7 +69,7 @@ void
open_error(filename)
char *filename;
{
- fprintf(stderr, "%s: f - cannot open \"%s\"\n", myname, filename);
+ warnx("f - cannot open \"%s\"", filename);
done(2);
}
@@ -75,8 +77,8 @@ char *filename;
void
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);
}
@@ -115,8 +117,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);
}
@@ -128,8 +130,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);
}
@@ -141,8 +143,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);
}
@@ -154,8 +156,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);
}
@@ -167,8 +169,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);
}
@@ -178,8 +180,8 @@ void
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);
}
@@ -191,8 +193,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);
}
@@ -202,8 +203,7 @@ void
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);
}
@@ -213,8 +213,8 @@ void
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);
}
@@ -223,8 +223,8 @@ void
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);
}
@@ -233,8 +233,8 @@ void
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);
}
@@ -242,8 +242,8 @@ void
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);
}
@@ -251,8 +251,8 @@ void
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);
}
@@ -260,8 +260,8 @@ void
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);
}
@@ -269,16 +269,16 @@ token\n", myname, lineno, input_file_name, s);
void
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);
}
void
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);
}
@@ -287,8 +287,8 @@ void
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);
}
@@ -296,8 +296,8 @@ of a production\n", myname, s_lineno, input_file_name);
void
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);
}
@@ -307,8 +307,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);
}
@@ -319,8 +319,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);
}
@@ -330,8 +330,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);
}
@@ -340,8 +339,7 @@ char *a_cptr;
void
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);
}
@@ -351,8 +349,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);
}
@@ -361,8 +359,7 @@ void
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);
}
@@ -370,8 +367,8 @@ int i;
void
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);
}
@@ -379,7 +376,7 @@ void
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);
}
@@ -388,5 +385,5 @@ void
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 fb8fa71..a683855 100644
--- a/usr.bin/yacc/main.c
+++ b/usr.bin/yacc/main.c
@@ -32,8 +32,6 @@
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
- *
- * $Id: main.c,v 1.5 1997/01/12 21:29:47 steve Exp $
*/
#ifndef lint
@@ -43,7 +41,11 @@ static char const copyright[] =
#endif /* not lint */
#ifndef lint
+#if 0
static char const sccsid[] = "@(#)main.c 5.5 (Berkeley) 5/24/93";
+#endif
+static const char rcsid[] =
+ "$Id$";
#endif /* not lint */
#include <signal.h>
@@ -60,7 +62,6 @@ char vflag;
char *symbol_prefix;
char *file_prefix = "y";
-char *myname = "yacc";
char *temp_form = "yacc.XXXXXXX";
int lineno;
@@ -156,7 +157,9 @@ set_signals()
static void
usage()
{
- fprintf(stderr, "usage: %s [-dlrtv] [-b file_prefix] [-o output_file_name] [-p symbol_prefix] filename\n", myname);
+ fprintf(stderr, "%s\n%s\n",
+ "usage: yacc [-dlrtv] [-b file_prefix] [-o output_filename]",
+ " [-p symbol_prefix] filename");
exit(1);
}
@@ -169,7 +172,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 bb59d9d..212a79b 100644
--- a/usr.bin/yacc/mkpar.c
+++ b/usr.bin/yacc/mkpar.c
@@ -32,12 +32,14 @@
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
- *
- * $Id$
*/
#ifndef lint
+#if 0
static char const sccsid[] = "@(#)mkpar.c 5.3 (Berkeley) 1/20/91";
+#endif
+static const char rcsid[] =
+ "$Id$";
#endif /* not lint */
#include <stdlib.h>
@@ -245,9 +247,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);
}
@@ -330,21 +332,15 @@ remove_conflicts()
static void
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 596d154..f532779 100644
--- a/usr.bin/yacc/yacc.1
+++ b/usr.bin/yacc/yacc.1
@@ -33,125 +33,106 @@
.\" SUCH DAMAGE.
.\"
.\" @(#)yacc.1 5.8 (Berkeley) 5/24/93
-.\" $Id: yacc.1,v 1.6 1997/02/22 19:58:04 peter Exp $
+.\" $Id: yacc.1,v 1.7 1997/05/14 02:33:08 steve Exp $
.\"
-.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 ] [ -o
-.I output_filename
-.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 o Ar output_filename
+.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-o \fIoutput_filename\fR
-The
-.B -o
-option causes
-.I yacc
+.It Fl o Ar output_filename
+Cause
+.Nm
to write the generated code to
-.IR output_filename
+.Ar output_filename
instead of the default file,
-.IR y.tab.c .
-.TP
-\fB-p \fIsymbol_prefix\fR
-The
-.B -p
-option changes the prefix prepended to yacc-generated symbols to
+.Pa y.tab.c .
+.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
OpenPOWER on IntegriCloud