Off subject

Jussi Jumppanen jussij at zeusedit.com
Tue Jan 6 22:52:17 PST 2009


Vincent Richomme Wrote:

> I would like to know if there are some parsers/scripts that could parse 
> some C/C++ language and that could insert printf in each function.

One option would be to use a regular expression within a search 
and replace.

Just as a simple test I came up regexp that does seems do the trick:

  Search string:
  (^[_a-z0-9]+[ &*\t]+[_a-z0-9 &*\t]*[_a-z0-9]+[ \t]*[(]+.*[^;]+)(\n{\n)


  Replace String:
  \0fprintf(stderr, ("\1")

Any regexp enabled text editor should be able to handle the search and
replace. It worked just fine in the Zeus IDE ;)

You could also use SED or AWK to do a batch mode regexp search and replace.

NOTE: The regexp was only tested for the function declaration that 
you posted, so it will almost certainly need to be tweaked for other 
variations of function definitions.




More information about the Digitalmars-d mailing list