Permalink
Browse files

Added check for unused rules in grammar.

  • Loading branch information...
bl0b committed Dec 27, 2011
1 parent 5dd5ecc commit db2fab399dc7837b56ef2599aa839533c401b0e1
Showing with 6 additions and 0 deletions.
  1. +6 −0 jupyLR/parser.py
View
@@ -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.