Googles appar
Huvudmeny

Post a Comment On: cbloom rants

"06-13-12 - MSVC RegExp Find-Replace"

5 Comments -

1 – 5 of 5
Anonymous Anonymous said...

Doesn't work if "blah" contains commas, e.g. if blah is another function call with multiple parameters.

(and in fact provably unparseable with regular expressions)

Doesn't matter much if you avoid that sort of style, though, so you may have never run into it. But I think it's pretty perilous in general.

June 14, 2012 at 1:40 AM

Anonymous Anonymous said...

And yeah, you want a find/replace engine embedded in a programming IDE to be able to understand the syntax of the language, and e.g. (optionally) recognize token boundaries.

Knowing about types is a lot harder, unfortunately:

- it requires a full parse (and a full parse is a super PITA in C++ compared to C),

- to do it right you need a more sophisticated c-preprocessor than the one in the compiler (you need one that keeps a tighter correlation between input tokens and output tokens, since the types come from output tokens but the strings you're replacing are input tokens)

- #ifdefs fuck you regardless of whether you preprocessor macro expansion or not

June 14, 2012 at 1:45 AM

Blogger johnb said...

Most regex engines provide facilities for word-boundary matching (or more general boundary conditions).

MSDN says that it wants '<' to match the beginning of a word, '>' to match the end of a word.

http://msdn.microsoft.com/en-us/library/2k3te2cs(v=vs.80).aspx

June 14, 2012 at 8:30 AM

Anonymous Anonymous said...

For renaming enum values, I've found Visual Assist to do a fair job, and it will even (try to) find references to them in comments. It's not impossible to confuse it, but it presents a nice summary of what it's going to do before it does it, so you can usually catch any problems before they occur. Serious hidden mistakes seem to be no more likely than if you did the change yourself.

June 14, 2012 at 8:38 AM

Blogger cbloom said...

Another one :

I should be able to do "insert default args" using the compiler to do text-pasting.

If you ever need to change or remove a default arg, you should be able to automatically paste the previous value into all places in the code that were using it.

June 19, 2012 at 1:27 PM

You can use some HTML tags, such as <b>, <i>, <a>

This blog does not allow anonymous comments.

Comment moderation has been enabled. All comments must be approved by the blog author.

You will be asked to sign in after submitting your comment.