Initial import from FreeBSD RELENG_4:
[dragonfly.git] / usr.bin / yacc / yacc.1
1 .\" Copyright (c) 1989, 1990 The Regents of the University of California.
2 .\" All rights reserved.
3 .\"
4 .\" This code is derived from software contributed to Berkeley by
5 .\" Robert Paul Corbett.
6 .\"
7 .\" Redistribution and use in source and binary forms, with or without
8 .\" modification, are permitted provided that the following conditions
9 .\" are met:
10 .\" 1. Redistributions of source code must retain the above copyright
11 .\"    notice, this list of conditions and the following disclaimer.
12 .\" 2. Redistributions in binary form must reproduce the above copyright
13 .\"    notice, this list of conditions and the following disclaimer in the
14 .\"    documentation and/or other materials provided with the distribution.
15 .\" 3. All advertising materials mentioning features or use of this software
16 .\"    must display the following acknowledgement:
17 .\"     This product includes software developed by the University of
18 .\"     California, Berkeley and its contributors.
19 .\" 4. Neither the name of the University nor the names of its contributors
20 .\"    may be used to endorse or promote products derived from this software
21 .\"    without specific prior written permission.
22 .\"
23 .\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
24 .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
25 .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
26 .\" ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
27 .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
28 .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
29 .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
30 .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
31 .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
32 .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
33 .\" SUCH DAMAGE.
34 .\"
35 .\"     @(#)yacc.1      5.8 (Berkeley) 5/24/93
36 .\" $FreeBSD: src/usr.bin/yacc/yacc.1,v 1.10.2.2 2003/02/25 03:07:40 trhodes Exp $
37 .\"
38 .Dd May 24, 1993
39 .Dt YACC 1
40 .Os
41 .Sh NAME
42 .Nm yacc
43 .Nd an LALR(1) parser generator
44 .Sh SYNOPSIS
45 .Nm
46 .Op Fl dlrtv
47 .Op Fl b Ar file_prefix
48 .Op Fl o Ar output_filename
49 .Op Fl p Ar symbol_prefix
50 .Ar filename
51 .Sh DESCRIPTION
52 The
53 .Nm
54 utility reads the grammar specification in the file
55 .Ar filename
56 and generates an LR(1) parser for it.
57 The parsers consist of a set of LALR(1) parsing tables and a driver routine
58 written in the C programming language.
59 The
60 .Nm
61 utility normally writes the parse tables and the driver routine to the file
62 .Pa y.tab.c .
63 .Pp
64 The following options are available:
65 .Bl -tag -width indent
66 .It Fl b Ar file_prefix
67 Change the prefix prepended to the output file names to
68 the string denoted by
69 .Ar file_prefix .
70 The default prefix is the character
71 .Pa y .
72 .It Fl d
73 Cause the header file
74 .Pa y.tab.h
75 to be written.
76 .It Fl l
77 If the
78 .Fl l
79 option is not specified,
80 .Nm
81 will insert #line directives in the generated code.
82 The #line directives let the C compiler relate errors in the
83 generated code to the user's original code.
84 If the
85 .Fl l
86 option is specified,
87 .Nm
88 will not insert the #line directives.
89 Any #line directives specified by the user will be retained.
90 .It Fl o Ar output_filename
91 Cause
92 .Nm
93 to write the generated code to
94 .Ar output_filename
95 instead of the default file,
96 .Pa y.tab.c .
97 .It Fl p Ar symbol_prefix
98 Change the prefix prepended to yacc-generated symbols to
99 the string denoted by
100 .Ar symbol_prefix .
101 The default prefix is the string
102 .Pa yy .
103 .It Fl r
104 Cause
105 .Nm
106 to produce separate files for code and tables.  The code file
107 is named
108 .Pa y.code.c ,
109 and the tables file is named
110 .Pa y.tab.c .
111 .It Fl t
112 Change the preprocessor directives generated by
113 .Nm
114 so that debugging statements will be incorporated in the compiled code.
115 .It Fl v
116 Cause a human-readable description of the generated parser to
117 be written to the file
118 .Pa y.output .
119 .El
120 .Sh ENVIRONMENT
121 .Bl -tag -width ".Ev TMPDIR"
122 .It Ev TMPDIR
123 Name of directory where temporary files are to be created.
124 .El
125 .Sh TABLES
126 The names of the tables generated by this version of
127 .Nm
128 are
129 .Va yylhs , yylen , yydefred , yydgoto , yysindex ,
130 .Va yyrindex , yygindex , yytable ,
131 and
132 .Va yycheck .
133 Two additional tables,
134 .Va yyname
135 and
136 .Va yyrule ,
137 are created if
138 .Dv YYDEBUG
139 is defined and non-zero.
140 .Sh FILES
141 .Bl -tag -width "Pa /tmp/yacc.aXXXXXXXXXX" -compact
142 .It Pa y.code.c
143 .It Pa y.tab.c
144 .It Pa y.tab.h
145 .It Pa y.output
146 .It Pa /tmp/yacc.aXXXXXXXXXX
147 .It Pa /tmp/yacc.tXXXXXXXXXX
148 .It Pa /tmp/yacc.uXXXXXXXXXX
149 .El
150 .Sh DIAGNOSTICS
151 If there are rules that are never reduced,
152 the number of such rules is reported on standard error.
153 If there are any
154 .Tn LALR(1)
155 conflicts,
156 the number of conflicts is reported on standard error.
157 .Sh SEE ALSO
158 .Xr yyfix 1
159 .Sh HISTORY
160 A
161 .Nm
162 command appeared in PWB UNIX.
163 .Sh STANDARDS
164 The
165 .Nm
166 utility conforms to
167 .St -p1003.2 .