diff options
author | Timothee Cour <timothee.cour2@gmail.com> | 2021-08-25 22:04:18 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-08-26 07:04:18 +0200 |
commit | 98f7254fb25d402a3cad8e7de81207448fc7b322 (patch) | |
tree | dfe342b15b7aeca5af8a1cda0cfb60e14958bdb1 | |
parent | c70e4040bd69e1ee32b6c676dbfc763c7cf4df37 (diff) | |
download | Nim-98f7254fb25d402a3cad8e7de81207448fc7b322.tar.gz |
followup #18711 grammar_nanny now reports unused non-terminals (#18746)
* followup #18711 cleanup unused grammar rules * make tools/grammar_nanny.nim report unused terminals * revert removal of some grammar comments
-rw-r--r-- | tools/grammar_nanny.nim | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/tools/grammar_nanny.nim b/tools/grammar_nanny.nim index 397041559..5120ef976 100644 --- a/tools/grammar_nanny.nim +++ b/tools/grammar_nanny.nim @@ -4,7 +4,7 @@ import std / [strutils, sets] import ".." / compiler / [ - llstream, ast, lexer, options, msgs, idents, + llstream, lexer, options, msgs, idents, lineinfos, pathutils] proc checkGrammarFileImpl(cache: IdentCache, config: ConfigRef) = @@ -35,6 +35,10 @@ proc checkGrammarFileImpl(cache: IdentCache, config: ConfigRef) = usedSyms.incl word else: rawGetTok(L, tok) + for u in declaredSyms: + if u notin usedSyms: + echo "Unused non-terminal: ", u + for u in usedSyms: if u notin declaredSyms: echo "Undeclared non-terminal: ", u |