-
Notifications
You must be signed in to change notification settings - Fork 106
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
Add left recursion support for rules without args #266
Add left recursion support for rules without args #266
Conversation
55d0e8c
to
68198a7
Compare
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.
Nice!
I'm thinking this should be a different attribute, maybe #[cache_left_rec]
or #[cache(recursive)]
, rather than changing the behavior of all #[cache]
. The overhead of this for a rule that does not use recursion is that it will parse the rule a second time, and always find the same end position and exit the loop. I'm not sure that double-parsing is acceptable, given than #[cache]
is most likely applied to rules that have nontrivial parse time when you want to avoid repeatedly parsing them.
bb79ba4
to
f3fe977
Compare
Yes, completely agree, making all |
I'm not sure the error message is the place to go into a ton of detail about the tradeoffs, but there should probably be a section in the documentation describing the different cache modes, and maybe a comparison of the approaches for parsing nested expressions. I'm happy to write this if you'd rather just get this merged. |
f3fe977
to
447dd0b
Compare
Yes, if we can merge this one, and add the doc in a different PR that would be great. Let me give it a go, I'll put up a PR tomorrow. |
Adding a straightforward implementation of the packrat memoization to support left recursion in rules without args.
These changes would resolve #262.
Any feedback is welcome, let me know what you think!