]> git.saurik.com Git - bison.git/blame_incremental - doc/bison.1
*** empty log message ***
[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 \-l
16] [
17.B \-\-no-lines
18] [
19.BI \-o " outfile"
20] [
21.BI \-\-output-file= outfile
22] [
23.BI \-p " prefix"
24] [
25.BI \-\-name-prefix= prefix
26] [
27.B \-t
28] [
29.B \-\-debug
30] [
31.B \-v
32] [
33.B \-\-verbose
34] [
35.B \-V
36] [
37.B \-\-version
38] [
39.B \-y
40] [
41.B \-\-yacc
42] [
43.B \-h
44] [
45.B \-\-help
46] [
47.B \-\-fixed-output-files
48]
49file
50.SH DESCRIPTION
51.I Bison
52is a parser generator in the style of
53.IR yacc (1).
54It should be upwardly compatible with input files designed
55for
56.IR yacc .
57.PP
58Input files should follow the
59.I yacc
60convention of ending in
61.BR .y .
62Unlike
63.IR yacc ,
64the generated files do not have fixed names, but instead use the prefix
65of the input file.
66For instance, a grammar description file named
67.B parse.y
68would produce the generated parser in a file named
69.BR parse.tab.c ,
70instead of
71.IR yacc 's
72.BR y.tab.c .
73.PP
74This description of the options that can be given to
75.I bison
76is adapted from the node
77.B Invocation
78in the
79.B bison.texinfo
80manual, which should be taken as authoritative.
81.PP
82.I Bison
83supports both traditional single-letter options and mnemonic long
84option names. Long option names are indicated with
85.B \-\-
86instead of
87.BR \- .
88Abbreviations for option names are allowed as long as they
89are unique. When a long option takes an argument, like
90.BR \-\-file-prefix ,
91connect the option name and the argument with
92.BR = .
93.SS OPTIONS
94.TP
95.BI \-b " file-prefix"
96.br
97.ns
98.TP
99.BI \-\-file-prefix= file-prefix
100Specify a prefix to use for all
101.I bison
102output file names. The names are
103chosen as if the input file were named
104\fIfile-prefix\fB.c\fR.
105.TP
106.B \-d
107.br
108.ns
109.TP
110.B \-\-defines
111Write an extra output file containing macro definitions for the token
112type names defined in the grammar and the semantic value type
113.BR YYSTYPE ,
114as well as a few
115.B extern
116variable declarations.
117.sp
118If the parser output file is named
119\fIname\fB.c\fR
120then this file
121is named
122\fIname\fB.h\fR.
123.sp
124This output file is essential if you wish to put the definition of
125.B yylex
126in a separate source file, because
127.B yylex
128needs to be able to refer to token type codes and the variable
129.BR yylval .
130.TP
131.B \-l
132.br
133.ns
134.TP
135.B \-\-no-lines
136Don't put any
137.B #line
138preprocessor commands in the parser file.
139Ordinarily
140.I bison
141puts them in the parser file so that the C compiler
142and debuggers will associate errors with your source file, the
143grammar file. This option causes them to associate errors with the
144parser file, treating it an independent source file in its own right.
145.TP
146.BI \-o " outfile"
147.br
148.ns
149.TP
150.BI \-\-output-file= outfile
151Specify the name
152.I outfile
153for the parser file.
154.sp
155The other output files' names are constructed from
156.I outfile
157as described under the
158.B \-v
159and
160.B \-d
161switches.
162.TP
163.BI \-p " prefix"
164.br
165.ns
166.TP
167.BI \-\-name-prefix= prefix
168Rename the external symbols used in the parser so that they start with
169.I prefix
170instead of
171.BR yy .
172The precise list of symbols renamed is
173.BR yyparse ,
174.BR yylex ,
175.BR yyerror ,
176.BR yylval ,
177.BR yychar ,
178and
179.BR yydebug .
180.sp
181For example, if you use
182.BR "\-p c" ,
183the names become
184.BR cparse ,
185.BR clex ,
186and so on.
187.TP
188.B \-t
189.br
190.ns
191.TP
192.B \-\-debug
193Output a definition of the macro
194.B YYDEBUG
195into the parser file,
196so that the debugging facilities are compiled.
197.TP
198.B \-v
199.br
200.ns
201.TP
202.B \-\-verbose
203Write an extra output file containing verbose descriptions of the
204parser states and what is done for each type of look-ahead token in
205that state.
206.sp
207This file also describes all the conflicts, both those resolved by
208operator precedence and the unresolved ones.
209.sp
210The file's name is made by removing
211.B .tab.c
212or
213.B .c
214from the parser output file name, and adding
215.B .output
216instead.
217.sp
218Therefore, if the input file is
219.BR foo.y ,
220then the parser file is called
221.B foo.tab.c
222by default. As a consequence, the verbose
223output file is called
224.BR foo.output .
225.TP
226.B \-V
227.br
228.ns
229.TP
230.B \-\-version
231Print the version number of
232.I bison
233and exit.
234.TP
235.B \-h
236.br
237.ns
238.TP
239.B \-\-help
240Print a summary of the options to
241.I bison
242and exit.
243.TP
244.B \-y
245.br
246.ns
247.TP
248.B \-\-yacc
249.br
250.ns
251.TP
252.B \-\-fixed-output-files
253Equivalent to
254.BR "\-o y.tab.c" ;
255the parser output file is called
256.BR y.tab.c ,
257and the other outputs are called
258.B y.output
259and
260.BR y.tab.h .
261The purpose of this switch is to imitate
262.IR yacc 's
263output file name conventions.
264Thus, the following shell script can substitute for
265.IR yacc :
266.sp
267.RS
268.ft B
269bison \-y $*
270.ft R
271.sp
272.RE
273.PP
274The long-named options can be introduced with `+' as well as `\-\-',
275for compatibility with previous releases. Eventually support for `+'
276will be removed, because it is incompatible with the POSIX.2 standard.
277.SH FILES
278/usr/local/lib/bison.simple simple parser
279.br
280/usr/local/lib/bison.hairy complicated parser
281.SH SEE ALSO
282.IR yacc (1)
283.br
284The
285.IR "Bison Reference Manual" ,
286included as the file
287.B bison.texinfo
288in the
289.I bison
290source distribution.
291.SH DIAGNOSTICS
292Self explanatory.
293