bison.1 4.6 KB

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