.TH yacc "" "" Command
.PC "Parser generator"
\fByacc [\fIoption ...\^\fB] \fIfile\fR
.br
\fBcc y.tab.c [\-ly]\fR
.PP
.HS
.SH Options:
.IC "\fB\-d\fR"
Enable debugging output (implies \fB\-v\fR)
.IC "\fB\-hdr\fR"
Next argument is name of header file (default, \fBy.tab.h\fR)
.IC \fB\-items \fIN\fR"
Allow \fIN\fR items per state.
.IC "\fB\-l\fR"
Next argument is name of listfile (default, \fBy.output\fR)
.IC "\fBsprod\fI N\fR"
Allow \fIN\fR symbols per production (default, 20)
.IC "\fB\-st\fR"
Print statistics on standard output
.IC "\fB\-v\fR"
Verbose (extra output in listfile)
.Pp
After each of the following, the next argument is a number to reset table size:
.IC "\fB\-nterms\fR"
Nonterminal symbols (default, 100)
.IC "\fB\-prods\fR"
Productions or rules (default, 350)
.IC "\fB\-states\fR"
States (default, 300)
.IC "\fB\-terms\fR"
Terminal symbols (default, 300)
.IC "\fB\-types\fR"
Types (default, 10)
.HE
.II liby
.II "library^yacc"
Many programs process highly structured input according to
given rules.
Compilers are a familiar example.
Two of the most complicated parts of such programs are
.I "lexical analysis"
and
.I parsing
(sometimes called
.IR "syntax analysis" ).
The \*(CO system includes two powerful tools called
.B lex
and
.B yacc
to assist you in performing these tasks.
.B lex
takes a set of lexical rules and writes a lexical analyzer, whereas
.B yacc
takes a set of parsing rules and writes a parser;
both output C source code that can be compiled into a full program.
.PP
The term
.I yacc
is an acronym for ``yet another compiler-compiler''.
In brief, the
.B yacc
input
.I file
describes a context free grammar using a BNF-like syntax.
The output is a file
.BR y.tab.c ;
it contains the definition of a C function
.BR yyparse (),
which parses the language described in
.IR file .
The output is ready for processing by the C compiler
.BR cc .
Ambiguities in the grammar are reported to the user,
but resolved automatically by precedence rules.
The user must provide a lexical scanner
.BR yylex (),
which you may generate with
.BR lex .
The
.B yacc
library includes default definitions of
.BR main ,
.BR yylex ,
and
.BR yyerror ,
and may be included with the option
.B \-ly
on the
.B cc
command line.
.PP
.B yacc
recognizes the following options:
.IP \fB\-d\fR
Enable debugging output; implies
.B \-v.
.IP "\fB\-hdr \fIheaderfile\fR"
Put the header output in
.I headerfile
instead of
.BR y.tab.h .
.IP "\fB\-items \fIN\fR"
Allow \fIN\fR items per state.
This option is designed to help \fByacc\fR users deal with the ANSI C grammar.
.IP  "\fB\-l \fIlistfile\fR"
Place a description of the state machine, tokens,
parsing actions, and statistics in file
.IR listfile .
.IP "\fB\-sprod \fIN\fR"
Allow \fIN\fR symbols per production; default, 20.
This option is designed to help \fByacc\fR users deal with the ANSI C grammar.
.IP \fB\-st\fR
Print statistics on the standard output.
.IP \fB\-v\fR
Verbose option.
Like
.BR \-l ,
but places the listing in file
.B y.output
by default.
.PP
The following options are useful if table overflow messages appear:
.IP "\fB\-nterms \fIN\fR"
Allow for \fIN\fR nonterminals; default, 100.
.IP "\fB\-prods \fIN\fR"
Allow for \fIN\fR productions (rules); default, 350.
.IP "\fB\-states \fIN\fR"
Allow for \fIN\fR states; default, 300.
.IP "\fB\-terms \fIN\fR"
Allow for \fIN\fR terminal symbols; default 100.
.IP "\fB\-types \fIN\fR"
Allow for \fIN\fR types; default, ten.
.SH Files
\fBy.tab.c\fR \(em C source output
.br
\fBy.tab.h\fR \(em Default C header output
.br
\fBy.output\fR \(em Default listing output
.br
\fB/lib/yyparse.c\fR \(em Protoparser
.br
\fB/tmp/y[ao]*\fR \(em Temporaries
.br
\fB/usr/lib/liby.a\fR \(em Library
.SH "See Also"
.Xr "cc," cc
.Xr "commands," commands
.Xr "lex," lex
.Xr "Programming COHERENT" programmi
.br
\fIIntroduction to yacc, Yet Another Compiler-Compiler\fR
.SH Diagnostics
.B yacc
writes onto the standard error the number of R/R (reduce/reduce)
and S/R (shift/reduce) conflicts (ambiguities).
.SH Notes
The version of
.B yacc
shipped prior to release 4.2 of \*(CO included the header file
.B <action.h>
in its output.
This file's data are now built into parser skeleton in
.BR /lib/yyparse ,
thus obviating
.BR <action.h> .
This header has been dropped from \*(CO.
You should re-run
.B yacc
to update the source files generated by previous versions of
.BR yacc .
