[plt-scheme] parsing/prettyprinting C

From: Dave Herman (dherman at ccs.neu.edu)
Date: Mon Mar 9 15:33:01 EDT 2009

FYI, version 0.2 is now available in PLaneT as (planet dherman/c:2:0).

http://planet.plt-scheme.org/package-source/dherman/c.plt/2/0/planet-docs/c/index.html

Dave

Dave Herman 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...
> 
> Dave
> _________________________________________________
>  For list-related administrative tasks:
>  http://list.cs.brown.edu/mailman/listinfo/plt-scheme



Posted on the users mailing list.