Language.C

Benedikt Huber benedikt.huber at gmail.com
Thu May 12 11:25:56 BST 2011


On 12.05.2011, at 10:33, Alexander Bernauer wrote:
> Hi Warren,
>
> On Wed, May 11, 2011 at 04:34:36PM -0700, Warren Harris wrote:
>> That sounds like what I was looking for. I noticed that 'show' will  
>> either
>> print things as C syntax (e.g. a CInteger will print out as "123"  
>> rather
>> than "CInteger 123"), or using a syntax for readability (e.g.  
>> identifiers
>> print as `foo' rather than as "Ident \"foo\" ..."). But maybe  
>> DumpAst.hs
>> will do the right thing.
>
> DumpAst ist just a simple tool to figure out match patterns. It
> completely relies on the language-c library and provides no magic on  
> its
> own - maybe except for restraining the dump of NodeInfo values.
>
> As Benedikt mentioned, in the current development version, the Show
> instances of the AST types return valid Haskell syntax. But as you
> noticed, there are some abbreviations.
>
> As far as I understood your concern you really need to have the  
> Haskell
> representation of the Language-C AST that represents the quasi-quoted
> code, right?
>
> In that case we should go on and change the remaining Show  
> instances. As
> far as I can see this involves Ident and all constants. Anything else?
>
> I think, this would be a simple patch. Shall we?
>
> Or is there a good use for the abbreviated Show instances, too? IMO in
> these cases the AST could always be pretty printed, couldn't it?
If I understand correctly, the property we are now aiming at is roughly
   (read CTranslUnit . show . parse HsExpr . show) ~ id
for all AST nodes x.
Although I have to admit that I was not always in favour of such  
'canonical'
Show instances, I'm now convinced that's the right thing to do for  
language-c.
And as we have pretty printing anyway, we should go on and change the  
remaining
Show instances.

cheers, benedikt

>
> Greetings
>
> Alex
> _______________________________________________
> Language-c mailing list
> Language-c at projects.haskell.org
> http://projects.haskell.org/cgi-bin/mailman/listinfo/language-c




More information about the Language-c mailing list