commit b672654f925bd3a8ab5b051e4f31baf48ce36c8c
Author: Yuichiro Kaneko <spiketeika@gmail.com>
Date:   Tue Oct 22 12:18:32 2019 +0900

    gram.c: Print terminals in grammar_dump
    
    * src/gram.c (grammar_dump): Print terminals likewise non terminals
    * tests/sets.at (Reduced Grammar): Update test case to
      catch up the change and add a test case where prec and assoc are used.

diff --git a/src/gram.c b/src/gram.c
index 5753f70f..01d5c131 100644
--- a/src/gram.c
+++ b/src/gram.c
@@ -259,12 +259,11 @@ grammar_dump (FILE *out, const char *title)
            "ntokens = %d, nvars = %d, nsyms = %d, nrules = %d, nritems = %d\n\n",
            ntokens, nvars, nsyms, nrules, nritems);
 
-
-  fprintf (out, "Variables\n---------\n\n");
+  fprintf (out, "Tokens\n------\n\n");
   {
     fprintf (out, "Value  Sprec  Sassoc  Tag\n");
 
-    for (symbol_number i = ntokens; i < nsyms; i++)
+    for (symbol_number i = 0; i < ntokens; i++)
       fprintf (out, "%5d  %5d   %5d  %s\n",
                i,
                symbols[i]->content->prec, symbols[i]->content->assoc,
@@ -272,6 +271,16 @@ grammar_dump (FILE *out, const char *title)
     fprintf (out, "\n\n");
   }
 
+  fprintf (out, "Non terminals\n-------------\n\n");
+  {
+    fprintf (out, "Value  Tag\n");
+
+    for (symbol_number i = ntokens; i < nsyms; i++)
+      fprintf (out, "%5d  %s\n",
+               i, symbols[i]->tag);
+    fprintf (out, "\n\n");
+  }
+
   fprintf (out, "Rules\n-----\n\n");
   {
     fprintf (out,
diff --git a/tests/sets.at b/tests/sets.at
index 5dbc50dc..a694cc95 100644
--- a/tests/sets.at
+++ b/tests/sets.at
@@ -329,14 +329,27 @@ Reduced Grammar
 
 ntokens = 7, nvars = 4, nsyms = 11, nrules = 6, nritems = 17
 
-Variables
----------
+Tokens
+------
 
 Value  Sprec  Sassoc  Tag
-    7      0       0  $accept
-    8      0       0  expr
-    9      0       0  term
-   10      0       0  fact
+    0      0       0  $end
+    1      0       0  error
+    2      0       0  $undefined
+    3      0       0  "+"
+    4      0       0  "*"
+    5      0       0  "useless"
+    6      0       0  "num"
+
+
+Non terminals
+-------------
+
+Value  Tag
+    7  $accept
+    8  expr
+    9  term
+   10  fact
 
 
 Rules
@@ -368,3 +381,89 @@ reduced input.y defines 7 terminals, 4 nonterminals, and 6 productions.
 ]])
 
 AT_CLEANUP
+
+
+## ------------------------------------- ##
+## Reduced Grammar with prec and assoc.  ##
+## ------------------------------------- ##
+
+# Check information about the grammar, once reduced.
+
+AT_SETUP([Reduced Grammar with prec and assoc])
+
+AT_DATA([input.y],
+[[%nonassoc '<' '>'
+%left '+' '-'
+%right '^' '='
+%%
+exp:
+   exp '<' exp
+ | exp '>' exp
+ | exp '+' exp
+ | exp '-' exp
+ | exp '^' exp
+ | exp '=' exp
+ | "exp"
+ ;
+]])
+
+AT_BISON_CHECK([[--trace=grammar -o input.c input.y]], [], [],
+[[Reduced Grammar
+
+ntokens = 10, nvars = 2, nsyms = 12, nrules = 8, nritems = 29
+
+Tokens
+------
+
+Value  Sprec  Sassoc  Tag
+    0      0       0  $end
+    1      0       0  error
+    2      0       0  $undefined
+    3      1       3  '<'
+    4      1       3  '>'
+    5      2       2  '+'
+    6      2       2  '-'
+    7      3       1  '^'
+    8      3       1  '='
+    9      0       0  "exp"
+
+
+Non terminals
+-------------
+
+Value  Tag
+   10  $accept
+   11  exp
+
+
+Rules
+-----
+
+Num (Prec, Assoc, Useful, UselessChain) Lhs -> (Ritem Range) Rhs
+  0 ( 0,  0,  t,  f)   10 -> ( 0- 1)  11   0
+  1 ( 1,  3,  t,  f)   11 -> ( 3- 5)  11   3  11
+  2 ( 1,  3,  t,  f)   11 -> ( 7- 9)  11   4  11
+  3 ( 2,  2,  t,  f)   11 -> (11-13)  11   5  11
+  4 ( 2,  2,  t,  f)   11 -> (15-17)  11   6  11
+  5 ( 3,  1,  t,  f)   11 -> (19-21)  11   7  11
+  6 ( 3,  1,  t,  f)   11 -> (23-25)  11   8  11
+  7 ( 0,  0,  t,  t)   11 -> (27-27)   9
+
+
+Rules interpreted
+-----------------
+
+0      $accept: exp $end
+1      exp: exp '<' exp
+2      exp: exp '>' exp
+3      exp: exp '+' exp
+4      exp: exp '-' exp
+5      exp: exp '^' exp
+6      exp: exp '=' exp
+7      exp: "exp"
+
+
+reduced input.y defines 10 terminals, 2 nonterminals, and 8 productions.
+]])
+
+AT_CLEANUP
