Language.C deriving (Show)

Joe Thornber joe.thornber at gmail.com
Sun Feb 15 09:54:21 EST 2009


2009/2/15 Benedikt Huber <benedikt.huber at gmail.com>:
>
> On 13.02.2009, at 19:58, John Van Enk wrote:
>
>> Benedikt,
>>
>> Have you considered adding a derived show clause to Language.C? I

I think a pretty printer for the AST itself would indeed be useful.
There have been a couple of occasions where I've been no idea why my
generic query doesn't work - obviously the parsed AST wasn't what I
expected, but I didn't really have a way of finding out what it
actually was.

I have tried the examples/sourceview program, but it provides limited
information so far.

>> One other thing, is there a plan in the future to convert your data
>> structure to using the record syntax?
> This is certainly something to think about, though I'd say e.g.
> expressions don't benefit as much from record syntax as
> declarations do. Do you suggest to use records for all AST types, or
> just some of them (as ghc does) ?

For most of the little uses I have for language-c quasi-quoting
support would make a big difference.  It has obvious applications for
code generation, but I also think that a quasi-quoted query language
would remove the need for most people to handle the AST directly.  For
example I may be interested in finding out the places in a C codebase
where someone assigns a value within an if-condition.  It would be
much nicer to be able to say something like:

  runQuery $ parseQuery [|c-query| if (:x = :y)|]

than have to grapple with the AST directly and write a generic query.

- Joe



More information about the Language-c mailing list