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