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