[Haskell-cafe] C++ Parser?
dagitj at gmail.com
Tue Jan 24 15:40:13 CET 2012
On Tue, Jan 24, 2012 at 2:06 AM, Christopher Brown
<cmb21 at st-andrews.ac.uk> wrote:
> I have stumbled across language-c on hackage and I was wondering if anyone is aware if there exists a full C++ parser written in Haskell?
I don't think one exists. I've heard it's quite difficult to get
template parsing working in an efficient manner.
My understanding is that "real" C++ compilers use the Edison Design
Group's parser: http://www.edg.com/index.php?location=c_frontend
For example, the Intel C++ compiler uses the edg front-end:
I thought even microsoft's compiler (which is surprisingly c++
compliant) uses it but I can't find details on google about that.
There is at least one open source project using it, rose, so it's not
unthinkingable to use it from Haskell: http://rosecompiler.org/
Rose has had working haskell bindings in the past but they have bit
rotted a bit. With rose you get support for much more than parsing
C++. You also get C and Fortran parsers as well as a fair bit of
static analysis. The downside is that rose is a big pile of C++
itself and is hard to compile on some platforms.
If you made a BSD3 licensed, fully functional, efficient C++ parser
that would be great. If you made it so that it preserves comments and
the input well enough to do source to source transformations
(unparsing) that would be very useful. I often wish I had rose
implemented in Haskell instead of C++.
More information about the Haskell-Cafe