• Login
Community
  • Login

User Defined Language functionlist parser only displays first function

Scheduled Pinned Locked Moved General Discussion
regexuserdefinedlangfunctionlist
6 Posts 2 Posters 2.3k Views
Loading More Posts
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • L
    L Scherer
    last edited by L Scherer Nov 15, 2017, 5:44 AM Nov 15, 2017, 5:41 AM

    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
    
    M 1 Reply Last reply Nov 15, 2017, 6:22 AM Reply Quote 0
    • M
      MAPJe71 @L Scherer
      last edited by Nov 15, 2017, 6:22 AM

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

      L 1 Reply Last reply Nov 15, 2017, 8:09 PM Reply Quote 0
      • L
        L Scherer
        last edited by Nov 15, 2017, 5:10 PM

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

        1 Reply Last reply Reply Quote 0
        • L
          L Scherer @MAPJe71
          last edited by L Scherer Nov 15, 2017, 8:12 PM Nov 15, 2017, 8:09 PM

          @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
          
          M 1 Reply Last reply Nov 15, 2017, 9:01 PM Reply Quote 0
          • M
            MAPJe71 @L Scherer
            last edited by Nov 15, 2017, 9:01 PM

            @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>
            
            L 1 Reply Last reply Nov 15, 2017, 10:38 PM Reply Quote 3
            • L
              L Scherer @MAPJe71
              last edited by Nov 15, 2017, 10:38 PM

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

              1 Reply Last reply Reply Quote 1
              4 out of 6
              • First post
                4/6
                Last post
              The Community of users of the Notepad++ text editor.
              Powered by NodeBB | Contributors