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
This commit is contained in:
Timothee Cour 2021-08-25 22:04:18 -07:00 • committed by GitHub
commit 98f7254fb2
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -4,7 +4,7 @@
import std / [strutils, sets] import std / [strutils, sets]
import ".." / compiler / [ import ".." / compiler / [
llstream, ast, lexer, options, msgs, idents, llstream, lexer, options, msgs, idents,
lineinfos, pathutils] lineinfos, pathutils]
proc checkGrammarFileImpl(cache: IdentCache, config: ConfigRef) = proc checkGrammarFileImpl(cache: IdentCache, config: ConfigRef) =
@ -35,6 +35,10 @@ proc checkGrammarFileImpl(cache: IdentCache, config: ConfigRef) =
usedSyms.incl word usedSyms.incl word
else: else:
rawGetTok(L, tok) rawGetTok(L, tok)
for u in declaredSyms:
if u notin usedSyms:
echo "Unused non-terminal: ", u
for u in usedSyms: for u in usedSyms:
if u notin declaredSyms: if u notin declaredSyms:
echo "Undeclared non-terminal: ", u echo "Undeclared non-terminal: ", u