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