Skip to content

Commit

Permalink
Added check for unused rules in grammar.
Browse files Browse the repository at this point in the history
  • Loading branch information
bl0b committed Dec 27, 2011
1 parent 5dd5ecc commit db2fab3
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions jupyLR/parser.py
Expand Up @@ -212,3 +212,9 @@ def dump_sets(self):
for i, lrset in enumerate(self.LR0):
print self.itemsetstr(lrset, i)
print

@property
def unused_rules(self):
unused = lambda i: reduce(lambda a, b: a and i not in b, a.LR0, True)
unused_rule_indices = set(x[0] for x in filter(check, a.I))
return set(a.R[x][0] for x in unused_rule_indices)

0 comments on commit db2fab3

Please sign in to comment.