Skip to content
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

Compose breaks down quite fast, two many recursions #18

Closed
seppeljordan opened this issue Aug 28, 2017 · 2 comments
Closed

Compose breaks down quite fast, two many recursions #18

seppeljordan opened this issue Aug 28, 2017 · 2 comments

Comments

@seppeljordan
Copy link

First of all: I really like parsec. It is solid work, but I encountered a problem. I really don't know what one can do about that in python but (at least on my machine) one can only compose ~200 parsers. I used python 3.6.2.

#!/usr/bin/env python

import parsec

n = 198

p = parsec.string('')
for x in range(0,n):
    p = p.compose(parsec.string('a'))
print(p.parse('a' * n))

gives

...
  File "/nix/store/fikb92d9was1qg3h4lwnay70i2ayzzd4-python3.6-parsec-3.3/lib/python3.6/site-packages/parsec/__init__.py", line 57, in success
    return Value(True, index, actual, None)
RecursionError: maximum recursion depth exceeded while calling a Python object
@sighingnow
Copy link
Owner

Thanks for your report. I will check it as soon as possible.

@sighingnow
Copy link
Owner

I think the only for your problem is to increase the system's recursion limit, using sys.setrecursionlimit. You even will encounter the same problem in a trivial hand-written recursive decent parser when you stack the same parser (call the same function recursively) so many times.

The default recursion depth limit is 1000 and it is too small for specific applications.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants