Dienstag, 1. Juli 2008

Last week on Language.C (1)

This week I tried to find a better representation for declarators, which was screwed up in the old AST from c2hs. I had another look at the CIL API, which is really nice, but quite different from the rather syntax oriented AST representation I'm working with. While CIL datatypes represent the semantics of a C file, Language.C's AST datatypes rather represent the syntax. I hope that this won't be a disadvantage, and that we can use view abstractions to make using the library as easy for the user as CIL is.
The documentation of the AST is now usable, and includes some examples for the trickier parts (declarators, intializers).
Due to a bug in ghc I switched to generating Data.Generic  instances offline using Data.Derive
I completed the implementation, which used to only derive gfoldl (but not toConstr etc.), and now it seems to be working nice. Currently, the Data instances are used for testing only, but I hope to play with Strafunsky a little bit next week.
I've also abstracted the notion of an InputStream - one can use either ByteString or String as input now (chosen at compile time). I didn't optimize the ByteString stuff, and therefore the performance improvement is rather small. But the interface abstraction is nice anyway. 
Finally, I didn't complete porting the declaration analysis code from c2hs (oh my), but at least some parts of the framework (traversal monad) is finished. This should be finished in a few days though, I hope.

Keine Kommentare: