Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
A
arpeggio-gm
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
backend
arpeggio-gm
Commits
f92ad9bd
Commit
f92ad9bd
authored
May 14, 2013
by
Igor Dejanovic
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix #1 Fixed bug with memoization cache not being cleared on input change.
parent
5a4f5e91
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
19 additions
and
1 deletion
+19
-1
__init__.py
arpeggio/__init__.py
+19
-1
No files found.
arpeggio/__init__.py
View file @
f92ad9bd
...
...
@@ -100,7 +100,24 @@ class ParsingExpression(object):
if
self
.
root
:
return
self
.
rule
else
:
return
id
(
self
)
return
id
(
self
)
def
clear_cache
(
self
,
processed
=
None
):
'''
Clears memoization cache. Should be called on input change.
Args:
processed (set): Set of processed nodes to prevent infinite loops.
'''
self
.
result_cache
=
{}
if
not
processed
:
processed
=
set
()
for
node
in
self
.
nodes
:
if
node
not
in
processed
:
processed
.
add
(
node
)
node
.
clear_cache
(
processed
)
def
_parse_intro
(
self
,
parser
):
logger
.
debug
(
"Parsing
%
s"
%
self
.
name
)
...
...
@@ -561,6 +578,7 @@ class Parser(object):
self
.
nm
=
None
# Last NoMatch exception
self
.
line_ends
=
[]
self
.
input
=
_input
self
.
parser_model
.
clear_cache
()
self
.
parse_tree
=
self
.
_parse
()
return
self
.
parse_tree
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment