> Hello,
>
> "epanda" <callingelvis@hotmail.fr> a écrit :
>
>> if (condition1
>> && condition 3 )
>> return
>
> Wouldn't a ")[[:blank_or_comment:]]return\>" be enough ?
> Of course it would match nonsense code like "foo(42) return;" or
> "while (cond) return", but does it really matter?
Yes, as skipping nested parens (within the condition) with a regexp is
not possible, it makes sense to not even try it.
> In GotoImpl [1], I've implemented the [[:blank_or_comment:]] this way:
>    \(\_s\|/\*.\{-}\*/\|//.*$\)*
Epanda, for a C-comment, the pattern
    \/\*\_.\{-}\*\/
is simpler than what I gave you.
Note on escaping: in a pattern for functions like substitute() there is
no need to escape '/'.  But for a :s/pat/repl/flags-command, '/' needs
to be escaped (except in a collection?).
> (Hum ... oddly I did not use \_. instead of . in the second
> expression... I guess the pattern should be modified to use the \@
> multi-items)
'\@' multi item?
> [1] http://code.google.com/p/lh-vim/wiki/lhCpp and more precisely:
> http://code.google.com/p/lh-vim/source/browse/cpp/trunk/autoload/lh/cpp/AnalysisLib_Function.vim#526
Result:
    /)\%(\_s\|\/\*.\{-}\*\/\|\/\/.*$\)*return\>
Minor difference: it will match wrong code like
)
/* */ */
    return
Alternative:
    /)\_s*\%(\%(\/\*.\{-}\*\/\|\/\/.*$\)\_s*\)*return\>
This way it's easier to restrict the number of comments:
    /)\_s*\%(\%(\/\*.\{-}\*\/\|\/\/.*$\)\_s*\)\{,5}return\>
-- 
Andy
-- 
You received this message from the "vim_use" maillist.
For more information, visit http://www.vim.org/maillist.php
No comments:
Post a Comment