new copyright; att/bsd/shared
[unix-history] / usr / src / usr.bin / yacc / yacc.1
CommitLineData
c89a75cf
KB
1.\" Copyright (c) 1989 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.\"
0fc6e47b 7.\" %sccs.include.redist.man%
c89a75cf 8.\"
0fc6e47b 9.\" @(#)yacc.1 5.5 (Berkeley) %G%
c89a75cf
KB
10.\"
11.TH YACC 1 ""
12.UC 7
13.SH NAME
14yacc \- an LALR(1) parser generator
15.SH SYNOPSIS
42ddc0cc 16.B yacc [ -dlrtv ] [ -b
c89a75cf
KB
17.I prefix
18.B ]
19.I filename
20.SH DESCRIPTION
21.I Yacc
22reads the grammar specification in the file
23.I filename
24and generates an LR(1) parser for it.
25The parsers consist of a set of LALR(1) parsing tables and a driver routine
26written in the C programming language.
27.I Yacc
28normally writes the parse tables and the driver routine to the file
29.IR y.tab.c.
30.PP
31The following options are available:
32.RS
33.TP
34\fB-b \fIprefix\fR
35The
36.B -b
37option changes the prefix prepended to the output file names to
38the string denoted by
39.IR prefix.
40The default prefix is the character
41.IR y.
42.TP
43.B -d
44The \fB-d\fR option causes the header file
45.IR y.tab.h
46to be written.
47.TP
48.B -l
49If the
50.B -l
51option is not specified,
52.I yacc
53will insert \#line directives in the generated code.
54The \#line directives let the C compiler relate errors in the
55generated code to the user's original code.
56If the \fB-l\fR option is specified,
57.I yacc
58will not insert the \#line directives.
42ddc0cc
BC
59\&\#line directives specified by the user will be retained.
60.TP
61.B -r
62The
63.B -r
64option causes
65.I yacc
66to produce separate files for code and tables.
67The code file is named
68.IR y.code.c,
69and the tables file is named
70.IR y.tab.c.
c89a75cf
KB
71.TP
72.B -t
73The
74.B -t
42ddc0cc 75option changes the preprocessor directives generated by
c89a75cf
KB
76.I yacc
77so that debugging statements will be incorporated in the compiled code.
78.TP
79.B -v
80The
81.B -v
82option causes a human-readable description of the generated parser to
83be written to the file
84.IR y.output.
85.RE
86.PP
87If the environment variable TMPDIR is set, the string denoted by
88TMPDIR will be used as the name of the directory where the temporary
89files are created.
fd572324 90.SH TABLES
fd572324
KB
91The names of the tables generated by this version of
92.I yacc
93are ``yylhs'', ``yylen'', ``yydefred'', ``yydgoto'', ``yysindex'',
94``yyrindex'', ``yygindex'', ``yytable'', and ``yycheck''.
95Two additional tables, ``yyname'' and ``yyrule'', are created if
96YYDEBUG is defined and non-zero.
c89a75cf 97.SH FILES
42ddc0cc
BC
98.IR y.code.c
99.br
c89a75cf
KB
100.IR y.tab.c
101.br
102.IR y.tab.h
103.br
104.IR y.output
105.br
106.IR /tmp/yacc.aXXXXXX
107.br
108.IR /tmp/yacc.tXXXXXX
109.br
110.IR /tmp/yacc.uXXXXXX
42e8df0f
KB
111.SH "SEE ALSO"
112yyfix(1)
c89a75cf
KB
113.SH DIAGNOSTICS
114If there are rules that are never reduced, the number of such rules is
115reported on standard error.
116If there are any LALR(1) conflicts, the number of conflicts is reported
117on standard error.