Commit bcd332a8 authored by di68kap's avatar di68kap
Browse files

- merged: refactoring of memoization to avoid excessive memory usage

parent d9b26f0c
...@@ -266,7 +266,7 @@ def add_parser_guard(parser_func): ...@@ -266,7 +266,7 @@ def add_parser_guard(parser_func):
rest = grammar.document__[-rlen:] if rlen else '' rest = grammar.document__[-rlen:] if rlen else ''
# don't overwrite any positive match (i.e. node not None) in the cache # don't overwrite any positive match (i.e. node not None) in the cache
# and don't add empty entries for parsers returning from left recursive calls! # and don't add empty entries for parsers returning from left recursive calls!
# TODO: uncomment the following for full memoizazion # COMMENT THIS TO TURN FULL MEMOIZATION OFF
if node is None and location not in grammar.recursion_locations__: if node is None and location not in grammar.recursion_locations__:
# otherwise also cache None-results # otherwise also cache None-results
parser.visited[location] = None parser.visited[location] = None
...@@ -276,7 +276,7 @@ def add_parser_guard(parser_func): ...@@ -276,7 +276,7 @@ def add_parser_guard(parser_func):
if grammar.last_rb__loc__ > location: if grammar.last_rb__loc__ > location:
# in case of left recursion, the first recursive step that # in case of left recursion, the first recursive step that
# matches will store its result in the cache # matches will store its result in the cache
# TODO: remove if clause for full memoization # UNCOMMENT THIS TO TURN FULL MEMOIZATION OFF
# if location in grammar.recursion_locations__: # if location in grammar.recursion_locations__:
parser.visited[location] = node parser.visited[location] = node
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment