mainland / language-c-quote

Other
58 stars 30 forks source link

AntiQuote for Initializer #11

Closed leepike closed 11 years ago

leepike commented 11 years ago

Hi, would it be possible to have an antiquote specifier for the Initializer type? There doesn't seem to be one, and it would be quite useful.

mainland commented 11 years ago

Do you need to antiquote compound initializers? If not, you can use expression antiquotes. If you need support for antiquoting compound initializers, I would be happy to accept a patch.

leepike commented 11 years ago

Do you need to antiquote compound initializers?

In my case, yes. I'm generating (possibly) nested compound initializers.

I would be happy to accept a patch.

I got this working just generating the AST directly. I started trying to add the antiquote, but it wasn't obvious how to do so. I don't know if I'll get to it, so I'll close the issue. I'm guessing you can add it much quicker than I can, and I think it would be a nice addition, but it's your call whether it's worthwhile!

mainland commented 11 years ago

Let's leave it open :) I'll get to it, just not right away.

mainland commented 11 years ago

Please try master and let me know whether or not it solves this issue. If not, please provide an example of quasiquotation that you think should work but doesn't.

leepike commented 11 years ago

I did a quick test, and ran into the following:

Language/C/Syntax.hs:419:5: Warning: Pattern match(es) are non-exhaustive In an equation for `locOf': Patterns not matched: AntiInit AntiInits

and

Language/C/Pretty.hs:294:5: Warning: Pattern match(es) are non-exhaustive In an equation for `ppr': Patterns not matched: AntiInit AntiInits

The first one seemed to cause an error (non-exhaustive pattern) for me.

mainland commented 11 years ago

OK, please try again.

leepike commented 11 years ago

Yep, everything seems to work! Thanks again.