
I'd like to parse some C headers for a toy project. It seems like c2hs probably has the functionality I want, but it's not packaged up as a library. So two questions: Is there an alternative C-parsing library? Has anyone looked into librarifying c2hs's parser?

On Sun, Feb 24, 2008 at 4:08 PM, Evan Martin
So two questions: Is there an alternative C-parsing library?
You could use gcc-xml[1] with one of the various XML parsers. [1] http://www.gccxml.org/HTML/Index.html -- Adam Langley agl@imperialviolet.org http://www.imperialviolet.org

Evan Martin wrote:
So two questions: Is there an alternative C-parsing library? Has anyone looked into librarifying c2hs's parser?
I have split c2hs into three packages once, the remains of CTK that it uses, the C parser and pretty printer, and c2hs itself. (I also tried to give the modules more sensible hierarchical names - CTK would reside in CTK.* and the C stuff in Language.C.*) However, I found the result fairly hard to use, partly due to CTK and partly because some aspects of the C ADT that c2hs uses appears to be designed for c2hs, not as a general purpose C AST. There's also a lot of room for adding new utility functions for inspecting the AST. I'm reluctant to publish the split packages because they really don't add much value over c2hs and I don't want to create a c2hs fork, or duplicate effort that goes into improving that code. Bertram

On Mon, 2008-02-25 at 03:06 +0100, Bertram Felgenhauer wrote:
Evan Martin wrote:
So two questions: Is there an alternative C-parsing library? Has anyone looked into librarifying c2hs's parser?
I have split c2hs into three packages once, the remains of CTK that it uses, the C parser and pretty printer, and c2hs itself. (I also tried to give the modules more sensible hierarchical names - CTK would reside in CTK.* and the C stuff in Language.C.*)
However, I found the result fairly hard to use, partly due to CTK and partly because some aspects of the C ADT that c2hs uses appears to be designed for c2hs, not as a general purpose C AST. There's also a lot of room for adding new utility functions for inspecting the AST.
I'm very happy to see patches to modify c2hs to use a more general C AST.
I'm reluctant to publish the split packages because they really don't add much value over c2hs and I don't want to create a c2hs fork, or duplicate effort that goes into improving that code.
I think it'd be ok to move the C parser into a library and see how it's api develops as people make use of it. We can port c2hs to use that library at a later date. Duncan
participants (4)
-
Adam Langley
-
Bertram Felgenhauer
-
Duncan Coutts
-
Evan Martin