[plt-scheme] parsing/prettyprinting C

From: Robby Findler (robby at eecs.northwestern.edu)
Date: Thu Mar 5 11:09:07 EST 2009

On Thu, Mar 5, 2009 at 10:02 AM, Dave Herman <dherman at ccs.neu.edu> wrote:
>>> I see it uses yacc.  The 2nd edition K&R has a grammar acceptable by
>>> yacc in appendix A, section A13.  Are there any difficulties to
>>> making this a complete parser other than "just typing it in" ?
> P.S. To answer your question more directly: *yes*. Parsing C is extremely
> tricky, especially using a parser generator. Long story short: the parser
> has to maintain an environment and feed the information to the lexer, and
> the lexer has to make sure it doesn't look ahead to far before the
> environment has been appropriately updated. It's one of history's glorious
> botches (a remarkable proportion of which seems to belong to C). Of course,
> C++ would be orders of magnitude harder...

FWIW, if you really need to get serious about parsing C++, I think you
want SWIG.


Posted on the users mailing list.