-
Notifications
You must be signed in to change notification settings - Fork 418
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
Wrong backtracking algorithm #181
Comments
This is not how PEG grammars work. PEG grammars are a short hand for recursive descent parsers, which do not backtrack in the same way that regular expressions do. This is intentional. |
Sorry, name PEG misleading me (and switch BNF alternative "|" to PEG ordered choice "/") This is common for "parsing strings" grammars unlike BNF "constructing string" (context free). |
As explained above, this is not a bug. Closing. |
Hello! I'm find that expression like:
start = (term? term)? term
term = [0-9]
don't correct work with nested optional terminals. It cannot recognize two digit string (11). One and three digit is ok.
Analogous regular expression work fine:
([0-9]?[0-9])?[0-9]
I think you use "possessive quantifiers" backtracking algorithm for optimize performance, like:
([0-9]?+[0-9])?+[0-9]
but in common case it is not correct.
How can I switch to classic "greedy"?
Thank you very much for your work!
The text was updated successfully, but these errors were encountered: