xref: /original-bsd/usr.bin/yacc/yacc.1 (revision b9df2d9d)
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.\" %sccs.include.redist.roff%
8.\"
9.\"     @(#)yacc.1	5.7 (Berkeley) 07/30/91
10.\"
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
26reads the grammar specification in the file
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
34written in the C programming language.
35.Nm Yacc
36normally writes the parse tables and the driver routine to the file
37.Pa y.tab.c .
38.Pp
39The following options are available:
40.Bl -tag -width Ar
41.It Fl b Ar prefix
42The
43.Fl b
44option changes the prefix prepended to the output file names to
45the string denoted by
46.Ar prefix .
47The default prefix is the character
48.Ar y .
49.It Fl d
50The
51.Fl d
52option causes the header file
53.Pa y.tab.h
54to be written.
55.It Fl l
56If the
57.Fl l
58option is not specified,
59.Nm yacc
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.
63If the
64.Fl l
65option is specified,
66.Nm yacc
67will not insert the \#line directives.
68\&\#line directives specified by the user will be retained.
69.It Fl r
70The
71.Fl r
72option causes
73.Nm yacc
74to produce separate files for code and tables.
75The code file is named
76.Pa y.code.c ,
77and the tables file is named
78.Pa y.tab.c .
79.It Fl t
80The
81.Fl t
82option changes the preprocessor directives generated by
83.Nm yacc
84so that debugging statements will be incorporated in the compiled code.
85.It Fl v
86The
87.Fl v
88option causes a human-readable description of the generated parser to
89be written to the file
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
102files are created.
103.El
104.Sh TABLES
105The names of the tables generated by this version of
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
126.Bl -tag -width /tmp/yacc.uXXXXXXXX -compact
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
136If there are rules that are never reduced, the number of such rules is
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 .
149