-
Notifications
You must be signed in to change notification settings - Fork 60
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
unbounded recursion in LexerStream.next() #52
Comments
I'm not sure I understand why this causes unbound recursion :-( |
The relevant code is: def next(self):
if self.idx >= len(self.s):
raise StopIteration
for rule in self.lexer.ignore_rules:
match = rule.matches(self.s, self.idx)
if match:
self._update_pos(match)
return self.next()
... CPython doesn't do tail recursion elimination, so if there's N consecutive ignorable tokens in the input, N stack frames will be consumed. def next(self):
while True:
if self.idx >= len(self.s):
raise StopIteration
for rule in self.lexer.ignore_rules:
match = rule.matches(self.s, self.idx)
if match:
self._update_pos(match)
break
else:
break
... (untested, sorry!) |
Ugh, right, I forgot how I implemented ignores. Will try to fix this On Wed, Feb 24, 2016 at 9:39 AM, Jakub Wilk notifications@github.com
"I disapprove of what you say, but I will defend to the death your right to |
Fixed #52 -- don't die with a recursion error if lots of tokens are s…
Closes hylang#1313. Ref. alex/rply#52, alex/rply#71.
This test program
makes the Python interpreter sad:
The text was updated successfully, but these errors were encountered: