-
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
Using generics on grammar level #333
Comments
I believe this would be possible to add, but would make the signatures of the rule functions more confusing. Generics can't be attached to a grammar test1<'g>() for str {
pub rule foo<'r, R>() = ...
} -> mod test1 {
pub fn foo<'g, 'r, R>(&'input str) {...}
} If we allow type (and / or const) params on the grammar, they must be reordered in the function definition so all lifetimes come before types: grammar test1<'g, G>() for str {
pub rule foo<'r, R>() = ...
} -> mod test1 {
pub fn foo<'g, 'r, G, R>(&'input str) {...}
} I skipped that complexity because I didn't see a need for grammar type params, but I think it could be added. |
Would be nice to have, but if I would be the only user, you should maybe not do it... By the way, I could remove some of the boilerplate by using |
I am trying to make the parser result generic and reuse the same parser for different tasks. The following variant is working:
But there is much boiler plate, always mentioning the Factory argument. Especially calling other rules always needs mentioning the factory argument there, too.
I would have expected that the following variant works, but on a grammar only life time generics may be specified:
I tried also the following variant, but I was unable to specify the return type of the rules:
Is there a way to realize this?
Would it be possible to allow type generics on the grammar itself?
The text was updated successfully, but these errors were encountered: