This isn't (or shouldn't be) my top priority right now but it sure would be nice if it was working.
I'm trying to make the prg_prog_search() function in prg.e find parameters for functions & procedures. At the same time, I want it to tag a standalone prg file as a procedure. I'm stuck on both of these.
Here's the dBase situation:
1) A standalone prg file contains code. It is read from top to bottom and any code not in a function or procedure is executed thus making the entire file a procedure. So I want to grab the file name and tag it.
2) When a procedure or function is found, if there are any parameters, those are on a subsequent line with the keyword PARAMETERS. Then they're listed (no data typing) and separated by commas.
3) As long all this is taking place, why not tag the func/proc with the containing file as the class?
func A
return
func B
parameters B1, B2
return x
func C
parameters C1, C2, C3
return
I started working with the existing prg_proc_search in prg.e by adding a second search for "parameters". Please look at my approach and make any comments or suggestions.
int prg_proc_search(_str &proc_name,boolean find_first)
{
int status=0;
if ( find_first ) {
if ( proc_name:=='') {
proc_name = _clex_identifier_re();
}
status=search('^([ \t]*(procedure|function|proc|func):b\c'proc_name'[ \t]*([(&]|$)|\c'proc_name'[ \t]*=[ \t])','@rhi');
} else {
status=repeat_search();
}
if ( status ) {
return(status);
}
_str line='';
get_line(line);
line=expand_tabs(line);
int p=pos('([ \t&(=]|$)',line,p_col,'r');
/* Parse out the name. Cursor is on first character of name. */
proc_name=substr(line,p_col,p-p_col);
/* Parse out the tag type. */
tag_type := "";
if ( p_col==1 ) tag_type = 'gvar';
if ( pos("^[ \\t]*proc", line, 1, "ri") > 0 ) tag_type = 'proc';
if ( pos("^[ \\t]*func", line, 1, "ri") > 0 ) tag_type = 'func';
// Adding code here to begin parameter search
_str args = "";
int iCount = 0;
status=search('^([ \t]*(para|parameters|parameter):b\c','@rhi');
if (!status){
get_line(line);
line=expand_tabs(line);
while (1==1) {
iCount += iCount;
args=args' 'substr(line,1,pos('s')-1);
if (pos('s')) {
break;
}
}
}
}
// compose the tag name
proc_name = tag_tree_compose_tag(proc_name, p_buf_name, tag_type, 0, args, "");
// end of added code
// proc_name = tag_tree_compose_tag(proc_name, "", tag_type);
return(0);
}