gram.c: also 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.
This commit is contained in:
Yuichiro Kaneko
2019-11-11 08:57:15 +09:00
committed by Akim Demaille
parent af000bab11
commit 17d34c231b
2 changed files with 117 additions and 9 deletions

View File

@@ -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,