MAN page from Trustix bison-1.875-7tr.i586.rpm
Section: User Commands (1)
bison - GNU Project parser generator (yacc replacement)
] [-o outfile
] [-p prefix
[similar options and operands
is a parser generator in the style ofyacc
(1).It should be upwardly compatible with input files designedforyacc
Input files should follow theyaccconvention of ending in.y.Unlikeyacc,the generated files do not have fixed names, but instead use the prefixof the input file.Moreover, if you need to putC++code in the input file, you can end his name by a C++-like extension(.ypp or .y++), then bison will follow your extension to name theoutput file (.cpp or .c++).For instance, a grammar description file namedparse.yxxwould produce the generated parser in a file namedparse.tab.cxx,instead ofyacc'sy.tab.cor oldBisonversion'sparse.tab.c.
This description of the options that can be given tobisonis adapted from the nodeInvocationin thebison.texinfomanual, which should be taken as authoritative.
Bisonsupports both traditional single-letter options and mnemonic longoption names. Long option names are indicated with--instead of-.Abbreviations for option names are allowed as long as theyare unique. When a long option takes an argument, like--file-prefix,connect the option name and the argument with=.
- -b file-prefix
- Specify a prefix to use for allbisonoutput file names. The names arechosen as if the input file were namedfile-prefix.c.
Write an extra output file containing macro definitions for the tokentype names defined in the grammar and the semantic value typeYYSTYPE,as well as a fewexternvariable declarations.
If the parser output file is namedname.cthen this fileis namedname.h.
This output file is essential if you wish to put the definition ofyylexin a separate source file, becauseyylexneeds to be able to refer to token type codes and the variableyylval.
- The behavior of--definesis the same than-doption.The only difference is that it has an optional argument which isthe name of the output filename.
Output a VCG definition of the LALR(1) grammar automaton computed byBison. If the grammar file isfoo.y, the VCG output file will befoo.vcg.
- The behavior of--graphis the same than-goption. The only difference is that it has an optional argument whichis the name of the output graph filename.
- This switch causes thename.tab.coutput to include a list oftoken names in order by their token numbers; this is defined in the arrayyytname.Also generatedare #defines forYYNTOKENS,YYNNTS,YYNRULES,andYYNSTATES.
- Don't put any#linepreprocessor commands in the parser file.Ordinarilybisonputs them in the parser file so that the C compilerand debuggers will associate errors with your source file, thegrammar file. This option causes them to associate errors with theparser file, treating it an independent source file in its own right.
- Do not generate the parser code into the output; generate onlydeclarations. The generatedname.tab.cfile will have onlyconstant declarations. In addition, aname.actfile isgenerated containing a switch statement body containing all thetranslated actions.
- -o outfile
- Specify the nameoutfilefor the parser file.
The other output files' names are constructed fromoutfileas described under the-vand-dswitches.
- -p prefix
- Rename the external symbols used in the parser so that they start withprefixinstead ofyy.The precise list of symbols renamed isyyparse,yylex,yyerror,yylval,yychar,andyydebug.
For example, if you use-p c,the names becomecparse,clex,and so on.
- In the parser file, define the macroYYDEBUGto 1 if it is not already defined,so that the debugging facilities are compiled.
- Write an extra output file containing verbose descriptions of theparser states and what is done for each type of look-ahead token inthat state.
This file also describes all the conflicts, both those resolved byoperator precedence and the unresolved ones.
The file's name is made by removing.tab.cor.cfrom the parser output file name, and adding.outputinstead.
Therefore, if the input file isfoo.y,then the parser file is calledfoo.tab.cby default. As a consequence, the verboseoutput file is calledfoo.output.
- Print the version number ofbisonand exit.
- Print a summary of the options tobisonand exit.
- Equivalent to-o y.tab.c;the parser output file is calledy.tab.c,and the other outputs are calledy.outputandy.tab.h.The purpose of this switch is to imitateyacc'soutput file name conventions.Thus, the following shell script can substitute foryaccand is often installed asyacc:
- bison -y "$@"
TheBison Reference Manual
,included as the filebison.texinfo
- SEE ALSO
This document was created byman2html,using the manual pages.