1 .\" $NetBSD: yacc.1,v 1.4 2011/09/10 21:29:04 christos Exp $
3 .\" Id: yacc.1,v 1.12 2011/09/08 00:40:44 tom Exp
5 .\" .TH YACC 1 "July\ 15,\ 1990"
7 .TH YACC 1 "September 7, 2011" "Berkeley Yacc" "User Commands"
9 Yacc \- an LALR(1) parser generator
11 .B yacc [ -dgilrtv ] [ \-b
19 reads the grammar specification in the file
21 and generates an LALR(1) parser for it.
22 The parsers consist of a set of LALR(1) parsing tables and a driver routine
23 written in the C programming language.
25 normally writes the parse tables and the driver routine to the file
28 The following options are available:
30 \fB\-b \fP\fIfile_prefix\fR
33 option changes the prefix prepended to the output file names to
36 The default prefix is the character
40 The \fB-d\fR option causes the header file
43 It contains #define's for the token identifiers.
48 option causes a graphical description of the generated LALR(1) parser to
49 be written to the file
51 in graphviz format, ready to be processed by dot(1).
54 The \fB-i\fR option causes a supplementary header file
57 It contains extern declarations
58 and supplementary #define's as needed to map the conventional \fIyacc\fP
59 \fByy\fP-prefixed names to whatever the \fB-p\fP option may specify.
60 The code file, e.g., \fBy.tab.c\fP is modified to #include this file
61 as well as the \fBy.tab.h\fP file, enforcing consistent usage of the
62 symbols defined in those files.
64 The supplementary header file makes it simpler to separate compilation
65 of lex- and yacc-files.
70 option is not specified,
72 will insert \fI#line\fP directives in the generated code.
73 The \fI#line\fP directives let the C compiler relate errors in the
74 generated code to the user's original code.
75 If the \fB-l\fR option is specified,
77 will not insert the \fI#line\fP directives.
78 \&\fI#line\fP directives specified by the user will be retained.
80 \fB\-o \fP\fIoutput_file\fR
81 specify the filename for the parser file.
82 If this option is not given, the output filename is
83 the file prefix concatenated with the file suffix, e.g., \fBy.tab.c\fP.
84 This overrides the \fB-p\fP option.
86 \fB\-p \fP\fIsymbol_prefix\fR
89 option changes the prefix prepended to yacc-generated symbols to
92 The default prefix is the string
96 create a reentrant parser, e.g., "%pure-parser".
103 to produce separate files for code and tables. The code file
106 and the tables file is named
108 The prefix "\fIy.\fP" can be overridden using the \fB\-b\fP option.
113 option changes the preprocessor directives generated by
115 so that debugging statements will be incorporated in the compiled code.
120 option causes a human-readable description of the generated parser to
121 be written to the file
125 print the version number to the standard output.
128 provides some extensions for compatibility with bison and other implementations
131 \fB %expect\fP \fInumber\fP
132 tell \fByacc\fP the expected number of shift/reduce conflicts.
133 That makes it only report the number if it differs.
135 \fB %expect-rr\fP \fInumber\fP
136 tell \fByacc\fP the expected number of reduce/reduce conflicts.
137 That makes it only report the number if it differs.
138 This is (unlike bison) allowable in LALR parsers.
140 \fB %lex-param\fP { \fIargument-declaration\fP }
141 By default, the lexer accepts no parameters, e.g., \fByylex()\fP.
142 Use this directive to add parameter declarations for your customized lexer.
144 \fB %parse-param\fP { \fIargument-declaration\fP }
145 By default, the parser accepts no parameters, e.g., \fByyparse()\fP.
146 Use this directive to add parameter declarations for your customized parser.
149 Most variables (other than \fByydebug\fP and \fByynerrs\fP) are
150 allocated on the stack within \fByyparse\fP, making the parser reasonably
154 If there are rules that are never reduced, the number of such rules is
155 reported on standard error.
156 If there are any LALR(1) conflicts, the number of conflicts is reported