Semantic patching

148

Just found a brief tutorial on a “semantic” patching tool for C. It’s called Coccinelle and it can recognize the semantics of the language (as in, “if X { …stuff… }”) and replace it with other things.

The example they give is partially replacing a function name. Typically, if you did a find/replace, then you could replace the incorrect thing (like part of a word in the comments). Coccinelle knows what an expression and what an identifier in C are so it can recognize and alter those specifically.

The nicest thing I read about it was this:

Coccinelle is one of those schizophrenic projects situated on the boundary between academic research and practical software development. 

It shows that the research of computing scientists shouldn’t be taken for granted as it can be applied (even though its applications may not be apparent at first).

 Thanks to the Code Junkies group on FriendFeed for pointing this out.