Page 1 of 1

find next function

Posted: Fri Mar 15, 2013 6:38 pm
by JackR
Hi Jussi,

The feature to find the next function ( control-down_arrow or control-up_arrow ) is no longer working correctly in C++ files. I'm not sure when it stopped working. It stops at many lines that aren't functions. I believe the problem is that it is stopping at any line which contains a double colon (::). I have a lot on lines in my code that have this structure

class_name::enum_constant_declared_in_class

This needs to be distinguished from a function which looks like this:

void class_name :: function_name( parameters)

Hopefully, this can be fixed because I use to love this feature.

Thanks!
Jack

Posted: Sat Mar 16, 2013 3:13 am
by jussij
In the general section of the document type there is a function regexp that defines what is a function.

All you need to do is create a regexp that defines the lines that are functions.

For example this regexp

Code: Select all

[a-zA-Z0-9_]+::[a-zA-Z0-9_]+\(
will identify lines of code like the following as functions

Code: Select all

void class_name::function_name( parameters)
To add more definitions just use the regep or construct:

Code: Select all

([a-zA-Z0-9_]+::[a-zA-Z0-9_]+\()|(some other regexp search)
Cheers Jussi

Posted: Mon Mar 18, 2013 3:08 pm
by JackR
Hi Jussi,

Thanks for the feedback, I didn't realize I could configure this. But unfortunately, this just changes the problem. I didn't do a complete job of asking my question. I want to find function definitions for C and C++ of the form

return_type class_name :: function name ( parameters )
return_type class_name :: function name ( parameters,
return_type function name ( parameters )
return_type function name ( parameters

and not find lines which call functions or have similar structures

function( parameter );
function (
if ( result > sizeof(tag) )
class_name::enum_variable

I'm not very good at regular expressions, but I don't see any way to find just the functions.

Thanks!
Jack

Posted: Mon Mar 18, 2013 10:23 pm
by jussij
Hi Jack,

Try this one:

Code: Select all

^[_a-z0-9]+[ &*\t]+[_a-z0-9 :\t]*[_a-z0-9]+[ \t]*[(]+.*
To test my regular expressions I just use the find dialog in Zeus itself.
I'm not very good at regular expressions
In the expression given the ^ represents the start of line, the [...] represent a set of charaters, the + means it must be found, the * means optional and the .* means any characters.

Cheers Jussi

Posted: Tue Mar 19, 2013 6:57 pm
by JackR
Hi Jussi,

Thanks for the help. Your solution doesn't fix the problem 100%, but it is so much better and very usable now. It still stops a prototypes of functions which is a very minor issue.

Thanks again!
Jack

Posted: Wed Mar 20, 2013 2:18 am
by jussij
It still stops a prototypes of functions which is a very minor issue.
Just change the regexp to be this:

Code: Select all

^[_a-z0-9]+[ &*\t]+[_a-z0-9 :\t]*[_a-z0-9]+[ \t]*[(]+.*[^;]+$
The [^;]+$ addition says ignore any line that ends in a semi-colon.

In fact since functions can be written using upper case letters the regexp should be this:

Code: Select all

^[_a-zA-Z0-9]+[ &*\t]+[_a-zA-Z0-9 :\t]*[_a-zA-Z0-9]+[ \t]*[(]+.*[^;]+$
Cheers Jussi

Posted: Mon Mar 25, 2013 2:27 pm
by JackR
Hi Jussi,

Thanks so much for your help. You may want to consider making this last reg ex string you provided me the C/C++ default when none is provided.

Thanks Again!
Jack