gram: detect and report (in debug traces) useless chain rules

A rule is a useless chain iff it's a chain (aka unit, or injection)
rule (i.e., the RHS has length 1), and it's useless (it has no used
defined semantic action).

* src/gram.h, src/gram.c (rule_useless_chain_p): New.
(grammar_dump): Report useless chain rules.
* tests/sets.at: Check the traces.
This commit is contained in:
Akim Demaille
2019-01-29 18:53:35 +01:00
parent 8b5fc2143f
commit 781d2b02de
3 changed files with 17 additions and 7 deletions

View File

@@ -337,12 +337,12 @@ 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
0 ( 0, 0, 0, t, f, 0- 1) 6 -> 7 0
1 ( 1, 0, 0, t, f, 3- 5) 7 -> 7 3 8
2 ( 2, 0, 0, t, t, 7- 7) 7 -> 8
3 ( 3, 0, 0, t, f, 9-11) 8 -> 8 4 9
4 ( 4, 0, 0, t, t, 13-13) 8 -> 9
5 ( 5, 0, 0, t, t, 15-15) 9 -> 5
Rules interpreted