From 70875b4873c15ed20c5e5bcdbeb54abb3b2f09bd Mon Sep 17 00:00:00 2001 From: Akim Demaille Date: Tue, 19 Jun 2018 08:32:19 +0200 Subject: [PATCH] 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. --- NEWS | 13 +++++++++++++ doc/bison.texi | 33 ++++++++++++++++++++++++--------- 2 files changed, 37 insertions(+), 9 deletions(-) diff --git a/NEWS b/NEWS index dcfddbdc..a02e9bc5 100644 --- a/NEWS +++ b/NEWS @@ -2,6 +2,19 @@ GNU Bison NEWS * 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 NUM + + the report now shows '': + + Terminals, with rules where they appear + + NUM (258) 5 + ** Diagnostics about useless rules In the following grammar, the 'exp' nonterminal is trivially useless. So, diff --git a/doc/bison.texi b/doc/bison.texi index 7d125b55..69e0e8dd 100644 --- a/doc/bison.texi +++ b/doc/bison.texi @@ -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: @example -%token NUM STR +@group +%union +{ + int ival; + const char *sval; +} +@end group +@group +%token NUM +%nterm exp +@end group +@group +%token STR +%nterm useless +@end group @group %left '+' '-' %left '*' @@ -9001,11 +9015,12 @@ useless: STR; @command{bison} reports: @example -calc.y: warning: 1 nonterminal useless in grammar -calc.y: warning: 1 rule useless in grammar -calc.y:12.1-7: warning: nonterminal useless in grammar: useless -calc.y:12.10-12: warning: rule useless in grammar: useless: STR -calc.y: conflicts: 7 shift/reduce +calc.y: warning: 1 nonterminal useless in grammar [-Wother] +calc.y: warning: 1 rule useless in grammar [-Wother] +calc.y:19.1-7: warning: nonterminal useless in grammar: useless [-Wother] + useless: STR; + ^^^^^^^ +calc.y: warning: 7 shift/reduce conflicts [-Wconflicts-sr] @end example When given @option{--report=state}, in addition to @file{calc.tab.c}, it @@ -9074,8 +9089,8 @@ $end (0) 0 '-' (45) 2 '/' (47) 4 error (256) -NUM (258) 5 -STR (259) +NUM (258) 5 +STR (259) @end group @group @@ -9083,7 +9098,7 @@ Nonterminals, with rules where they appear $accept (9) on left: 0 -exp (10) +exp (10) on left: 1 2 3 4 5, on right: 0 1 2 3 4 @end group @end example