Open lpw25 opened 10 years ago
Actually, thinking about it I only need the token and output to be parametrised, not the buffer. I've adjusted the description above accordingly.
In an ideal world, yes it would be possible to handle parsers with type parameters.
The backends are undergoing major changes as parts of this fork are being considered for upstreaming. At the moment we are trying to make things simpler. Introducing parametric polymorphism is likely not going to help.
So while possible, it is not going to happen anytime soon. Is it really a problem to go through a functor application?
So while possible, it is not going to happen anytime soon. Is it really a problem to go through a functor application?
Not really, it just annoyed me a bit and I could see how a solution would work so I thought I'd write it down somewhere where it might eventually get acted upon.
Since you're experimenting with Menhir, and would probably know how feasible this feature is, I thought I would suggest it here.
I would like to parametrise my parsers by type parameters. Essentially, I would like the resulting parse functions to look like:
I can get something like this by using:
and using a local module to apply the parser, but it is quite ugly.
I think something like the following would work as a definition:
The implementation would be to parametrise the token type by the type parameter, using the name
'param
wherever the token type appears in the rule definitions. As long as the definitions of the rule code was careful not to capture the type parameter name I think all the definitions would be appropriately typed.