summaryrefslogtreecommitdiff
path: root/tests/sets.at
diff options
context:
space:
mode:
authorAkim Demaille <akim.demaille@gmail.com>2019-01-23 07:26:23 +0100
committerAkim Demaille <akim.demaille@gmail.com>2019-01-26 16:21:35 +0100
commit21a7fa8063171de5afae1caae506b0e0b10a5824 (patch)
treef359e4fafdc4feac5d6b3698ac278bc1e51b78ab /tests/sets.at
parent83463dfbee32f0d289a6fcfc2cf7801f5a910c82 (diff)
downloadbison-21a7fa8063171de5afae1caae506b0e0b10a5824.tar.gz
traces: always print the reduced grammar and fix it
* src/gram.c (grammar_dump): Print the effective number first instead of last. And fix it (remove the incorrect "+1"). Use t/f for Booleans. * src/reduce.c: When asked, always print the reduced grammar, even if there was nothing useless. * tests/sets.at (Reduced Grammar): Check that.
Diffstat (limited to 'tests/sets.at')
-rw-r--r--tests/sets.at60
1 files changed, 60 insertions, 0 deletions
diff --git a/tests/sets.at b/tests/sets.at
index 7cd254a9..01339c22 100644
--- a/tests/sets.at
+++ b/tests/sets.at
@@ -300,3 +300,63 @@ AT_CHECK([sed -n '
0, [expout])
AT_CLEANUP
+
+
+
+## ----------------- ##
+## Reduced Grammar. ##
+## ----------------- ##
+
+# Check information about the grammar, once reduced.
+
+AT_SETUP([Reduced Grammar])
+
+AT_DATA([input.y],
+[[%%
+expr: expr "+" term | term
+term: term "*" fact | fact
+fact: "num"
+]])
+
+AT_BISON_CHECK([[--trace=grammar -o input.c input.y]], [], [],
+[[Reduced Grammar
+
+ntokens = 6, nvars = 4, nsyms = 10, nrules = 6, nritems = 17
+
+Variables
+---------
+
+Value Sprec Sassoc Tag
+ 6 0 0 $accept
+ 7 0 0 expr
+ 8 0 0 term
+ 9 0 0 fact
+
+
+Rules
+-----
+
+Num (Num, Prec, Assoc, Useful, UselessChain, Ritem Range) Lhs -> Rhs (Ritem range)
+ 0 ( 0, 0, 0, t, 0- 1) 6 -> 7 0
+ 1 ( 1, 0, 0, t, 3- 5) 7 -> 7 3 8
+ 2 ( 2, 0, 0, t, 7- 7) 7 -> 8
+ 3 ( 3, 0, 0, t, 9-11) 8 -> 8 4 9
+ 4 ( 4, 0, 0, t, 13-13) 8 -> 9
+ 5 ( 5, 0, 0, t, 15-15) 9 -> 5
+
+
+Rules interpreted
+-----------------
+
+0 $accept: expr $end
+1 expr: expr "+" term
+2 expr: term
+3 term: term "*" fact
+4 term: fact
+5 fact: "num"
+
+
+reduced input.y defines 6 terminals, 4 nonterminals, and 6 productions.
+]])
+
+AT_CLEANUP