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
Allow custom & union productions #233
Conversation
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.
Absolutely love it, thanks for doing this!
I have no major objections, it all looks quite reasonable to me. I think the only two issues are lack of documents on the new functions (not unexpected for a draft!), and the name "custom" is not specific enough.
Updated naming and documentation, and converted the fat tests to examples. Also added some smaller tests to the main tests suite just to make sure we're covering the new functionality. |
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.
Again, awesome, thanks for implementing this :)
// In most cases, using MaxLookahead will achieve the same results in practice, | ||
// but with a concrete upper bound to prevent pathological behavior in the parser. | ||
// Using infinite lookahead can be useful for testing, or for parsing especially | ||
// ambiguous grammars. Use at your own risk! |
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.
👍
// | ||
// If the first member matches A, and the second member matches A B, | ||
// and he source string is "AB", then the parser will only match A, and will not | ||
// try to parse the second member at all. |
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.
🙏
This is awesome, thanks for coordinating with me to get this merged so quickly! |
Thanks for doing the work :) PS. I updated the README, and made one minor change: renamed the |
Saw that - that's a fine change, naming is hard 😅 |
This PR will eventually provide an implementation of "custom" productions (a custom parsing function that can parse any arbitrary go value), and "union" productions, which parse a single value from a set of possible values into a container of a single interface type.
The details regarding API and ergonomics will need to be fleshed out further before this can be merged.