Annotation of src/usr.bin/yacc/yacc.1, Revision 1.26
1.26 ! jmc 1: .\" $OpenBSD: yacc.1,v 1.25 2010/09/03 11:09:29 jmc Exp $
1.10 aaron 2: .\"
1.1 deraadt 3: .\" Copyright (c) 1989, 1990 The Regents of the University of California.
4: .\" All rights reserved.
5: .\"
6: .\" This code is derived from software contributed to Berkeley by
7: .\" Robert Paul Corbett.
8: .\"
9: .\" Redistribution and use in source and binary forms, with or without
10: .\" modification, are permitted provided that the following conditions
11: .\" are met:
12: .\" 1. Redistributions of source code must retain the above copyright
13: .\" notice, this list of conditions and the following disclaimer.
14: .\" 2. Redistributions in binary form must reproduce the above copyright
15: .\" notice, this list of conditions and the following disclaimer in the
16: .\" documentation and/or other materials provided with the distribution.
1.15 millert 17: .\" 3. Neither the name of the University nor the names of its contributors
1.1 deraadt 18: .\" may be used to endorse or promote products derived from this software
19: .\" without specific prior written permission.
20: .\"
21: .\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
22: .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
23: .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
24: .\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
25: .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
26: .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
27: .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
28: .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
29: .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
30: .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
31: .\" SUCH DAMAGE.
32: .\"
33: .\" from: @(#)yacc.1 5.7 (Berkeley) 7/30/91
34: .\"
1.26 ! jmc 35: .Dd $Mdocdate: September 3 2010 $
1.1 deraadt 36: .Dt YACC 1
37: .Os
38: .Sh NAME
39: .Nm yacc
40: .Nd an
41: .Tn LALR(1)
42: parser generator
43: .Sh SYNOPSIS
44: .Nm yacc
45: .Op Fl dlrtv
1.20 sobrado 46: .Op Fl b Ar file_prefix
1.5 aaron 47: .Op Fl o Ar output_file
1.2 deraadt 48: .Op Fl p Ar symbol_prefix
1.20 sobrado 49: .Ar file
1.1 deraadt 50: .Sh DESCRIPTION
1.10 aaron 51: .Nm
1.20 sobrado 52: reads the grammar specification in
53: .Ar file
1.1 deraadt 54: and generates an
55: .Tn LR(1)
56: parser for it.
57: The parsers consist of a set of
58: .Tn LALR(1)
59: parsing tables and a driver routine
60: written in the C programming language.
1.10 aaron 61: .Nm
1.1 deraadt 62: normally writes the parse tables and the driver routine to the file
63: .Pa y.tab.c .
64: .Pp
1.9 aaron 65: The options are as follows:
1.13 aaron 66: .Bl -tag -width Ds
1.20 sobrado 67: .It Fl b Ar file_prefix
1.1 deraadt 68: The
69: .Fl b
70: option changes the prefix prepended to the output file names to
71: the string denoted by
1.20 sobrado 72: .Ar file_prefix .
1.1 deraadt 73: The default prefix is the character
74: .Ar y .
75: .It Fl d
76: The
77: .Fl d
78: option causes the header file
79: .Pa y.tab.h
80: to be written.
81: .It Fl l
82: If the
83: .Fl l
84: option is not specified,
1.10 aaron 85: .Nm
1.1 deraadt 86: will insert #line directives in the generated code.
87: The #line directives let the C compiler relate errors in the
88: generated code to the user's original code.
89: If the
90: .Fl l
91: option is specified,
1.10 aaron 92: .Nm
1.1 deraadt 93: will not insert the #line directives.
94: #line directives specified by the user will be retained.
1.5 aaron 95: .It Fl o Ar output_file
96: The
97: .Fl o
1.8 aaron 98: option specifies an explicit name for the parser's output file name instead
1.11 aaron 99: of the default.
100: The names of the other output files are constructed from
1.8 aaron 101: .Pa output_file
102: as described under the
103: .Fl d
104: and
105: .Fl v
106: options.
1.2 deraadt 107: .It Fl p Ar symbol_prefix
108: The
109: .Fl p
110: option changes the prefix prepended to yacc-generated symbols to
111: the string denoted by
112: .Ar symbol_prefix .
113: The default prefix is the string
114: .Ar yy .
1.1 deraadt 115: .It Fl r
116: The
117: .Fl r
118: option causes
1.10 aaron 119: .Nm
1.1 deraadt 120: to produce separate files for code and tables.
121: The code file is named
122: .Pa y.code.c ,
123: and the tables file is named
124: .Pa y.tab.c .
125: .It Fl t
126: The
127: .Fl t
128: option changes the preprocessor directives generated by
1.10 aaron 129: .Nm
1.1 deraadt 130: so that debugging statements will be incorporated in the compiled code.
131: .It Fl v
132: The
133: .Fl v
134: option causes a human-readable description of the generated parser to
135: be written to the file
136: .Pa y.output .
1.12 aaron 137: .El
1.1 deraadt 138: .Sh ENVIRONMENT
139: .Bl -tag -width TMPDIR
140: .It Ev TMPDIR
1.10 aaron 141: Name of directory where temporary files are to be created.
1.1 deraadt 142: .El
143: .Sh TABLES
144: The names of the tables generated by this version of
1.10 aaron 145: .Nm
1.1 deraadt 146: are
147: .Dq yylhs ,
148: .Dq yylen ,
149: .Dq yydefred ,
150: .Dq yydgoto ,
151: .Dq yysindex ,
152: .Dq yyrindex ,
153: .Dq yygindex ,
154: .Dq yytable ,
155: and
156: .Dq yycheck .
157: Two additional tables,
158: .Dq yyname
159: and
160: .Dq yyrule ,
161: are created if
162: .Dv YYDEBUG
163: is defined and non-zero.
164: .Sh FILES
1.7 millert 165: .Bl -tag -width /tmp/yacc.uXXXXXXXXXX -compact
1.1 deraadt 166: .It Pa y.code.c
167: .It Pa y.tab.c
168: .It Pa y.tab.h
169: .It Pa y.output
1.7 millert 170: .It Pa /tmp/yacc.aXXXXXXXXXX
171: .It Pa /tmp/yacc.tXXXXXXXXXX
172: .It Pa /tmp/yacc.uXXXXXXXXXX
1.1 deraadt 173: .El
1.25 jmc 174: .Sh EXIT STATUS
175: .Ex -std yacc
1.16 jmc 176: .Sh DIAGNOSTICS
177: If there are rules that are never reduced, the number of such rules is
178: written to the standard error.
179: If there are any
180: .Tn LALR(1)
181: conflicts, the number of conflicts is also written
182: to the standard error.
1.7 millert 183: .Sh SEE ALSO
184: .Xr yyfix 1
1.1 deraadt 185: .Sh STANDARDS
186: The
1.10 aaron 187: .Nm
1.18 jmc 188: utility is compliant with the
1.21 jmc 189: .St -p1003.1-2008
1.22 jmc 190: specification,
191: though its presence is optional.
1.18 jmc 192: .Pp
193: The flags
194: .Op Fl or
195: are extensions to that specification.
1.23 jmc 196: .Sh HISTORY
1.24 jmc 197: Yacc was originally developed at AT&T by Stephen C. Johnson.
198: .Pp
1.23 jmc 199: Berkeley Yacc was originally developed using PCC on a VAX with the
200: intent of being as compatible as possible with AT&T Yacc.
201: Much is owed to the unflagging efforts of Keith Bostic.
202: His badgering kept me working on Yacc long after I was ready to
203: quit.
204: .Pp
205: Berkeley Yacc is based on the excellent algorithm for computing
206: LALR(1) lookaheads developed by Tom Pennello and Frank DeRemer.
207: The algorithm is described in their almost impenetrable article in
208: TOPLAS 4,4.
209: .Pp
210: Finally, much credit must go to those who pointed out deficiencies
211: of earlier releases.
212: Among the most prolific contributors were
213: Benson I. Margulies,
214: Dave Gentzel,
215: Antoine Verheijen,
216: Peter S. Housel,
217: Dale Smith,
218: Ozan Yigit,
219: John Campbell,
220: Bill Sommerfeld,
221: Paul Hilfinger,
222: Gary Bridgewater,
223: Dave Bakken,
224: Dan Lanciani,
225: Richard Sargent,
226: and
227: Parag Patel.
228: .Sh AUTHORS
229: The
230: .Nm
231: utility was written by
232: .An Robert Corbett .