* src/getargs.c (longopts): Support `--output'. getopt is now

able to understand that `--out' is OK: the two racing long options
are aliases.
(usage): Adjust.
* src/lex.h (tok_setopt): Remove, replaced with...
(tok_intopt, tok_stropt): these new guys.
* src/lex.c (getopt.h): Not needed.
(token_buffer, unlexed_token_buffer): Not const.
(percent_table): Promote `-' over `_' in directive names.
Active `%name-prefix', `file-prefix', and `output'.
(parse_percent_token): Accept possible arguments to directives.
Promote `-' over `_' in directive names.
* doc/bison.texinfo (Decl Summary): Split the list into
`directives for grammars' and `directives for bison'.
Sort'em.
Add description of `%name-prefix', `file-prefix', and `output'.
Promote `-' over `_' in directive names.
(Bison Options): s/%locactions/%locations/.  Nice Freudian slip.
Simplify the description of `--name-prefix'.
Promote `-' over `_' in directive names.
Promote `--output' over `--output-file'.
Fix the description of `--defines'.
* tests/output.at: Exercise %file-prefix and %output.
This commit is contained in:
Akim Demaille
2001-11-04 16:26:59 +00:00
parent 57c429f305
commit ea57e0a3c4
32 changed files with 966 additions and 901 deletions

View File

@@ -31,115 +31,115 @@ instead of in the original English.

Indirect:
bison.info-1: 1313
bison.info-2: 50691
bison.info-3: 100581
bison.info-4: 150131
bison.info-5: 197908
bison.info-2: 50689
bison.info-3: 100579
bison.info-4: 147579
bison.info-5: 197449

Tag Table:
(Indirect)
Node: Top1313
Node: Introduction8969
Node: Conditions10244
Node: Copying11708
Node: Concepts30911
Node: Language and Grammar31990
Node: Grammar in Bison37006
Node: Semantic Values38930
Node: Semantic Actions41031
Node: Locations Overview42220
Node: Bison Parser43667
Node: Stages45979
Node: Grammar Layout47262
Node: Examples48519
Node: RPN Calc49717
Node: Rpcalc Decls50691
Node: Rpcalc Rules52278
Node: Rpcalc Input54078
Node: Rpcalc Line55539
Node: Rpcalc Expr56654
Node: Rpcalc Lexer58599
Node: Rpcalc Main61171
Node: Rpcalc Error61569
Node: Rpcalc Gen62577
Node: Rpcalc Compile63726
Node: Infix Calc64601
Node: Simple Error Recovery67308
Node: Location Tracking Calc69197
Node: Ltcalc Decls69927
Node: Ltcalc Rules70836
Node: Ltcalc Lexer72897
Node: Multi-function Calc75235
Node: Mfcalc Decl76802
Node: Mfcalc Rules78825
Node: Mfcalc Symtab80205
Node: Exercises86578
Node: Grammar File87084
Node: Grammar Outline87932
Node: C Declarations88666
Node: Bison Declarations89246
Node: Grammar Rules89658
Node: C Code90118
Node: Symbols91048
Node: Rules96129
Node: Recursion97768
Node: Semantics99487
Node: Value Type100581
Node: Multiple Types101253
Node: Actions102270
Node: Action Types105055
Node: Mid-Rule Actions106358
Node: Locations111928
Node: Location Type112576
Node: Actions and Locations113134
Node: Location Default Action115290
Node: Declarations116753
Node: Token Decl118072
Node: Precedence Decl120085
Node: Union Decl121636
Node: Type Decl122480
Node: Expect Decl123386
Node: Start Decl124932
Node: Pure Decl125310
Node: Decl Summary126987
Node: Multiple Parsers132370
Node: Interface133864
Node: Parser Function134736
Node: Lexical135571
Node: Calling Convention136977
Node: Token Values139748
Node: Token Positions140897
Node: Pure Calling141782
Node: Error Reporting144714
Node: Action Features146836
Node: Algorithm150131
Node: Look-Ahead152424
Node: Shift/Reduce154556
Node: Precedence157468
Node: Why Precedence158119
Node: Using Precedence159984
Node: Precedence Examples160952
Node: How Precedence161653
Node: Contextual Precedence162802
Node: Parser States164593
Node: Reduce/Reduce165836
Node: Mystery Conflicts169397
Node: Stack Overflow172783
Node: Error Recovery174156
Node: Context Dependency179292
Node: Semantic Tokens180140
Node: Lexical Tie-ins183157
Node: Tie-in Recovery184705
Node: Debugging186877
Node: Invocation190178
Node: Bison Options191430
Node: Environment Variables195398
Node: Option Cross Key196246
Node: VMS Invocation197124
Node: Table of Symbols197908
Node: Glossary205547
Node: Copying This Manual211851
Node: GNU Free Documentation License212060
Node: Index231925
Node: Introduction8967
Node: Conditions10242
Node: Copying11706
Node: Concepts30909
Node: Language and Grammar31988
Node: Grammar in Bison37004
Node: Semantic Values38928
Node: Semantic Actions41029
Node: Locations Overview42218
Node: Bison Parser43665
Node: Stages45977
Node: Grammar Layout47260
Node: Examples48517
Node: RPN Calc49715
Node: Rpcalc Decls50689
Node: Rpcalc Rules52276
Node: Rpcalc Input54076
Node: Rpcalc Line55537
Node: Rpcalc Expr56652
Node: Rpcalc Lexer58597
Node: Rpcalc Main61169
Node: Rpcalc Error61567
Node: Rpcalc Gen62575
Node: Rpcalc Compile63724
Node: Infix Calc64599
Node: Simple Error Recovery67306
Node: Location Tracking Calc69195
Node: Ltcalc Decls69925
Node: Ltcalc Rules70834
Node: Ltcalc Lexer72895
Node: Multi-function Calc75233
Node: Mfcalc Decl76800
Node: Mfcalc Rules78823
Node: Mfcalc Symtab80203
Node: Exercises86576
Node: Grammar File87082
Node: Grammar Outline87930
Node: C Declarations88664
Node: Bison Declarations89244
Node: Grammar Rules89656
Node: C Code90116
Node: Symbols91046
Node: Rules96127
Node: Recursion97766
Node: Semantics99485
Node: Value Type100579
Node: Multiple Types101251
Node: Actions102268
Node: Action Types105053
Node: Mid-Rule Actions106356
Node: Locations111926
Node: Location Type112574
Node: Actions and Locations113132
Node: Location Default Action115288
Node: Declarations116751
Node: Token Decl118070
Node: Precedence Decl120083
Node: Union Decl121634
Node: Type Decl122478
Node: Expect Decl123384
Node: Start Decl124930
Node: Pure Decl125308
Node: Decl Summary126985
Node: Multiple Parsers133113
Node: Interface134607
Node: Parser Function135479
Node: Lexical136314
Node: Calling Convention137720
Node: Token Values140491
Node: Token Positions141640
Node: Pure Calling142525
Node: Error Reporting145457
Node: Action Features147579
Node: Algorithm150874
Node: Look-Ahead153167
Node: Shift/Reduce155299
Node: Precedence158211
Node: Why Precedence158862
Node: Using Precedence160727
Node: Precedence Examples161695
Node: How Precedence162396
Node: Contextual Precedence163545
Node: Parser States165336
Node: Reduce/Reduce166579
Node: Mystery Conflicts170140
Node: Stack Overflow173526
Node: Error Recovery174899
Node: Context Dependency180035
Node: Semantic Tokens180883
Node: Lexical Tie-ins183900
Node: Tie-in Recovery185448
Node: Debugging187620
Node: Invocation190921
Node: Bison Options192173
Node: Environment Variables195723
Node: Option Cross Key196571
Node: VMS Invocation197449
Node: Table of Symbols198233
Node: Glossary206201
Node: Copying This Manual212505
Node: GNU Free Documentation License212714
Node: Index232579

End Tag Table

View File

@@ -34,7 +34,7 @@ File: bison.info, Node: Top, Next: Introduction, Up: (dir)
Bison
*****
This manual documents version 1.30a of Bison, updated 20 September
This manual documents version 1.30a of Bison, updated 4 November
2001.
* Menu:

View File

@@ -710,7 +710,7 @@ File: bison.info, Node: Decl Summary, Prev: Pure Decl, Up: Declarations
Bison Declaration Summary
-------------------------
Here is a summary of all Bison declarations:
Here is a summary of the declarations used to define a grammar:
`%union'
Declare the collection of data types that semantic values may have
@@ -745,38 +745,9 @@ Bison Declaration Summary
Declare the expected number of shift-reduce conflicts (*note
Suppressing Conflict Warnings: Expect Decl.).
`%yacc'
`%fixed_output_files'
Pretend the option `--yacc' was given, i.e., imitate Yacc,
including its naming conventions. *Note Bison Options::, for more.
`%locations'
Generate the code processing the locations (*note Special Features
for Use in Actions: Action Features.). This mode is enabled as
soon as the grammar uses the special `@N' tokens, but if your
grammar does not use it, using `%locations' allows for more
accurate parse error messages.
`%pure_parser'
Request a pure (reentrant) parser program (*note A Pure
(Reentrant) Parser: Pure Decl.).
`%no_parser'
Do not include any C code in the parser file; generate tables
only. The parser file contains just `#define' directives and
static variable declarations.
This option also tells Bison to write the C code for the grammar
actions into a file named `FILENAME.act', in the form of a
brace-surrounded body fit for a `switch' statement.
`%no_lines'
Don't generate any `#line' preprocessor commands in the parser
file. Ordinarily Bison writes these commands in the parser file
so that the C compiler and debuggers will associate errors and
object code with your source file (the grammar file). This
directive causes them to associate errors with the parser file,
treating it an independent source file in its own right.
In order to change the behavior of `bison', use the following
directives:
`%debug'
Output a definition of the macro `YYDEBUG' into the parser file, so
@@ -796,20 +767,48 @@ Bison Declaration Summary
able to refer to token type codes and the variable `yylval'.
*Note Semantic Values of Tokens: Token Values.
`%verbose'
Write an extra output file containing verbose descriptions of the
parser states and what is done for each type of look-ahead token in
that state.
`%file-prefix="PREFIX"'
Specify a prefix to use for all Bison output file names. The
names are chosen as if the input file were named `PREFIX.y'.
This file also describes all the conflicts, both those resolved by
operator precedence and the unresolved ones.
`%locations'
Generate the code processing the locations (*note Special Features
for Use in Actions: Action Features.). This mode is enabled as
soon as the grammar uses the special `@N' tokens, but if your
grammar does not use it, using `%locations' allows for more
accurate parse error messages.
The file's name is made by removing `.tab.c' or `.c' from the
parser output file name, and adding `.output' instead.
`%name-prefix="PREFIX"'
Rename the external symbols used in the parser so that they start
with PREFIX instead of `yy'. The precise list of symbols renamed
is `yyparse', `yylex', `yyerror', `yynerrs', `yylval', `yychar'
and `yydebug'. For example, if you use `%name-prefix="c_"', the
names become `c_parse', `c_lex', and so on. *Note Multiple
Parsers in the Same Program: Multiple Parsers.
Therefore, if the input file is `foo.y', then the parser file is
called `foo.tab.c' by default. As a consequence, the verbose
output file is called `foo.output'.
`%no-parser'
Do not include any C code in the parser file; generate tables
only. The parser file contains just `#define' directives and
static variable declarations.
This option also tells Bison to write the C code for the grammar
actions into a file named `FILENAME.act', in the form of a
brace-surrounded body fit for a `switch' statement.
`%no-lines'
Don't generate any `#line' preprocessor commands in the parser
file. Ordinarily Bison writes these commands in the parser file
so that the C compiler and debuggers will associate errors and
object code with your source file (the grammar file). This
directive causes them to associate errors with the parser file,
treating it an independent source file in its own right.
`%output="FILENAME"'
Specify the FILENAME for the parser file.
`%pure-parser'
Request a pure (reentrant) parser program (*note A Pure
(Reentrant) Parser: Pure Decl.).
`%token_table'
Generate an array of token names in the parser file. The name of
@@ -845,6 +844,26 @@ Bison Declaration Summary
`YYNSTATES'
The number of parser states (*note Parser States::).
`%verbose'
Write an extra output file containing verbose descriptions of the
parser states and what is done for each type of look-ahead token in
that state.
This file also describes all the conflicts, both those resolved by
operator precedence and the unresolved ones.
The file's name is made by removing `.tab.c' or `.c' from the
parser output file name, and adding `.output' instead.
Therefore, if the input file is `foo.y', then the parser file is
called `foo.tab.c' by default. As a consequence, the verbose
output file is called `foo.output'.
`%yacc'
`%fixed-output-files'
Pretend the option `--yacc' was given, i.e., imitate Yacc,
including its naming conventions. *Note Bison Options::, for more.

File: bison.info, Node: Multiple Parsers, Prev: Declarations, Up: Grammar File
@@ -1226,92 +1245,3 @@ encountered so far. Normally this variable is global; but if you
request a pure parser (*note A Pure (Reentrant) Parser: Pure Decl.)
then it is a local variable which only the actions can access.

File: bison.info, Node: Action Features, Prev: Error Reporting, Up: Interface
Special Features for Use in Actions
===================================
Here is a table of Bison constructs, variables and macros that are
useful in actions.
`$$'
Acts like a variable that contains the semantic value for the
grouping made by the current rule. *Note Actions::.
`$N'
Acts like a variable that contains the semantic value for the Nth
component of the current rule. *Note Actions::.
`$<TYPEALT>$'
Like `$$' but specifies alternative TYPEALT in the union specified
by the `%union' declaration. *Note Data Types of Values in
Actions: Action Types.
`$<TYPEALT>N'
Like `$N' but specifies alternative TYPEALT in the union specified
by the `%union' declaration. *Note Data Types of Values in
Actions: Action Types.
`YYABORT;'
Return immediately from `yyparse', indicating failure. *Note The
Parser Function `yyparse': Parser Function.
`YYACCEPT;'
Return immediately from `yyparse', indicating success. *Note The
Parser Function `yyparse': Parser Function.
`YYBACKUP (TOKEN, VALUE);'
Unshift a token. This macro is allowed only for rules that reduce
a single value, and only when there is no look-ahead token. It
installs a look-ahead token with token type TOKEN and semantic
value VALUE; then it discards the value that was going to be
reduced by this rule.
If the macro is used when it is not valid, such as when there is a
look-ahead token already, then it reports a syntax error with a
message `cannot back up' and performs ordinary error recovery.
In either case, the rest of the action is not executed.
`YYEMPTY'
Value stored in `yychar' when there is no look-ahead token.
`YYERROR;'
Cause an immediate syntax error. This statement initiates error
recovery just as if the parser itself had detected an error;
however, it does not call `yyerror', and does not print any
message. If you want to print an error message, call `yyerror'
explicitly before the `YYERROR;' statement. *Note Error
Recovery::.
`YYRECOVERING'
This macro stands for an expression that has the value 1 when the
parser is recovering from a syntax error, and 0 the rest of the
time. *Note Error Recovery::.
`yychar'
Variable containing the current look-ahead token. (In a pure
parser, this is actually a local variable within `yyparse'.) When
there is no look-ahead token, the value `YYEMPTY' is stored in the
variable. *Note Look-Ahead Tokens: Look-Ahead.
`yyclearin;'
Discard the current look-ahead token. This is useful primarily in
error rules. *Note Error Recovery::.
`yyerrok;'
Resume generating error messages immediately for subsequent syntax
errors. This is useful primarily in error rules. *Note Error
Recovery::.
`@$'
Acts like a structure variable containing information on the
textual position of the grouping made by the current rule. *Note
Tracking Locations: Locations.
`@N'
Acts like a structure variable containing information on the
textual position of the Nth component of the current rule. *Note
Tracking Locations: Locations.

View File

@@ -28,6 +28,95 @@ License", "Conditions for Using Bison" and this permission notice may be
included in translations approved by the Free Software Foundation
instead of in the original English.

File: bison.info, Node: Action Features, Prev: Error Reporting, Up: Interface
Special Features for Use in Actions
===================================
Here is a table of Bison constructs, variables and macros that are
useful in actions.
`$$'
Acts like a variable that contains the semantic value for the
grouping made by the current rule. *Note Actions::.
`$N'
Acts like a variable that contains the semantic value for the Nth
component of the current rule. *Note Actions::.
`$<TYPEALT>$'
Like `$$' but specifies alternative TYPEALT in the union specified
by the `%union' declaration. *Note Data Types of Values in
Actions: Action Types.
`$<TYPEALT>N'
Like `$N' but specifies alternative TYPEALT in the union specified
by the `%union' declaration. *Note Data Types of Values in
Actions: Action Types.
`YYABORT;'
Return immediately from `yyparse', indicating failure. *Note The
Parser Function `yyparse': Parser Function.
`YYACCEPT;'
Return immediately from `yyparse', indicating success. *Note The
Parser Function `yyparse': Parser Function.
`YYBACKUP (TOKEN, VALUE);'
Unshift a token. This macro is allowed only for rules that reduce
a single value, and only when there is no look-ahead token. It
installs a look-ahead token with token type TOKEN and semantic
value VALUE; then it discards the value that was going to be
reduced by this rule.
If the macro is used when it is not valid, such as when there is a
look-ahead token already, then it reports a syntax error with a
message `cannot back up' and performs ordinary error recovery.
In either case, the rest of the action is not executed.
`YYEMPTY'
Value stored in `yychar' when there is no look-ahead token.
`YYERROR;'
Cause an immediate syntax error. This statement initiates error
recovery just as if the parser itself had detected an error;
however, it does not call `yyerror', and does not print any
message. If you want to print an error message, call `yyerror'
explicitly before the `YYERROR;' statement. *Note Error
Recovery::.
`YYRECOVERING'
This macro stands for an expression that has the value 1 when the
parser is recovering from a syntax error, and 0 the rest of the
time. *Note Error Recovery::.
`yychar'
Variable containing the current look-ahead token. (In a pure
parser, this is actually a local variable within `yyparse'.) When
there is no look-ahead token, the value `YYEMPTY' is stored in the
variable. *Note Look-Ahead Tokens: Look-Ahead.
`yyclearin;'
Discard the current look-ahead token. This is useful primarily in
error rules. *Note Error Recovery::.
`yyerrok;'
Resume generating error messages immediately for subsequent syntax
errors. This is useful primarily in error rules. *Note Error
Recovery::.
`@$'
Acts like a structure variable containing information on the
textual position of the grouping made by the current rule. *Note
Tracking Locations: Locations.
`@N'
Acts like a structure variable containing information on the
textual position of the Nth component of the current rule. *Note
Tracking Locations: Locations.

File: bison.info, Node: Algorithm, Next: Error Recovery, Prev: Interface, Up: Top
@@ -1118,19 +1207,12 @@ Tuning the parser:
Parser: Debugging.
`--locations'
Pretend that `%locactions' was specified. *Note Decl Summary::.
Pretend that `%locations' was specified. *Note Decl Summary::.
`-p PREFIX'
`--name-prefix=PREFIX'
Rename the external symbols used in the parser so that they start
with PREFIX instead of `yy'. The precise list of symbols renamed
is `yyparse', `yylex', `yyerror', `yynerrs', `yylval', `yychar'
and `yydebug'.
For example, if you use `-p c', the names become `cparse', `clex',
and so on.
*Note Multiple Parsers in the Same Program: Multiple Parsers.
Pretend that `%name-prefix="PREFIX"' was specified. *Note Decl
Summary::.
`-l'
`--no-lines'
@@ -1143,41 +1225,40 @@ Tuning the parser:
`-n'
`--no-parser'
Pretend that `%no_parser' was specified. *Note Decl Summary::.
Pretend that `%no-parser' was specified. *Note Decl Summary::.
`-k'
`--token-table'
Pretend that `%token_table' was specified. *Note Decl Summary::.
Pretend that `%token-table' was specified. *Note Decl Summary::.
Adjust the output:
`-d'
Pretend that `%verbose' was specified, i.e., write an extra output
`--defines'
Pretend that `%defines' was specified, i.e., write an extra output
file containing macro definitions for the token type names defined
in the grammar and the semantic value type `YYSTYPE', as well as a
few `extern' variable declarations. *Note Decl Summary::.
`--defines=DEFINES-FILE'
The behaviour of -DEFINES is the same than `-d'. The only
difference is that it has an optionnal argument which is the name
of the output filename.
Same as above, but save in the file DEFINES-FILE.
`-b FILE-PREFIX'
`--file-prefix=PREFIX'
Specify a prefix to use for all Bison output file names. The
names are chosen as if the input file were named `PREFIX.c'.
Pretend that `%verbose' was specified, i.e, specify prefix to use
for all Bison output file names. *Note Decl Summary::.
`-v'
`--verbose'
Pretend that `%verbose' was specified, i.e, write an extra output
file containing verbose descriptions of the grammar and parser.
*Note Decl Summary::, for more.
*Note Decl Summary::.
`-o OUTFILE'
`--output-file=OUTFILE'
Specify the name OUTFILE for the parser file.
`-o FILENAME'
`--output=FILENAME'
Specify the FILENAME for the parser file.
The other output files' names are constructed from OUTFILE as
The other output files' names are constructed from FILENAME as
described under the `-v' and `-d' options.
`-g'
@@ -1230,32 +1311,8 @@ find the corresponding short option.
--name-prefix=PREFIX -p NAME-PREFIX
--no-lines -l
--no-parser -n
--output-file=OUTFILE -o OUTFILE
--output=OUTFILE -o OUTFILE
--token-table -k
--verbose -v
--version -V

File: bison.info, Node: VMS Invocation, Prev: Option Cross Key, Up: Invocation
Invoking Bison under VMS
========================
The command line syntax for Bison on VMS is a variant of the usual
Bison command syntax--adapted to fit VMS conventions.
To find the VMS equivalent for any Bison option, start with the long
option, and substitute a `/' for the leading `--', and substitute a `_'
for each `-' in the name of the long option. For example, the
following invocation under VMS:
bison /debug/name_prefix=bar foo.y
is equivalent to the following command under POSIX.
bison --debug --name-prefix=bar foo.y
The VMS file system does not permit filenames such as `foo.tab.c'.
In the above example, the output file would instead be named
`foo_tab.c'.

View File

@@ -28,6 +28,30 @@ License", "Conditions for Using Bison" and this permission notice may be
included in translations approved by the Free Software Foundation
instead of in the original English.

File: bison.info, Node: VMS Invocation, Prev: Option Cross Key, Up: Invocation
Invoking Bison under VMS
========================
The command line syntax for Bison on VMS is a variant of the usual
Bison command syntax--adapted to fit VMS conventions.
To find the VMS equivalent for any Bison option, start with the long
option, and substitute a `/' for the leading `--', and substitute a `_'
for each `-' in the name of the long option. For example, the
following invocation under VMS:
bison /debug/name_prefix=bar foo.y
is equivalent to the following command under POSIX.
bison --debug --name-prefix=bar foo.y
The VMS file system does not permit filenames such as `foo.tab.c'.
In the above example, the output file would instead be named
`foo_tab.c'.

File: bison.info, Node: Table of Symbols, Next: Glossary, Prev: Invocation, Up: Top
@@ -172,11 +196,19 @@ Bison Symbols
Bison declaration to create a header file meant for the scanner.
*Note Decl Summary::.
`%file-prefix="PREFIX"'
Bison declaration to set tge prefix of the output files. *Note
Decl Summary::.
`%left'
Bison declaration to assign left associativity to token(s). *Note
Operator Precedence: Precedence Decl.
`%no_lines'
`%name-prefix="PREFIX"'
Bison declaration to rename the external symbols. *Note Decl
Summary::.
`%no-lines'
Bison declaration to avoid generating `#line' directives in the
parser file. *Note Decl Summary::.
@@ -184,11 +216,15 @@ Bison Symbols
Bison declaration to assign non-associativity to token(s). *Note
Operator Precedence: Precedence Decl.
`%output="FILENAME"'
Bison declaration to set the name of the parser file. *Note Decl
Summary::.
`%prec'
Bison declaration to assign a precedence to a specific rule.
*Note Context-Dependent Precedence: Contextual Precedence.
`%pure_parser'
`%pure-parser'
Bison declaration to request a pure (reentrant) parser. *Note A
Pure (Reentrant) Parser: Pure Decl.
@@ -204,7 +240,7 @@ Bison Symbols
Bison declaration to declare token(s) without specifying
precedence. *Note Token Type Names: Token Decl.
`%token_table'
`%token-table'
Bison declaration to include a token name table in the parser file.
*Note Decl Summary::.

View File

@@ -3167,7 +3167,7 @@ valid grammar.
@cindex declaration summary
@cindex summary, Bison declaration
Here is a summary of all Bison declarations:
Here is a summary of the declarations used to define a grammar:
@table @code
@item %union
@@ -3202,40 +3202,14 @@ Start-Symbol}).
@item %expect
Declare the expected number of shift-reduce conflicts
(@pxref{Expect Decl, ,Suppressing Conflict Warnings}).
@end table
@item %yacc
@itemx %fixed_output_files
Pretend the option @option{--yacc} was given, i.e., imitate Yacc,
including its naming conventions. @xref{Bison Options}, for more.
@item %locations
Generate the code processing the locations (@pxref{Action Features,
,Special Features for Use in Actions}). This mode is enabled as soon as
the grammar uses the special @samp{@@@var{n}} tokens, but if your
grammar does not use it, using @samp{%locations} allows for more
accurate parse error messages.
@item %pure_parser
Request a pure (reentrant) parser program (@pxref{Pure Decl, ,A Pure
(Reentrant) Parser}).
@item %no_parser
Do not include any C code in the parser file; generate tables only. The
parser file contains just @code{#define} directives and static variable
declarations.
This option also tells Bison to write the C code for the grammar actions
into a file named @file{@var{filename}.act}, in the form of a
brace-surrounded body fit for a @code{switch} statement.
@item %no_lines
Don't generate any @code{#line} preprocessor commands in the parser
file. Ordinarily Bison writes these commands in the parser file so that
the C compiler and debuggers will associate errors and object code with
your source file (the grammar file). This directive causes them to
associate errors with the parser file, treating it an independent source
file in its own right.
@sp 1
@noindent
In order to change the behavior of @command{bison}, use the following
directives:
@table @code
@item %debug
Output a definition of the macro @code{YYDEBUG} into the parser file, so
that the debugging facilities are compiled. @xref{Debugging, ,Debugging
@@ -3254,35 +3228,64 @@ This output file is essential if you wish to put the definition of
be able to refer to token type codes and the variable
@code{yylval}. @xref{Token Values, ,Semantic Values of Tokens}.@refill
@item %file-prefix="@var{prefix}"
Specify a prefix to use for all Bison output file names. The names are
chosen as if the input file were named @file{@var{prefix}.y}.
@c @item %header_extension
@c Specify the extension of the parser header file generated when
@c @code{%define} or @samp{-d} are used.
@c
@c For example, a grammar file named @file{foo.ypp} and containing a
@c @code{%header_extension .hh} directive will produce a header file
@c named @file{foo.tab.hh}
@item %locations
Generate the code processing the locations (@pxref{Action Features,
,Special Features for Use in Actions}). This mode is enabled as soon as
the grammar uses the special @samp{@@@var{n}} tokens, but if your
grammar does not use it, using @samp{%locations} allows for more
accurate parse error messages.
@item %name-prefix="@var{prefix}"
Rename the external symbols used in the parser so that they start with
@var{prefix} instead of @samp{yy}. The precise list of symbols renamed
is @code{yyparse}, @code{yylex}, @code{yyerror}, @code{yynerrs},
@code{yylval}, @code{yychar} and @code{yydebug}. For example, if you
use @samp{%name-prefix="c_"}, the names become @code{c_parse},
@code{c_lex}, and so on. @xref{Multiple Parsers, ,Multiple Parsers in
the Same Program}.
@item %no-parser
Do not include any C code in the parser file; generate tables only. The
parser file contains just @code{#define} directives and static variable
declarations.
This option also tells Bison to write the C code for the grammar actions
into a file named @file{@var{filename}.act}, in the form of a
brace-surrounded body fit for a @code{switch} statement.
@item %no-lines
Don't generate any @code{#line} preprocessor commands in the parser
file. Ordinarily Bison writes these commands in the parser file so that
the C compiler and debuggers will associate errors and object code with
your source file (the grammar file). This directive causes them to
associate errors with the parser file, treating it an independent source
file in its own right.
@item %output="@var{filename}"
Specify the @var{filename} for the parser file.
@item %pure-parser
Request a pure (reentrant) parser program (@pxref{Pure Decl, ,A Pure
(Reentrant) Parser}).
@c @item %source_extension
@c Specify the extension of the parser output file.
@c
@c For example, a grammar file named @file{foo.yy} and containing a
@c @code{%source_extension .cpp} directive will produce a parser file
@c named @file{foo.tab.cpp}
@c
@c @item %header_extension
@c Specify the extension of the parser header file generated when
@c @code{%define} or @samp{-d} are used.
@c
@c For example, a garmmar file named @file{foo.ypp} and containing a
@c @code{%header_extension .hh} directive will produce a header file
@c named @file{foo.tab.hh}
@item %verbose
Write an extra output file containing verbose descriptions of the
parser states and what is done for each type of look-ahead token in
that state.
This file also describes all the conflicts, both those resolved by
operator precedence and the unresolved ones.
The file's name is made by removing @samp{.tab.c} or @samp{.c} from
the parser output file name, and adding @samp{.output} instead.@refill
Therefore, if the input file is @file{foo.y}, then the parser file is
called @file{foo.tab.c} by default. As a consequence, the verbose
output file is called @file{foo.output}.@refill
@item %token_table
Generate an array of token names in the parser file. The name of the
@@ -3316,8 +3319,31 @@ The number of grammar rules,
@item YYNSTATES
The number of parser states (@pxref{Parser States}).
@end table
@item %verbose
Write an extra output file containing verbose descriptions of the
parser states and what is done for each type of look-ahead token in
that state.
This file also describes all the conflicts, both those resolved by
operator precedence and the unresolved ones.
The file's name is made by removing @samp{.tab.c} or @samp{.c} from
the parser output file name, and adding @samp{.output} instead.@refill
Therefore, if the input file is @file{foo.y}, then the parser file is
called @file{foo.tab.c} by default. As a consequence, the verbose
output file is called @file{foo.output}.@refill
@item %yacc
@itemx %fixed-output-files
Pretend the option @option{--yacc} was given, i.e., imitate Yacc,
including its naming conventions. @xref{Bison Options}, for more.
@end table
@node Multiple Parsers
@section Multiple Parsers in the Same Program
@@ -5049,19 +5075,12 @@ that the debugging facilities are compiled. @xref{Debugging, ,Debugging
Your Parser}.
@item --locations
Pretend that @code{%locactions} was specified. @xref{Decl Summary}.
Pretend that @code{%locations} was specified. @xref{Decl Summary}.
@item -p @var{prefix}
@itemx --name-prefix=@var{prefix}
Rename the external symbols used in the parser so that they start with
@var{prefix} instead of @samp{yy}. The precise list of symbols renamed
is @code{yyparse}, @code{yylex}, @code{yyerror}, @code{yynerrs},
@code{yylval}, @code{yychar} and @code{yydebug}.
For example, if you use @samp{-p c}, the names become @code{cparse},
@code{clex}, and so on.
@xref{Multiple Parsers, ,Multiple Parsers in the Same Program}.
Pretend that @code{%name-prefix="@var{prefix}"} was specified.
@xref{Decl Summary}.
@item -l
@itemx --no-lines
@@ -5073,11 +5092,11 @@ parser file, treating it as an independent source file in its own right.
@item -n
@itemx --no-parser
Pretend that @code{%no_parser} was specified. @xref{Decl Summary}.
Pretend that @code{%no-parser} was specified. @xref{Decl Summary}.
@item -k
@itemx --token-table
Pretend that @code{%token_table} was specified. @xref{Decl Summary}.
Pretend that @code{%token-table} was specified. @xref{Decl Summary}.
@end table
@noindent
@@ -5085,33 +5104,32 @@ Adjust the output:
@table @option
@item -d
Pretend that @code{%verbose} was specified, i.e., write an extra output
@itemx --defines
Pretend that @code{%defines} was specified, i.e., write an extra output
file containing macro definitions for the token type names defined in
the grammar and the semantic value type @code{YYSTYPE}, as well as a few
@code{extern} variable declarations. @xref{Decl Summary}.
@item --defines=@var{defines-file}
The behaviour of @var{--defines} is the same than @samp{-d}. The only
difference is that it has an optionnal argument which is the name of
the output filename.
Same as above, but save in the file @var{defines-file}.
@item -b @var{file-prefix}
@itemx --file-prefix=@var{prefix}
Specify a prefix to use for all Bison output file names. The names are
chosen as if the input file were named @file{@var{prefix}.c}.
Pretend that @code{%verbose} was specified, i.e, specify prefix to use
for all Bison output file names. @xref{Decl Summary}.
@item -v
@itemx --verbose
Pretend that @code{%verbose} was specified, i.e, write an extra output
file containing verbose descriptions of the grammar and
parser. @xref{Decl Summary}, for more.
parser. @xref{Decl Summary}.
@item -o @var{outfile}
@itemx --output-file=@var{outfile}
Specify the name @var{outfile} for the parser file.
@item -o @var{filename}
@itemx --output=@var{filename}
Specify the @var{filename} for the parser file.
The other output files' names are constructed from @var{outfile}
as described under the @samp{-v} and @samp{-d} options.
The other output files' names are constructed from @var{filename} as
described under the @samp{-v} and @samp{-d} options.
@item -g
Output a VCG definition of the LALR(1) grammar automaton computed by
@@ -5119,7 +5137,7 @@ Bison. If the grammar file is @file{foo.y}, the VCG output file will
be @file{foo.vcg}.
@item --graph=@var{graph-file}
The behaviour of @var{--graph} is the same than @samp{-g}. The only
The behaviour of @var{--graph} is the same than @samp{-g}. The only
difference is that it has an optionnal argument which is the name of
the output graph filename.
@end table
@@ -5168,7 +5186,7 @@ the corresponding short option.
\line{ --name-prefix \leaderfill -p}
\line{ --no-lines \leaderfill -l}
\line{ --no-parser \leaderfill -n}
\line{ --output-file \leaderfill -o}
\line{ --output \leaderfill -o}
\line{ --token-table \leaderfill -k}
\line{ --verbose \leaderfill -v}
\line{ --version \leaderfill -V}
@@ -5187,7 +5205,7 @@ the corresponding short option.
--name-prefix=@var{prefix} -p @var{name-prefix}
--no-lines -l
--no-parser -n
--output-file=@var{outfile} -o @var{outfile}
--output=@var{outfile} -o @var{outfile}
--token-table -k
--verbose -v
--version -V
@@ -5361,6 +5379,10 @@ Equip the parser for debugging. @xref{Decl Summary}.
Bison declaration to create a header file meant for the scanner.
@xref{Decl Summary}.
@item %file-prefix="@var{prefix}"
Bison declaration to set tge prefix of the output files. @xref{Decl
Summary}.
@c @item %source_extension
@c Bison declaration to specify the generated parser output file extension.
@c @xref{Decl Summary}.
@@ -5373,7 +5395,10 @@ Bison declaration to create a header file meant for the scanner.
Bison declaration to assign left associativity to token(s).
@xref{Precedence Decl, ,Operator Precedence}.
@item %no_lines
@item %name-prefix="@var{prefix}"
Bison declaration to rename the external symbols. @xref{Decl Summary}.
@item %no-lines
Bison declaration to avoid generating @code{#line} directives in the
parser file. @xref{Decl Summary}.
@@ -5381,11 +5406,15 @@ parser file. @xref{Decl Summary}.
Bison declaration to assign non-associativity to token(s).
@xref{Precedence Decl, ,Operator Precedence}.
@item %output="@var{filename}"
Bison declaration to set the name of the parser file. @xref{Decl
Summary}.
@item %prec
Bison declaration to assign a precedence to a specific rule.
@xref{Contextual Precedence, ,Context-Dependent Precedence}.
@item %pure_parser
@item %pure-parser
Bison declaration to request a pure (reentrant) parser.
@xref{Pure Decl, ,A Pure (Reentrant) Parser}.
@@ -5400,7 +5429,7 @@ Bison declaration to specify the start symbol. @xref{Start Decl, ,The Start-Sym
Bison declaration to declare token(s) without specifying precedence.
@xref{Token Decl, ,Token Type Names}.
@item %token_table
@item %token-table
Bison declaration to include a token name table in the parser file.
@xref{Decl Summary}.

View File

@@ -1,4 +1,4 @@
@set UPDATED 20 September 2001
@set UPDATED-MONTH September 2001
@set UPDATED 4 November 2001
@set UPDATED-MONTH November 2001
@set EDITION 1.30a
@set VERSION 1.30a

View File

@@ -1,4 +1,4 @@
@set UPDATED 20 September 2001
@set UPDATED-MONTH September 2001
@set UPDATED 4 November 2001
@set UPDATED-MONTH November 2001
@set EDITION 1.30a
@set VERSION 1.30a