Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
badw-it
DHParser
Commits
a8c00788
Commit
a8c00788
authored
Jul 12, 2021
by
di68kap
Browse files
slow down for memoization with FixedEBNF fixed
parent
65dada02
Changes
1
Hide whitespace changes
Inline
Side-by-side
DHParser/parse.py
View file @
a8c00788
...
@@ -3930,7 +3930,7 @@ class Forward(UnaryParser):
...
@@ -3930,7 +3930,7 @@ class Forward(UnaryParser):
result
=
self
.
parser
(
text
)
result
=
self
.
parser
(
text
)
self
.
recursion_counter
[
location
]
=
depth
# allow moving back and forth
self
.
recursion_counter
[
location
]
=
depth
# allow moving back and forth
else
:
else
:
recurs
ion_state
=
grammar
.
suspend_memoization__
memoizat
ion_state
=
grammar
.
suspend_memoization__
self
.
recursion_counter
[
location
]
=
0
# fail on the first recursion
self
.
recursion_counter
[
location
]
=
0
# fail on the first recursion
grammar
.
suspend_memoization__
=
False
grammar
.
suspend_memoization__
=
False
result
=
self
.
parser
(
text
)
result
=
self
.
parser
(
text
)
...
@@ -3967,9 +3967,9 @@ class Forward(UnaryParser):
...
@@ -3967,9 +3967,9 @@ class Forward(UnaryParser):
break
break
result
=
next_result
result
=
next_result
depth
+=
1
depth
+=
1
grammar
.
suspend_memoization__
=
recursion_state
\
#
grammar.suspend_memoization__ = recursion_state \
or
location
<=
(
grammar
.
last_rb__loc__
+
int
(
text
.
_len
==
result
[
1
].
_len
))
#
or location <= (grammar.last_rb__loc__ + int(text._len == result[1]._len))
#
grammar.suspend_memoization__ =
recurs
ion_state
grammar
.
suspend_memoization__
=
memoizat
ion_state
if
not
grammar
.
suspend_memoization__
:
if
not
grammar
.
suspend_memoization__
:
visited
[
location
]
=
result
visited
[
location
]
=
result
return
result
return
result
...
...
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