Skip to content

Commit

Permalink
followup #18711 grammar_nanny now reports unused non-terminals (#18746)
Browse files Browse the repository at this point in the history
* followup #18711 cleanup unused grammar rules

* make tools/grammar_nanny.nim report unused terminals

* revert removal of some grammar comments
  • Loading branch information
timotheecour authored Aug 26, 2021
1 parent c70e404 commit 98f7254
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion tools/grammar_nanny.nim
Original file line number Diff line number Diff line change
Expand Up @@ -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) =
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 98f7254

Please sign in to comment.