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

.parse doesn't support arbitrary iterables #78

Open
Kodiologist opened this issue Jun 28, 2023 · 0 comments
Open

.parse doesn't support arbitrary iterables #78

Kodiologist opened this issue Jun 28, 2023 · 0 comments

Comments

@Kodiologist
Copy link

>>> from funcparserlib.parser import a, many
>>> many(a("x")).parse("xxxxxxx")
['x', 'x', 'x', 'x', 'x', 'x', 'x']
>>> many(a("x")).parse(x for x in "xxxxxxx")
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/hippo/Scratch/Python-venv/lib/python3.11/site-packages/funcparserlib/parser.py", line 221, in parse
    (tree, _) = self.run(tokens, State(0, 0, None))
                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/hippo/Scratch/Python-venv/lib/python3.11/site-packages/funcparserlib/parser.py", line 569, in _many
    (v, s) = p.run(tokens, s)
             ^^^^^^^^^^^^^^^^
  File "/home/hippo/Scratch/Python-venv/lib/python3.11/site-packages/funcparserlib/parser.py", line 614, in _some
    if s.pos >= len(tokens):
                ^^^^^^^^^^^
TypeError: object of type 'generator' has no len()

It seems likely one would want to parse an iterable stream of tokens at times.

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

1 participant