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
Refactor: attempt to simplify the multiply operator. #547
base: master
Are you sure you want to change the base?
Refactor: attempt to simplify the multiply operator. #547
Conversation
Not ignoring you, I have some work to catch up on tomorrow and over the weekend. |
pyparsing/core.py
Outdated
return ret | ||
return And([self] * minElements) | ||
|
||
return And([self] * minElements) + (Opt(self) * (maxElements - minElements)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No hurry on code review; but from re-inspecting this myself, I'm beginning to wonder about this Opt
construction and the effect this could have on the parse output.
In particular: perhaps it's better to have a chain of nested Opt
nodes (recursive, instead of iterative as in this PR), because then matching an input against the parse tree can exit as soon as a single token doesn't match -- whereas the And[Opt(...), Opt(...), ...]
formulation here would be evaluated in full (I think?).
…er of nodes in the optional-tail case
…red-vs-optional parse output nodes
Ellipsis
operator (somewhat equivalent/similar toNone
values -- translating to: unbound).cc @ptmcg