]> git.saurik.com Git - bison.git/blame_incremental - doc/bison.1
* src/tables.c (tables_generate): Use free for pointers that
[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.BI \-\-defines= defines-file
14] [
15.B \-g
16] [
17.BI \-\-graph= graph-file
18] [
19.B \-k
20] [
21.B \-\-token-table
22] [
23.B \-l
24] [
25.B \-\-no-lines
26] [
27.B \-n
28] [
29.B \-\-no-parser
30] [
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.
78Moreover, if you need to put
79.I 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++).
83For instance, a grammar description file named
84.B parse.yxx
85would produce the generated parser in a file named
86.BR parse.tab.cxx ,
87instead of
88.IR yacc 's
89.B y.tab.c
90or old
91.I Bison
92version's
93.BR parse.tab.c .
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\fP\fB.c\fP.
126.TP
127.B \-d
128.br
129.ns
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.IB name .c
139then this file
140is named
141\fIname\fP\fB.h\fP.
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
150.BI \-\-defines= defines-file
151The behavior of
152.B \-\-defines
153is the same than
154.B \-d
155option.
156The only difference is that it has an optional 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 behavior of
170.BI \-\-graph
171is the same than
172.BI \-g
173option. The only difference is that it has an optional argument which
174is the name of the output graph filename.
175.TP
176.B \-k
177.br
178.ns
179.TP
180.B \-\-token-table
181This switch causes the
182.IB name .tab.c
183output to include a list of
184token names in order by their token numbers; this is defined in the array
185.IR yytname .
186Also generated
187are #defines for
188.IR YYNTOKENS ,
189.IR YYNNTS ,
190.IR YYNRULES ,
191and
192.IR YYNSTATES .
193.TP
194.B \-l
195.br
196.ns
197.TP
198.B \-\-no-lines
199Don't put any
200.B #line
201preprocessor commands in the parser file.
202Ordinarily
203.I bison
204puts them in the parser file so that the C compiler
205and debuggers will associate errors with your source file, the
206grammar file. This option causes them to associate errors with the
207parser file, treating it an independent source file in its own right.
208.TP
209.B \-n
210.br
211.ns
212.TP
213.B \-\-no-parser
214Do not generate the parser code into the output; generate only
215declarations. The generated
216.IB name .tab.c
217file will have only
218constant declarations. In addition, a
219.IB name .act
220file is
221generated containing a switch statement body containing all the
222translated actions.
223.TP
224.BI \-o " outfile"
225.br
226.ns
227.TP
228.BI \-\-output-file= outfile
229Specify the name
230.I outfile
231for the parser file.
232.sp
233The other output files' names are constructed from
234.I outfile
235as described under the
236.B \-v
237and
238.B \-d
239switches.
240.TP
241.BI \-p " prefix"
242.br
243.ns
244.TP
245.BI \-\-name-prefix= prefix
246Rename the external symbols used in the parser so that they start with
247.I prefix
248instead of
249.BR yy .
250The precise list of symbols renamed is
251.BR yyparse ,
252.BR yylex ,
253.BR yyerror ,
254.BR yylval ,
255.BR yychar ,
256and
257.BR yydebug .
258.sp
259For example, if you use
260.BR "\-p c" ,
261the names become
262.BR cparse ,
263.BR clex ,
264and so on.
265.TP
266.B \-t
267.br
268.ns
269.TP
270.B \-\-debug
271In the parser file, define the macro
272.B YYDEBUG
273to 1 if it is not already defined,
274so that the debugging facilities are compiled.
275.TP
276.B \-v
277.br
278.ns
279.TP
280.B \-\-verbose
281Write an extra output file containing verbose descriptions of the
282parser states and what is done for each type of look-ahead token in
283that state.
284.sp
285This file also describes all the conflicts, both those resolved by
286operator precedence and the unresolved ones.
287.sp
288The file's name is made by removing
289.B .tab.c
290or
291.B .c
292from the parser output file name, and adding
293.B .output
294instead.
295.sp
296Therefore, if the input file is
297.BR foo.y ,
298then the parser file is called
299.B foo.tab.c
300by default. As a consequence, the verbose
301output file is called
302.BR foo.output .
303.TP
304.B \-V
305.br
306.ns
307.TP
308.B \-\-version
309Print the version number of
310.I bison
311and exit.
312.TP
313.B \-h
314.br
315.ns
316.TP
317.B \-\-help
318Print a summary of the options to
319.I bison
320and exit.
321.TP
322.B \-y
323.br
324.ns
325.TP
326.B \-\-yacc
327.br
328.ns
329.TP
330.B \-\-fixed-output-files
331Equivalent to
332.BR "\-o y.tab.c" ;
333the parser output file is called
334.BR y.tab.c ,
335and the other outputs are called
336.B y.output
337and
338.BR y.tab.h .
339The purpose of this switch is to imitate
340.IR yacc 's
341output file name conventions.
342Thus, the following shell script can substitute for
343.IR yacc :
344.sp
345.RS
346.ft B
347bison \-y $*
348.ft R
349.sp
350.RE
351.SH FILES
352/usr/local/share/bison/bison.simple simple parser
353.br
354/usr/local/share/bison/bison.hairy complicated parser
355.SH "ENVIRONMENT VARIABLES"
356.TP
357.SM BISON_SIMPLE
358If this is set, it specifies the location in which the
359.B bison.simple
360parser can be found.
361.TP
362.SM BISON_HAIRY
363If this is set, it specifies the location in which the
364.B bison.hairy
365parser can be found.
366.SH SEE ALSO
367.IR yacc (1)
368.br
369The
370.IR "Bison Reference Manual" ,
371included as the file
372.B bison.texinfo
373in the
374.I bison
375source distribution.
376.SH DIAGNOSTICS
377Self explanatory.