Skip to content

Commit

Permalink
Clear memoize() caches before parsing
Browse files Browse the repository at this point in the history
  • Loading branch information
vlasovskikh committed May 29, 2011
1 parent 03a5b77 commit 79e1641
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/funcparserlib/parser.py
Expand Up @@ -107,6 +107,8 @@ def parse(self, tokens):
ebnf_rule(q),
u', '.join(unicode(x) for x in opts)))

clear_caches(self)

try:
(tree, _) = self(tokens, State())
return tree
Expand Down Expand Up @@ -383,6 +385,12 @@ def ebnf(self):
return str(self.p)


def clear_caches(p):
for x in all_parsers(p):
if isinstance(x, _Memoize):
x.cache = {}


class State(object):
'''A parsing state that is maintained basically for error reporting.
Expand Down

0 comments on commit 79e1641

Please sign in to comment.