doc: we now show the type of the symbols

* doc/bison.texi (Understanding Your Parser): Update the output
from Bison.
Use types in the example, and show them in the report.
* NEWS: Update.
This commit is contained in:
Akim Demaille
2018-06-19 08:32:19 +02:00
parent 34d1773990
commit 70875b4873
2 changed files with 37 additions and 9 deletions

13
NEWS
View File

@@ -2,6 +2,19 @@ GNU Bison NEWS
* Noteworthy changes in release ?.? (????-??-??) [?] * Noteworthy changes in release ?.? (????-??-??) [?]
** Reports include the type of the symbols
The sections about terminal and nonterminal symbols of the '*.output' file
now specify their declared type. For instance, for:
%token <ival> NUM
the report now shows '<ival>':
Terminals, with rules where they appear
NUM <ival> (258) 5
** Diagnostics about useless rules ** Diagnostics about useless rules
In the following grammar, the 'exp' nonterminal is trivially useless. So, In the following grammar, the 'exp' nonterminal is trivially useless. So,

View File

@@ -8979,7 +8979,21 @@ a consequence, the verbose output file is called @file{foo.output}.
The following grammar file, @file{calc.y}, will be used in the sequel: The following grammar file, @file{calc.y}, will be used in the sequel:
@example @example
%token NUM STR @group
%union
{
int ival;
const char *sval;
}
@end group
@group
%token <ival> NUM
%nterm <ival> exp
@end group
@group
%token <sval> STR
%nterm <sval> useless
@end group
@group @group
%left '+' '-' %left '+' '-'
%left '*' %left '*'
@@ -9001,11 +9015,12 @@ useless: STR;
@command{bison} reports: @command{bison} reports:
@example @example
calc.y: warning: 1 nonterminal useless in grammar calc.y: warning: 1 nonterminal useless in grammar [-Wother]
calc.y: warning: 1 rule useless in grammar calc.y: warning: 1 rule useless in grammar [-Wother]
calc.y:12.1-7: warning: nonterminal useless in grammar: useless calc.y:19.1-7: warning: nonterminal useless in grammar: useless [-Wother]
calc.y:12.10-12: warning: rule useless in grammar: useless: STR useless: STR;
calc.y: conflicts: 7 shift/reduce ^^^^^^^
calc.y: warning: 7 shift/reduce conflicts [-Wconflicts-sr]
@end example @end example
When given @option{--report=state}, in addition to @file{calc.tab.c}, it When given @option{--report=state}, in addition to @file{calc.tab.c}, it
@@ -9074,8 +9089,8 @@ $end (0) 0
'-' (45) 2 '-' (45) 2
'/' (47) 4 '/' (47) 4
error (256) error (256)
NUM (258) 5 NUM <ival> (258) 5
STR (259) STR <sval> (259)
@end group @end group
@group @group
@@ -9083,7 +9098,7 @@ Nonterminals, with rules where they appear
$accept (9) $accept (9)
on left: 0 on left: 0
exp (10) exp <ival> (10)
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
@end group @end group
@end example @end example