]> git.saurik.com Git - bison.git/blame - doc/bison.1
Add %define lr.keep_unreachable_states.
[bison.git] / doc / bison.1
CommitLineData
a641b0da
DM
1.TH BISON 1 local
2.SH NAME
3bison \- GNU Project parser generator (yacc replacement)
4.SH SYNOPSIS
5.B bison
6[
7.BI \-b " file-prefix"
8] [
9.BI \-\-file-prefix= file-prefix
10] [
11.B \-d
12] [
342b8b6e
AD
13.BI \-\-defines= defines-file
14] [
15.B \-g
16] [
17.BI \-\-graph= graph-file
a641b0da 18] [
333ccc01
RS
19.B \-k
20] [
21.B \-\-token-table
22] [
a641b0da
DM
23.B \-l
24] [
25.B \-\-no-lines
26] [
27.BI \-o " outfile"
28] [
29.BI \-\-output-file= outfile
30] [
31.BI \-p " prefix"
32] [
33.BI \-\-name-prefix= prefix
34] [
35.B \-t
36] [
37.B \-\-debug
38] [
39.B \-v
40] [
41.B \-\-verbose
42] [
43.B \-V
44] [
45.B \-\-version
46] [
47.B \-y
48] [
49.B \-\-yacc
50] [
51.B \-h
52] [
53.B \-\-help
54] [
55.B \-\-fixed-output-files
56]
57file
7eab453e
PE
58.br
59.B yacc
60[
61.I "similar options and operands"
62]
a641b0da
DM
63.SH DESCRIPTION
64.I Bison
65is a parser generator in the style of
66.IR yacc (1).
67It should be upwardly compatible with input files designed
68for
69.IR yacc .
70.PP
71Input files should follow the
72.I yacc
73convention of ending in
74.BR .y .
75Unlike
76.IR yacc ,
77the generated files do not have fixed names, but instead use the prefix
78of the input file.
4e0813a6
PE
79Moreover, if you need to put
80.I C++
234a3be3 81code in the input file, you can end his name by a C++-like extension
4e0813a6 82(.ypp or .y++), then bison will follow your extension to name the
234a3be3 83output file (.cpp or .c++).
a641b0da 84For instance, a grammar description file named
234a3be3 85.B parse.yxx
a641b0da 86would produce the generated parser in a file named
234a3be3 87.BR parse.tab.cxx ,
a641b0da
DM
88instead of
89.IR yacc 's
4e0813a6
PE
90.B y.tab.c
91or old
92.I Bison
93version's
234a3be3 94.BR parse.tab.c .
a641b0da
DM
95.PP
96This description of the options that can be given to
97.I bison
98is adapted from the node
99.B Invocation
100in the
101.B bison.texinfo
102manual, which should be taken as authoritative.
103.PP
104.I Bison
105supports both traditional single-letter options and mnemonic long
106option names. Long option names are indicated with
107.B \-\-
108instead of
109.BR \- .
110Abbreviations for option names are allowed as long as they
111are unique. When a long option takes an argument, like
112.BR \-\-file-prefix ,
113connect the option name and the argument with
114.BR = .
115.SS OPTIONS
116.TP
117.BI \-b " file-prefix"
118.br
119.ns
120.TP
121.BI \-\-file-prefix= file-prefix
122Specify a prefix to use for all
123.I bison
124output file names. The names are
125chosen as if the input file were named
4e0813a6 126\fIfile-prefix\fP\fB.c\fP.
a641b0da
DM
127.TP
128.B \-d
129.br
130.ns
a641b0da
DM
131Write an extra output file containing macro definitions for the token
132type names defined in the grammar and the semantic value type
133.BR YYSTYPE ,
134as well as a few
135.B extern
136variable declarations.
137.sp
138If the parser output file is named
4e0813a6 139.IB name .c
a641b0da
DM
140then this file
141is named
4e0813a6 142\fIname\fP\fB.h\fP.
a641b0da
DM
143.sp
144This output file is essential if you wish to put the definition of
145.B yylex
146in a separate source file, because
147.B yylex
148needs to be able to refer to token type codes and the variable
149.BR yylval .
150.TP
342b8b6e 151.BI \-\-defines= defines-file
4e0813a6
PE
152The behavior of
153.B \-\-defines
154is the same than
155.B \-d
156option.
157The only difference is that it has an optional argument which is
342b8b6e
AD
158the name of the output filename.
159.TP
160.BI \-g
161.br
162.ns
35fe0834 163Output a graph of the grammar automaton computed by
4e0813a6 164Bison. If the grammar file is
342b8b6e 165.BR foo.y
35fe0834
PE
166, the output file will be
167.BR foo.dot .
342b8b6e
AD
168.TP
169.BI \-\-graph= graph-file
4e0813a6
PE
170The behavior of
171.BI \-\-graph
342b8b6e
AD
172is the same than
173.BI \-g
4e0813a6 174option. The only difference is that it has an optional argument which
342b8b6e
AD
175is the name of the output graph filename.
176.TP
333ccc01
RS
177.B \-k
178.br
179.ns
180.TP
181.B \-\-token-table
4e0813a6
PE
182This switch causes the
183.IB name .tab.c
184output to include a list of
185token names in order by their token numbers; this is defined in the array
333ccc01 186.IR yytname .
62ab6972
AD
187Also generated
188are #defines for
333ccc01
RS
189.IR YYNTOKENS ,
190.IR YYNNTS ,
191.IR YYNRULES ,
62ab6972 192and
333ccc01
RS
193.IR YYNSTATES .
194.TP
a641b0da
DM
195.B \-l
196.br
197.ns
198.TP
199.B \-\-no-lines
200Don't put any
201.B #line
202preprocessor commands in the parser file.
203Ordinarily
204.I bison
205puts them in the parser file so that the C compiler
206and debuggers will associate errors with your source file, the
207grammar file. This option causes them to associate errors with the
208parser file, treating it an independent source file in its own right.
209.TP
210.BI \-o " outfile"
211.br
212.ns
213.TP
214.BI \-\-output-file= outfile
215Specify the name
216.I outfile
217for the parser file.
218.sp
219The other output files' names are constructed from
220.I outfile
221as described under the
222.B \-v
223and
224.B \-d
225switches.
226.TP
227.BI \-p " prefix"
228.br
229.ns
230.TP
231.BI \-\-name-prefix= prefix
232Rename the external symbols used in the parser so that they start with
233.I prefix
234instead of
235.BR yy .
236The precise list of symbols renamed is
237.BR yyparse ,
238.BR yylex ,
239.BR yyerror ,
240.BR yylval ,
62ab6972 241.BR yychar ,
a641b0da
DM
242and
243.BR yydebug .
244.sp
245For example, if you use
246.BR "\-p c" ,
247the names become
248.BR cparse ,
249.BR clex ,
250and so on.
251.TP
252.B \-t
253.br
254.ns
255.TP
256.B \-\-debug
4947ebdb 257In the parser file, define the macro
62ab6972 258.B YYDEBUG
4947ebdb 259to 1 if it is not already defined,
a641b0da
DM
260so that the debugging facilities are compiled.
261.TP
262.B \-v
263.br
264.ns
265.TP
266.B \-\-verbose
267Write an extra output file containing verbose descriptions of the
742e4900 268parser states and what is done for each type of lookahead token in
a641b0da
DM
269that state.
270.sp
271This file also describes all the conflicts, both those resolved by
272operator precedence and the unresolved ones.
273.sp
274The file's name is made by removing
275.B .tab.c
276or
277.B .c
278from the parser output file name, and adding
279.B .output
280instead.
281.sp
282Therefore, if the input file is
283.BR foo.y ,
284then the parser file is called
285.B foo.tab.c
286by default. As a consequence, the verbose
287output file is called
288.BR foo.output .
289.TP
290.B \-V
291.br
292.ns
293.TP
294.B \-\-version
295Print the version number of
296.I bison
297and exit.
298.TP
299.B \-h
300.br
301.ns
5fcfb6e7 302.TP
a641b0da
DM
303.B \-\-help
304Print a summary of the options to
305.I bison
306and exit.
307.TP
308.B \-y
309.br
310.ns
311.TP
312.B \-\-yacc
313.br
314.ns
315.TP
316.B \-\-fixed-output-files
317Equivalent to
318.BR "\-o y.tab.c" ;
319the parser output file is called
320.BR y.tab.c ,
321and the other outputs are called
322.B y.output
323and
324.BR y.tab.h .
325The purpose of this switch is to imitate
326.IR yacc 's
327output file name conventions.
328Thus, the following shell script can substitute for
7eab453e
PE
329.I yacc
330and is often installed as
a641b0da
DM
331.IR yacc :
332.sp
333.RS
334.ft B
7eab453e 335bison \-y "$@"
a641b0da
DM
336.ft R
337.sp
338.RE
a641b0da
DM
339.SH SEE ALSO
340.IR yacc (1)
341.br
342The
343.IR "Bison Reference Manual" ,
344included as the file
345.B bison.texinfo
346in the
347.I bison
348source distribution.
349.SH DIAGNOSTICS
350Self explanatory.
cf2a5f7c
PE
351.SH COPYRIGHT
352Copyright \(co 2006 Free Software Foundation, Inc.
353.br
354This is free software. You may redistribute copies of it under the terms of
355the GNU General Public License <http://www.gnu.org/licenses/gpl.html>.
356There is NO WARRANTY, to the extent permitted by law.