Manual
Manual
Manual
Create successful ePaper yourself
Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.
60 Bison 2.3<br />
See Section 8.2 [Tracing Your Parser], page 95.<br />
%defines<br />
[Directive]<br />
Write a header file containing macro definitions for the token type names defined in<br />
the grammar as well as a few other declarations. If the parser output file is named<br />
‘name.c’ then this file is named ‘name.h’.<br />
Unless YYSTYPE is already defined as a macro, the output header declares YYSTYPE.<br />
Therefore, if you are using a %union (see Section 3.5.2 [More Than One Value Type],<br />
page 46) with components that require other definitions, or if you have defined a<br />
YYSTYPE macro (see Section 3.5.1 [Data Types of Semantic Values], page 46), you<br />
need to arrange for these definitions to be propagated to all modules, e.g., by putting<br />
them in a prerequisite header that is included both by your parser and by any other<br />
module that needs YYSTYPE.<br />
Unless your parser is pure, the output header declares yylval as an external variable.<br />
See Section 3.7.10 [A Pure (Reentrant) Parser], page 58.<br />
If you have also used locations, the output header declares YYLTYPE and yylloc<br />
using a protocol similar to that of YYSTYPE and yylval. See Section 3.6 [Tracking<br />
Locations], page 51.<br />
This output file is normally essential if you wish to put the definition of yylex in a<br />
separate source file, because yylex typically needs to be able to refer to the abovementioned<br />
declarations and to the token type codes. See Section 4.2.2 [Semantic<br />
Values of Tokens], page 65.<br />
%destructor<br />
[Directive]<br />
Specify how the parser should reclaim the memory associated to discarded symbols.<br />
See Section 3.7.7 [Freeing Discarded Symbols], page 57.<br />
%file-prefix="prefix"<br />
[Directive]<br />
Specify a prefix to use for all Bison output file names. The names are chosen as if the<br />
input file were named ‘prefix.y’.<br />
%locations<br />
[Directive]<br />
Generate the code processing the locations (see Section 4.4 [Special Features for Use<br />
in Actions], page 68). This mode is enabled as soon as the grammar uses the special<br />
‘@n’ tokens, but if your grammar does not use it, using ‘%locations’ allows for more<br />
accurate syntax error messages.<br />
%name-prefix="prefix"<br />
[Directive]<br />
Rename the external symbols used in the parser so that they start with prefix instead<br />
of ‘yy’. The precise list of symbols renamed in C parsers is yyparse, yylex, yyerror,<br />
yynerrs, yylval, yychar, yydebug, and (if locations are used) yylloc. For example,<br />
if you use ‘%name-prefix="c_"’, the names become c_parse, c_lex, and so on. In<br />
C++ parsers, it is only the surrounding namespace which is named prefix instead of<br />
‘yy’. See Section 3.8 [Multiple Parsers in the Same Program], page 62.<br />
%no-parser<br />
[Directive]<br />
Do not include any C code in the parser file; generate tables only. The parser file<br />
contains just #define directives and static variable declarations.