I have written a C++ parser in Scheme, with a Parsec-style parser combinator library. It can parse a large portion of C++ and I use it to do structural comparison between ASTs. I made some macros so that the parser combinators look like the grammar itself.
It's code is at: http://github.com/yinwang0/ydiff/blob/master/parse-cpp.ss A demo of the parse tree based comparison tool is at: http://www.cs.indiana.edu/~yw21/demos/d8-3404-d8-8424.html The bit of information I can tell you about parsing C++: - C++'s grammar is not that bad if you see the consistency in it. Parsing a major portion of C++ is not hard. I made the parser in two days. It can parse most of Google's V8 Javascript compiler code. I just need to fix some corner cases later. - It is better to delay semantic checks to a later stage. Don't put those into the parser. Parse a larger language first, and then walk the parse tree to eliminate semantically wrong programs. - Don't try translating from the formal grammar or parser generator files for C++. They contain years of bugs and patches and you will probably be confused looking at them. I wrote the parser just by looking at some example C++ programs. Cheers, Yin On Tue, Jan 24, 2012 at 5:06 AM, Christopher Brown <cm...@st-andrews.ac.uk> wrote: > Hi, > > 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? > > Many thanks, > Chris. > > > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe _______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe