User Defined Language functionlist parser only displays first function



  • This is my first attempt at any type of moderately complex regex. I was able to suss out a regex that worked perfectly in the search box. After hours of hacking away at the task I was able to get it to work in the FunctionList.xml…kind of. My problem now is that it only finds the first function in the program. Language at issue is HP TAL my parser is below:

          <parser id="tal_function" displayName="tal source" commentExpr="((!.*)/|(--.*?$))">
               <function  mainExpr="^.*(proc |subproc )"  displayMode="$functionName">
                         <functionName>
                                 <nameExpr expr="^.*(proc |subproc )\K[A-Z0-9._^+-]+"/>
                         </functionName>
              </function>
    

    </parser>

    all that shows is:

                            MYSERVER.TAL
                              |_ initialize^parameters


  • @L-Scherer Could you provide some TAL source examples for test/verification.



  • I’ll have to sanitize something and get it uploaded later today.



  • @MAPJe71 It’s kind of long-ish, but I wanted to mimic the complexity level and get all the examples in there. Essentially, there are procs, subprocs within them and a bunch of other stmts to include external content. The correct list of procs & subprocs should be 4 items: process^sqldata, just^for^compiling, get^mtext and format^date^time. I am currently dispaying only “get^mtext” (a subproc). No matter how I re-arrange procs, it always displays the 2nd-to-last in the function list. I’m sure that means something - just not sure what.

                TestPgm.tal
       ?sql wheneverlist
       ?source tal(directives)
       ?syntax
       name bbctestpgm;
       !%
       !-------------------------------------------------------------------------------
       !
       !            U P D A T E   A U D I T   T R A I L
       !            ============================================
       !
       !  CHG #    DATE    PERSON    DESCRIPTION
       !  -----  --------  ------  ----------------------------------------------------
       !   1234  11/15/17   LAS   Created.
       !-------------------------------------------------------------------------------
       !%
       ?source cmncode(some^data)
       
       ?source LUListst
       ?source LUmlitst(LUmlits)
       ?source bbcrtnst(common^literals)
       int donestuff;
       
       literal stat^edit^error = 0,
               max^errors      = 1,
               max^ids   = 1,
               idx^data^inc   = 0,
               idx^data^incd   = 1,
               idx^data^mrules   = 2;
       
       
       int proc process^sqldata(table^nm,response^code,use^bbcsqlxb) variable;
       
          int table^nm;
          string .response^code;
          int use^bbcsqlxb;
       
       begin
       
          return true;
       end;
       
       int proc just^for^compiling;
       begin
       
              int subproc get^mtext(code,stat^id,response^code) variable;
       
                 int msg^code,
                     stat^id;
                 string .response^code;
              
              begin
                 return true;
              end;
       end;   ! just^for^compiling
    
       ?section format^date^time
       ?page
       int proc format^date^time(tstamp,format^field);
       
          fixed tstamp;
          string .format^field;
       
       begin
          int dt[0:6];
       
          string month^name = 'p' := ["JanFebMarAprMayJunJulAugSepOctNovDec"];
          call interprettimestamp(tstamp,dt);
          call numout(format^field[0],dt[2],10,2);
          format^field[2] gets month^name[((dt[1] - 1) * 3)] for 3;
          call numout(format^field[5],dt[0],10,4);
          format^field[9] := " ";
          call numout(format^field[10],dt[3],10,2);
          format^field[12] := ":";
          call numout(format^field[13],dt[4],10,2);
          format^field[15] := ":";
          call numout(format^field[16],dt[5],10,2);
       
          return true;
       end;
    
       ?section procedure^end
       ?endif 15
       ?endif 15


  • @L-Scherer Please try the following parser:

    			<parser
    				displayName="TAL - Transaction Programming Language"
    				id         ="tal_function"
    				commentExpr="(?x)                                               # free-spacing (see `RegEx - Pattern Modifiers`)
    								(?m-s:(?:\x21|\x96{2}).*$)                      # Single Line Comment 1 and 2
    							|	(?:\x22[^\x22\r\n]*\x22)                        # String Literal - Double Quoted
    							"
    			>
    				<function
    					mainExpr="(?x)                                              # free-spacing (see `RegEx - Pattern Modifiers`)
    							(?ms)                                               # - ^, $ and dot match at line-breaks
    							^\h*                                                # optional leading white-space at start-of-line
    							(?:int|string)                                      # function type specifier
    							\s+
    							(?-i:proc|subproc)
    							\K                                                  # discard text matched so far
    							.*?                                                 # whatever, until...
    							;                                                   # ...end-of-function-header indicator
    						"
    				>
    					<functionName>
    						<nameExpr expr="[\w.^+-]+" />
    					</functionName>
    				</function>
    			</parser>
    


  • @MAPJe71 YOU ROCK! thank you. My entire project team thanks you.