Author Topic: Enhancing the dBase prg.e file for files & function parameters  (Read 1911 times)


  • Community Member
  • Posts: 5
  • Hero Points: 0
Enhancing the dBase prg.e file for files & function parameters
« on: February 03, 2012, 07:52:40 pm »
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?

Code: [Select]
func A

func B
    parameters B1, B2
    return x

func C
    parameters C1, C2, C3

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.

Code: [Select]
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 {
   if ( status ) {
   _str line='';
   int p=pos('([ \t&(=]|$)',line,p_col,'r');
   /* Parse out the name.  Cursor is on first character of name. */
   /* 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){
       while (1==1) {
           iCount += iCount;
           args=args' 'substr(line,1,pos('s')-1);
           if (pos('s')) {
   // 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);