xref: /openbsd/usr.bin/yacc/yacc.1 (revision db3296cf)
1.\"	$OpenBSD: yacc.1,v 1.16 2003/06/10 09:12:13 jmc Exp $
2.\"
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.
17.\" 3. Neither the name of the University nor the names of its contributors
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.\"
35.Dd July 30, 1991
36.Dt YACC 1
37.Os
38.Sh NAME
39.Nm yacc
40.Nd an
41.Tn LALR(1)
42parser generator
43.Sh SYNOPSIS
44.Nm yacc
45.Op Fl dlrtv
46.Op Fl b Ar prefix
47.Op Fl o Ar output_file
48.Op Fl p Ar symbol_prefix
49.Ar filename
50.Sh DESCRIPTION
51.Nm
52reads the grammar specification in the file
53.Ar filename
54and generates an
55.Tn LR(1)
56parser for it.
57The parsers consist of a set of
58.Tn LALR(1)
59parsing tables and a driver routine
60written in the C programming language.
61.Nm
62normally writes the parse tables and the driver routine to the file
63.Pa y.tab.c .
64.Pp
65The options are as follows:
66.Bl -tag -width Ds
67.It Fl b Ar prefix
68The
69.Fl b
70option changes the prefix prepended to the output file names to
71the string denoted by
72.Ar prefix .
73The default prefix is the character
74.Ar y .
75.It Fl d
76The
77.Fl d
78option causes the header file
79.Pa y.tab.h
80to be written.
81.It Fl l
82If the
83.Fl l
84option is not specified,
85.Nm
86will insert #line directives in the generated code.
87The #line directives let the C compiler relate errors in the
88generated code to the user's original code.
89If the
90.Fl l
91option is specified,
92.Nm
93will not insert the #line directives.
94#line directives specified by the user will be retained.
95.It Fl o Ar output_file
96The
97.Fl o
98option specifies an explicit name for the parser's output file name instead
99of the default.
100The names of the other output files are constructed from
101.Pa output_file
102as described under the
103.Fl d
104and
105.Fl v
106options.
107.It Fl p Ar symbol_prefix
108The
109.Fl p
110option changes the prefix prepended to yacc-generated symbols to
111the string denoted by
112.Ar symbol_prefix .
113The default prefix is the string
114.Ar yy .
115.It Fl r
116The
117.Fl r
118option causes
119.Nm
120to produce separate files for code and tables.
121The code file is named
122.Pa y.code.c ,
123and the tables file is named
124.Pa y.tab.c .
125.It Fl t
126The
127.Fl t
128option changes the preprocessor directives generated by
129.Nm
130so that debugging statements will be incorporated in the compiled code.
131.It Fl v
132The
133.Fl v
134option causes a human-readable description of the generated parser to
135be written to the file
136.Pa y.output .
137.El
138.Sh ENVIRONMENT
139.Bl -tag -width TMPDIR
140.It Ev TMPDIR
141Name of directory where temporary files are to be created.
142.El
143.Sh TABLES
144The names of the tables generated by this version of
145.Nm
146are
147.Dq yylhs ,
148.Dq yylen ,
149.Dq yydefred ,
150.Dq yydgoto ,
151.Dq yysindex ,
152.Dq yyrindex ,
153.Dq yygindex ,
154.Dq yytable ,
155and
156.Dq yycheck .
157Two additional tables,
158.Dq yyname
159and
160.Dq yyrule ,
161are created if
162.Dv YYDEBUG
163is defined and non-zero.
164.Sh FILES
165.Bl -tag -width /tmp/yacc.uXXXXXXXXXX -compact
166.It Pa y.code.c
167.It Pa y.tab.c
168.It Pa y.tab.h
169.It Pa y.output
170.It Pa /tmp/yacc.aXXXXXXXXXX
171.It Pa /tmp/yacc.tXXXXXXXXXX
172.It Pa /tmp/yacc.uXXXXXXXXXX
173.El
174.Sh DIAGNOSTICS
175If there are rules that are never reduced, the number of such rules is
176written to the standard error.
177If there are any
178.Tn LALR(1)
179conflicts, the number of conflicts is also written
180to the standard error.
181.Sh SEE ALSO
182.Xr yyfix 1
183.Sh STANDARDS
184The
185.Nm
186utility conforms to
187.St -p1003.2 .
188