-
-
Notifications
You must be signed in to change notification settings - Fork 191
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
Proposal: Support grammar aliases. #22
Comments
Alternatively (or in addition to) just making it easier to go from a grammar string to something which implements Having a facility parallel to
|
That's not a bad idea at all. All it would take would be to add an extra method to the Parser. |
Though it's a bit inconvenient in that, as you say, you end up with a separate struct where you might only need a string or int or whatever. |
any updates? |
I haven't thought of a good API for this yet unfortunately. |
My usual pattern is to pull the field out into a struct. It's a bit uglier for the AST though. |
Is there any accepted approach that I could use to do what @shahms suggested in this comment? I'm trying to understand the most appropriate way to "jump back" into the normal grammar from within an implementation of |
In moderately complex grammars it's fairly common to see duplicate patterns emerge. For example, when matching a dot-separated identifier (eg.
foo.bar
) the pattern(Ident { "." Ident })
is used repeatedly. This can be handled by a Go type alias implementing theParseable
interface, but that is quite onerous.I propose adding support for grammar aliases. Here's an example creating and using an
Identifier
alias:The text was updated successfully, but these errors were encountered: