On Fri, 17 Dec 2010, Michael T wrote:

> Jani Monoses <jani <at> ubuntu.com> writes:
> > I heard that writing a complete C++ parser is very hard, but I was 
> > wondering if Coccinelle could be made to work on C++ codebases
> > only handling the C subset of the language and ignoring what it does not 
> > treat.
> 
> Hello,
> 
> I am chipping in here a bit late, but I have just run up against this as well,
> and was wondering if a little adjustment of the current rules might not go a
> long way.  I have never looked at the internals of Coccinelle, so forgive me 
> if
> what I am writing is nonsense, but when I try to parse C++ code with debug
> output enabled I see things like the following:
> 
> BAD:!!!!! for (object::subobject it = myobj.method();
> 
> BAD:!!!!! object::method(type param)
> 
> BAD:!!!!! extern "C" {
> 
> and this one is C, not C++, but seems to confuse Coccinelle too:
> 
> BAD:!!!!! MACRO(type) function(type param)
> 
> Surely it would be possible to make Coccinelle sufficiently aware of these
> syntactic forms that it can parse the files and get the correct flow in ninety
> percent of cases.  Of course, templates would add additional complication (I
> would have to run spatch over something using templates, and worse, something
> defining them to see what it says about them).

Allowing :: in identifier names is certainly possible.  We could even 
allow <>.  But aren't there class declarations in C++?  All code inside 
them would be completely ignored.

julia
_______________________________________________
Cocci mailing list
[email protected]
http://lists.diku.dk/mailman/listinfo/cocci
(Web access from inside DIKUs LAN only)

Reply via email to