3553 |
Generate an array of token names in the parser file. The name of the |
Generate an array of token names in the parser file. The name of the |
3554 |
array is @code{yytname}; @code{yytname[@var{i}]} is the name of the |
array is @code{yytname}; @code{yytname[@var{i}]} is the name of the |
3555 |
token whose internal Bison token code number is @var{i}. The first |
token whose internal Bison token code number is @var{i}. The first |
3556 |
three elements of @code{yytname} are always @code{"$"}, @code{"error"}, |
three elements of @code{yytname} are always @code{"$end"}, |
3557 |
and @code{"$undefined."}; after these come the symbols defined in the |
@code{"error"}, and @code{"$undefined"}; after these come the symbols |
3558 |
grammar file. |
defined in the grammar file. |
3559 |
|
|
3560 |
For single-character literal tokens and literal string tokens, the name |
For single-character literal tokens and literal string tokens, the name |
3561 |
in the table includes the single-quote or double-quote characters: for |
in the table includes the single-quote or double-quote characters: for |
5276 |
%% |
%% |
5277 |
@end example |
@end example |
5278 |
|
|
5279 |
@command{bison} reports that @samp{calc.y contains 1 useless nonterminal |
@command{bison} reports: |
5280 |
and 1 useless rule} and that @samp{calc.y contains 7 shift/reduce |
|
5281 |
conflicts}. When given @option{--report=state}, in addition to |
@example |
5282 |
@file{calc.tab.c}, it creates a file @file{calc.output} with contents |
calc.y: warning: 1 useless nonterminal and 1 useless rule |
5283 |
detailed below. The order of the output and the exact presentation |
calc.y:11.1-7: warning: useless nonterminal: useless |
5284 |
might vary, but the interpretation is the same. |
calc.y:11.8-12: warning: useless rule: useless: STR |
5285 |
|
calc.y contains 7 shift/reduce conflicts. |
5286 |
|
@end example |
5287 |
|
|
5288 |
|
When given @option{--report=state}, in addition to @file{calc.tab.c}, it |
5289 |
|
creates a file @file{calc.output} with contents detailed below. The |
5290 |
|
order of the output and the exact presentation might vary, but the |
5291 |
|
interpretation is the same. |
5292 |
|
|
5293 |
The first section includes details on conflicts that were solved thanks |
The first section includes details on conflicts that were solved thanks |
5294 |
to precedence and/or associativity: |
to precedence and/or associativity: |
5341 |
Grammar |
Grammar |
5342 |
|
|
5343 |
Number, Line, Rule |
Number, Line, Rule |
5344 |
0 5 $axiom -> exp $ |
0 5 $accept -> exp $end |
5345 |
1 5 exp -> exp '+' exp |
1 5 exp -> exp '+' exp |
5346 |
2 6 exp -> exp '-' exp |
2 6 exp -> exp '-' exp |
5347 |
3 7 exp -> exp '*' exp |
3 7 exp -> exp '*' exp |
5355 |
@example |
@example |
5356 |
Terminals, with rules where they appear |
Terminals, with rules where they appear |
5357 |
|
|
5358 |
$ (0) 0 |
$end (0) 0 |
5359 |
'*' (42) 3 |
'*' (42) 3 |
5360 |
'+' (43) 1 |
'+' (43) 1 |
5361 |
'-' (45) 2 |
'-' (45) 2 |
5365 |
|
|
5366 |
Nonterminals, with rules where they appear |
Nonterminals, with rules where they appear |
5367 |
|
|
5368 |
$axiom (8) |
$accept (8) |
5369 |
on left: 0 |
on left: 0 |
5370 |
exp (9) |
exp (9) |
5371 |
on left: 1 2 3 4 5, on right: 0 1 2 3 4 |
on left: 1 2 3 4 5, on right: 0 1 2 3 4 |
5383 |
@example |
@example |
5384 |
state 0 |
state 0 |
5385 |
|
|
5386 |
$axiom -> . exp $ (rule 0) |
$accept -> . exp $ (rule 0) |
5387 |
|
|
5388 |
NUM shift, and go to state 1 |
NUM shift, and go to state 1 |
5389 |
|
|
5414 |
@example |
@example |
5415 |
state 0 |
state 0 |
5416 |
|
|
5417 |
$axiom -> . exp $ (rule 0) |
$accept -> . exp $ (rule 0) |
5418 |
exp -> . exp '+' exp (rule 1) |
exp -> . exp '+' exp (rule 1) |
5419 |
exp -> . exp '-' exp (rule 2) |
exp -> . exp '-' exp (rule 2) |
5420 |
exp -> . exp '*' exp (rule 3) |
exp -> . exp '*' exp (rule 3) |
5446 |
@example |
@example |
5447 |
state 2 |
state 2 |
5448 |
|
|
5449 |
$axiom -> exp . $ (rule 0) |
$accept -> exp . $ (rule 0) |
5450 |
exp -> exp . '+' exp (rule 1) |
exp -> exp . '+' exp (rule 1) |
5451 |
exp -> exp . '-' exp (rule 2) |
exp -> exp . '-' exp (rule 2) |
5452 |
exp -> exp . '*' exp (rule 3) |
exp -> exp . '*' exp (rule 3) |
5473 |
@example |
@example |
5474 |
state 3 |
state 3 |
5475 |
|
|
5476 |
$axiom -> exp $ . (rule 0) |
$accept -> exp $ . (rule 0) |
5477 |
|
|
5478 |
$default accept |
$default accept |
5479 |
@end example |
@end example |
6013 |
@table @code |
@table @code |
6014 |
@item @@$ |
@item @@$ |
6015 |
In an action, the location of the left-hand side of the rule. |
In an action, the location of the left-hand side of the rule. |
6016 |
@xref{Locations, , Locations Overview}. |
@xref{Locations, , Locations Overview}. |
6017 |
|
|
6018 |
@item @@@var{n} |
@item @@@var{n} |
6019 |
In an action, the location of the @var{n}-th symbol of the right-hand |
In an action, the location of the @var{n}-th symbol of the right-hand |
6027 |
In an action, the semantic value of the @var{n}-th symbol of the |
In an action, the semantic value of the @var{n}-th symbol of the |
6028 |
right-hand side of the rule. @xref{Actions}. |
right-hand side of the rule. @xref{Actions}. |
6029 |
|
|
6030 |
|
@item $accept |
6031 |
|
The predefined nonterminal whose only rule is @samp{$accept: @var{start} |
6032 |
|
$end}, where @var{start} is the start symbol. @xref{Start Decl, , The |
6033 |
|
Start-Symbol}. It cannot be used in the grammar. |
6034 |
|
|
6035 |
|
@item $end |
6036 |
|
The predefined token marking the end of the token stream. It cannot be |
6037 |
|
used in the grammar. |
6038 |
|
|
6039 |
|
@item $undefined |
6040 |
|
The predefined token onto which all undefined values returned by |
6041 |
|
@code{yylex} are mapped. It cannot be used in the grammar, rather, use |
6042 |
|
@code{error}. |
6043 |
|
|
6044 |
@item error |
@item error |
6045 |
A token name reserved for error recovery. This token may be used in |
A token name reserved for error recovery. This token may be used in |
6046 |
grammar rules so as to allow the Bison parser to recognize an error in |
grammar rules so as to allow the Bison parser to recognize an error in |