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