-
Notifications
You must be signed in to change notification settings - Fork 55
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
Lookahead not working in OrderedChoice #96
Comments
|
For comparison, Ohm says lookahead is usually used as part of a sequence, but it is not mandatory. Indeed, the string
|
Thanks for the input. I'll investigate. BTW, do you have any real-world example where you would like to use predicates outside of a sequence? I just can't figure out where it would be useful. |
We had a grammar where this occurred. |
This change is backward incompatible. It removes a sort of "soft failure" used by repetition (if inner expression returns None) to avoid infinite looping on nested non-consuming matches. This has lead to some subtle problems and inconsistencies which confused users. See for example: #96 But, OTOT, it is now possible to create a grammar which will loop endlessly by having a possible non-consuming (e.g. regex which can match empty, Option, ZeroOrMore...) to be nested inside repetitions (ZeroOrMore, OneOrMore). The parser will loop as the inner expression will succeed without consuming input bringing the parser in the same state over and over.
Fixed on the |
If a branch in ordered choice has a potentially non-consuming successful alternative (Optional, ZeroOrMore, Not, And), it will succeed if alternative succeeds and thus will not try further choices.
Because
And
andOr
return nothing when parsed, they are ignored byOrderedChoice
.The text was updated successfully, but these errors were encountered: