Help with Function String syntax for REXX

Help with Function String syntax for REXX

11
Basic UserBasic User
11

    Mar 25, 2010#1

    I just discovered the Function List feature. I would like to use it to create a list of the functions in my Rexx programs, but I can't figure out the /Function String syntax.

    First, does UE scan the code and find the function names or do I need to put a comment string by each function to identify it? I'd like to learn how to do it both ways.

    A Rexx function name is just a label, which is a valid name followed by a colon. There can be some keywords after the colon.

    Function1:
    Function2: Procedure

    Rexx comments start with "/*", end with "*/", and can span multiple lines. /* This is a comment */

    Can someone give me a correct /Function String statement and what to put in the code?

    I just want a list of the functions. I don't care too much about the calls.

    There are several Rexx wordfiles on the website. Some of them have /Function String statements. One of them is:

    /Function String = "%[a-zA-Z]*)"

    I tried putting that one in my wordfile and pushing F8. It caused some (but not all) of the calls to subroutines to show up in the Function List, but none of the actual functions.

    Thanks

    PS: I am running UE 14.20.1.1008 on WinXP.
    I am running UE 16.30.0.1000 on WinXP (all updates applied).

    6,681583
    Grand MasterGrand Master
    6,681583

      Mar 25, 2010#2

      Write into your wordfile for Rexx

      /Function String = "%[ ^t]++^([0-9a-z_]+^):"

      What does this UltraEdit regular expression mean?
      Well, you could answer that by yourself using the table at top of help page Regular Expressions (Legacy) which explains the special characters for the UltraEdit regexp engine, or you use the regular expression builder help (button with triangle arrow) in the Find/Replace dialog when UltraEdit regular expression option is enabled and you use UE v16.00. However, I explain it here:

      % means start of line. So the string to find must begin at start of a line.

      [ ^t]++ means find a space or tab zero or more times. In other words ignore spaces/tabs between start of line and function name. If preceding white-space characters are not allowed in Rexx because a function/procedure must start at column 1, remove this part of the expression from the function string you want to use.

      ^(...^) tags the string found by the expression inside ^( and ^). This is normally used in a replace to reference a part of the found string for being re-used also in the replace string. For the function string list it is used to tell UltraEdit which part of the found string should be displayed in the function list view.

      [0-9a-z_]+ means find one or more characters which is either a digit or a letter or an underscore. In your case this is the function name. If other characters are also allowed, put them into the square brackets. But be aware that the characters [ - ] and ^ must be escaped with a preceding ^ inside the square bracket to be interpreted as character without special regular expression meaning. Many languages require that the first character of a symbol name (function name) can be only a letter or an underscore. If that is true also for Rexx, [a-z_][0-9a-z_]++ would be better because now the first character of the function name string can be only a letter or an underscore.

      : has no special regular expression meaning. It just defines that after the function name a colon must follow to identify the found string as function string.
      Best regards from an UC/UE/UES for Windows user from Austria

      11
      Basic UserBasic User
      11

        Mar 25, 2010#3

        Thanks, Mofi. That got me started.

        /Function String = "%[ ^t]++^([0-9a-z_]+^):"

        is mostly working. The main problem involves multi-line comments. Most of my functions have a prolog that is a single comment block and most of them contain a syntax line:

        Code: Select all

        /*===================================
        
        Describe function...
        
           Syntax: MyFun(p1, p2, p3, ...)
        
        Other prolog information...
        ===================================*/
        Is there a way to get the Function String search to ignore comments? I have block comments indicated in the first line of the worfile:

        /L1"Rexx, Quercus" REXX_LANG Nocase NestBlockComments Block Comment On = /* Block Comment Off = */ File Extensions = REX REXX
        /Delimiters = '".,;:( )»+-/*|=\^&%<>

        » is used here as a placeholder for a tab character because tabs are displayed in HTML as a single space.

        I am running v14. I can upgrade to v16 if that will help.
        I am running UE 16.30.0.1000 on WinXP (all updates applied).

        6,681583
        Grand MasterGrand Master
        6,681583

          Mar 27, 2010#4

          UltraEdit (also v16.00) does not ignore comments when searching for function strings. Most simple would be to avoid Syntax: in comments. Running a replace in files on all *.rex* files could be used to change all Syntax: to !Syntax: or just Syntax to avoid being interpreted as function string.

          Another method is to use instead of the UltraEdit regular expression engine the more powerful Perl regular expression engine. Instead of line

          /Function String = "%[ ^t]++^([0-9a-z_]+^):"

          using

          /Regexp Type = Perl
          /Function String = "^[ \t]*([0-9a-z_]+)(?<!Syntax):"


          solves the problem with Syntax: because this Perl regular expression similar to the UltraEdit regexp looks back on the found function name string and ignores it when this string is Syntax in any case. (?<!Syntax) is responsible for this additional check on the string found by the preceding expression.

          Hint: Remove REXX_LANG from the first line of your wordfile. All possible language marker strings are listed on the help page with title Syntax Highlighting. Obviously invented REXX_LANG is not listed there, therefore not recognized by UltraEdit and so completely useless.
          Best regards from an UC/UE/UES for Windows user from Austria