minor rewording, no fixes
[unix-history] / usr / src / usr.bin / yacc / yacc.1
CommitLineData
f3ace67d 1.\" Copyright (c) 1989, 1990 The Regents of the University of California.
c89a75cf
KB
2.\" All rights reserved.
3.\"
4.\" This code is derived from software contributed to Berkeley by
5.\" Robert Paul Corbett.
6.\"
f3ace67d 7.\" %sccs.include.redist.roff%
c89a75cf 8.\"
a023ab7e 9.\" @(#)yacc.1 5.7 (Berkeley) %G%
c89a75cf 10.\"
f3ace67d
CL
11.Dd
12.Dt YACC 1
13.Os
14.Sh NAME
15.Nm yacc
16.Nd an
17.Tn LALR(1)
18parser generator
19.Sh SYNOPSIS
20.Nm yacc
21.Op Fl dlrtv
22.Op Fl b Ar prefix
23.Ar filename
24.Sh DESCRIPTION
25.Nm Yacc
c89a75cf 26reads the grammar specification in the file
f3ace67d
CL
27.Ar filename
28and generates an
29.Tn LR(1)
30parser for it.
31The parsers consist of a set of
32.Tn LALR(1)
33parsing tables and a driver routine
c89a75cf 34written in the C programming language.
f3ace67d 35.Nm Yacc
c89a75cf 36normally writes the parse tables and the driver routine to the file
f3ace67d
CL
37.Pa y.tab.c .
38.Pp
c89a75cf 39The following options are available:
f3ace67d
CL
40.Bl -tag -width Ar
41.It Fl b Ar prefix
c89a75cf 42The
f3ace67d 43.Fl b
c89a75cf
KB
44option changes the prefix prepended to the output file names to
45the string denoted by
f3ace67d 46.Ar prefix .
c89a75cf 47The default prefix is the character
f3ace67d
CL
48.Ar y .
49.It Fl d
50The
51.Fl d
52option causes the header file
53.Pa y.tab.h
c89a75cf 54to be written.
f3ace67d 55.It Fl l
c89a75cf 56If the
f3ace67d 57.Fl l
c89a75cf 58option is not specified,
f3ace67d 59.Nm yacc
c89a75cf
KB
60will insert \#line directives in the generated code.
61The \#line directives let the C compiler relate errors in the
62generated code to the user's original code.
f3ace67d
CL
63If the
64.Fl l
65option is specified,
66.Nm yacc
c89a75cf 67will not insert the \#line directives.
42ddc0cc 68\&\#line directives specified by the user will be retained.
f3ace67d 69.It Fl r
42ddc0cc 70The
f3ace67d 71.Fl r
42ddc0cc 72option causes
f3ace67d 73.Nm yacc
42ddc0cc
BC
74to produce separate files for code and tables.
75The code file is named
f3ace67d 76.Pa y.code.c ,
42ddc0cc 77and the tables file is named
f3ace67d
CL
78.Pa y.tab.c .
79.It Fl t
c89a75cf 80The
f3ace67d 81.Fl t
42ddc0cc 82option changes the preprocessor directives generated by
f3ace67d 83.Nm yacc
c89a75cf 84so that debugging statements will be incorporated in the compiled code.
f3ace67d 85.It Fl v
c89a75cf 86The
f3ace67d 87.Fl v
c89a75cf
KB
88option causes a human-readable description of the generated parser to
89be written to the file
f3ace67d
CL
90.Pa y.output .
91.Pp
92.Sh ENVIRONMENT
93The following environment variable is referenced by
94.Nm yacc :
95.Bl -tag -width TMPDIR
96.It Ev TMPDIR
97If the environment variable
98.Ev TMPDIR
99is set, the string denoted by
100.Ev TMPDIR
101will be used as the name of the directory where the temporary
c89a75cf 102files are created.
f3ace67d
CL
103.El
104.Sh TABLES
fd572324 105The names of the tables generated by this version of
f3ace67d
CL
106.Nm yacc
107are
108.Dq yylhs ,
109.Dq yylen ,
110.Dq yydefred ,
111.Dq yydgoto ,
112.Dq yysindex ,
113.Dq yyrindex ,
114.Dq yygindex ,
115.Dq yytable ,
116and
117.Dq yycheck .
118Two additional tables,
119.Dq yyname
120and
121.Dq yyrule ,
122are created if
123.Dv YYDEBUG
124is defined and non-zero.
125.Sh FILES
a023ab7e 126.Bl -tag -width /tmp/yacc.uXXXXXXXX -compact
f3ace67d
CL
127.It Pa y.code.c
128.It Pa y.tab.c
129.It Pa y.tab.h
130.It Pa y.output
131.It Pa /tmp/yacc.aXXXXXX
132.It Pa /tmp/yacc.tXXXXXX
133.It Pa /tmp/yacc.uXXXXXX
134.El
135.Sh DIAGNOSTICS
c89a75cf 136If there are rules that are never reduced, the number of such rules is
f3ace67d
CL
137written to the standard error.
138If there are any
139.Tn LALR(1)
140conflicts, the number of conflicts is also written
141to the standard error.
142.Sh SEE ALSO
143.Xr yyfix 1
144.Sh STANDARDS
145The
146.Nm yacc
147utility conforms to
148.St -p1003.2 .