Friday, November 27, 2009

Re: Detect when a return follow an if instruction without bracket

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?

In GotoImpl [1], I've implemented the [[:blank_or_comment:]] this way:
\(\_s\|/\*.\{-}\*/\|//.*$\)*
(Hum ... oddly I did not use \_. instead of . in the second expression... I guess the pattern should be modified to use the \@ multi-items)

[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

HTH,

--
Luc Hermitte
http://lh-vim.googlecode.com/
http://hermitte.free.fr/vim/

--
You received this message from the "vim_use" maillist.
For more information, visit http://www.vim.org/maillist.php

No comments:

Post a Comment