Community
    • Login

    FunctionList Confused

    Scheduled Pinned Locked Moved Help wanted · · · – – – · · ·
    82 Posts 5 Posters 20.4k 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.
    • Lycan ThropeL
      Lycan Thrope @Lycan Thrope
      last edited by

      @lycan-thrope
      Not sure if I made it worse or not. ::sigh::
      The one change I did do, which was changed the funcNameExpr that’s supposed to find just the functions, to nameExpr seem to change my test set, to lose the Function/Procedure lead names, but they still show, but on the positive side, the set procedure to in my testing program was removed and from being shown, which is a desired result. So, I may be on to something, but those words in the comments Function <name> the <name> part is still showing up, so, I guess I’ll have to play.

      In the code above, I noticed that my pasted code had different highlighing than it does in NPP, which triggered my finding that I had misnamed the nameExpr. Strange that it didn’t show up on the editor like it does here.

      Lee

      Lycan ThropeL 1 Reply Last reply Reply Quote 0
      • Lycan ThropeL
        Lycan Thrope @Lycan Thrope
        last edited by

        @lycan-thrope
        Testing to see if my change fixed the highlight difference in here:

        <?xml version="1.0" encoding="UTF-8" ?>
        <!-- ==========================================================================\
        |
        |   To learn how to make your own language parser, please check the following
        |   link:
        |       https://npp-user-manual.org/docs/function-list/
        |
        \=========================================================================== -->
        <NotepadPlus>
        	<functionList>
        		<!-- ========================================================= [ dBASEPlus ] -->
        		<parser
        			displayName="dBASEPlus"
        			id         ="dbaseplus"
        			commentExpr="(?s:/\*.*?\*/)|(?m-s://.*?$)|(?m-s:\&\&.*?$)"
        		>
        			<classRange
        				mainExpr="(?x-i)                        #  Free-spacing mode and inline comments + search sensitive to case
        
        						  ^\h*                          #  Optional leading whitespace chars
        						  class                         #  'class' keyword
        						  \h?                           #  Optional whitepace char
        						  \w+                           #  Class name
        
        														#  Following the class name there is the option of parameters, and if so the first entry inside the parens is required, whether there is other 
        														#  parameters or not, once the parens go up, the first is required. ie: class FrameCtrl(frameObj)
        
        						  (                             #  Beginning of the optional parameter(s) part  ( Group 1 )
        							\h? \(                      #    Opening parenthesis
        							\w+                         #    First and required parameter
        							( , \h? \w+)*               #    Following optional/additional parameters
        							\)                          #    Closing  parenthesis
        						  )?                            #  End of the optional parameter(s) part
        
        														#  For the rest of the class declaration, after the class name, all other options are part of one big optional set, that follows 'of'
        														#  and can be populated by one of several options.
        
        						  (?:                           #  Beginning of the main optional part, in a non-capturing group
        
        														#    The first and most prevalent is the Superclass name that the class is being subclassed from, and it's options of parameters and again, 
        														#    if it has parameters, at least the first one is required ie.: class ToolButtonFx(oParent) of Toolbutton(oParent).
        
        							\h of \h                    #    Optional 'of' keyword, surrounded by 1 horizontal whitespace char
        							\w+                         #    Superclass name
        
        							(?1)?                       #    Optional parameter(s) part ( Subroutine call to Group 1 )
        
        														#    The next possible option is that it is a custom object and needs to be in this line so if the object or form is opened up in the dBASE IDE,
        														#    the designers in it won't mess up the object by streaming out missing parts or overriding properties or objects and functions.
        
        							( \h custom )?              #    Optional 'custom' keyword 
        
        														#    The next possible option is that the class is being subclassed from another object that is contained elsewhere and the compiler needs to know
        														#    this reference. There are two options for pointing to the file. The first is an Alias path in the IDE that can be accessed by the compiler
        														#    in the environment, or second, it is in the current directory and only the name is needed...or it has a path that can be listed here,
        														#    but this is bad practice, and an Alias is recommended if the file is in a place other than the current directory. If it is, the name can be
        														#    used in quotes as a string that gets passed to the compiler. Both follow the word 'From'. The Alias directory is a name that is enclosed
        														#    in two colons, one immediately before the Alias name and one immediately after, no spaces.
        
        							(?:                         #    Beginning of the optional part, in a non-capturing group
        							  \h from \h                #      Optional 'from' keyword, surrounded by 1 horizontal whitespace char
        
        							  (?:                       #    Beginning of a non-capturing group
        								  : \w+ : \w+ \. \w+    #        First pointing file case
        								|                       #      OR
        								  \x22 \w+ \. \w+ \x22  #        Second pointing file case
        							  )                         #    End of a non-capturing group
        
        							)?                          #    End of the optional part
        
        						  )?                            #  End of the main optional part
        
        						  $                             #  End of current line and end of the class declaration
        
        						  (?s:.*?^\h*endclass)           #  must match all the way to 'endclass'
        
        
        						 "
        
        				 closeSymbole="endclass"
        						 
        			>
        				<className>
        					<nameExpr
        						expr="(?x-i)                    #  Free-spacing mode and inline comments and search sensible to case
        						      \h*                       #  Optional leading whitespace chars
        						      class                     #  'class' keyword
        						      \h?                       #  Optional whitepace char
        						      \K\w+                     #  Pure class name
        						     "
        					/>
        					
        				</className>
        			<function
        					mainExpr="(?x-s) 
        									
        									\h* 
        									(?:
        									
        									function \h+ \w+
        									|
        									procedure \h+ \w+
        									|
        									with \h+ \(.*?\)
        								)
        								\h*
        							"
        				>
        					<functionName>
        						<funcNameExpr expr="(?x-s)			# multiline/comments
        															# (! // | && | * ) trying to keep following keywords from being included in comments
        								\h*							# allow leading spaces
        								(?:
        									
        									function				# must have word 'function' as first word
        									\h+						# must have at least one horizontal space after function
        									\K 						# don't keep 'function' in the name of the function in the panel
        									\w+						# the name of the function is the first whole word after 'function'
        								|
        									procedure				# must have word 'procedure' as first word
        									\h+      				# must have at least one horizontal space after procedure
        									\K       				# don't keep 'procedure' in the name of the function in the panel
        									(!to)\w+ 				# the name of the function is the first whole word after 'procedure' - 'to'
        															# so as to exclude any 'set procedure to' statements, needs work though.
        								|
        									with					# must have word 'with' as first word
        									\h+						# must have at least one horizontal space after function
        									\K 						# don't keep 'with' in the name of the function in the panel
        									\(						# start paren
        									.*?						# 'this' or equivalent
        									\)						# end paren
        								)
        							"
        						/>
        					</functionName>
        				</function>
        			</classRange>
        			<function
        					mainExpr="(?x-s) 
        									\h* 
        									(?:
        									function \h+ \w+
        									|
        									procedure \h+ \w+
        									|
        									with \h+ \(.*?\)
        								)
        								\h*
        							"
        				>
        					<functionName>
        						<nameExpr expr="(?x-s)			# multiline/comments
        								
        								\h*							# allow leading spaces
        								(?:
        									function				# must have word 'function' as first word
        									\h+						# must have at least one horizontal space after function
        									\K 						# don't keep 'function' in the name of the function in the panel
        									\w+						# the name of the function is the first whole word after 'function'
        								|
        									procedure
        									\h+
        									\K
        									(!to)\w+
        								|
        									with					# must have word 'with' as first word
        									\h+						# must have at least one horizontal space after function
        									\K 						# don't keep 'with' in the name of the function in the panel
        									\(						# start paren
        									.*?						# 'this' or equivalent
        									\)						# end paren
        								)
        							"
        						/>
        					</functionName>
        				</function>
        		</parser>
        	</functionList>
        </NotepadPlus>
        
        Lycan ThropeL 1 Reply Last reply Reply Quote 0
        • Lycan ThropeL
          Lycan Thrope @Lycan Thrope
          last edited by

          @lycan-thrope
          There seems, according to this forum code highlighting, to be a difference in highlighting, that to me, says there’s a typo somewhere, that I’m not seeing in NPP. Screen 1 shows what looks to be normal, kind of going abnormal:
          BBCodeShow1.PNG

          And then Screen 2 shows what looks like something unclosed or different and abnormal:
          BBCodeShow2.PNG

          Will keep looking and thanks for at least, pointing out it works for you, so I will go back to seeing what the heck happened. errant keypress or whatever.

          Lee

          Lycan ThropeL PeterJonesP 2 Replies Last reply Reply Quote 0
          • Lycan ThropeL
            Lycan Thrope @Lycan Thrope
            last edited by

            @lycan-thrope
            Well, one of the things I may have just discoverd is that after taking all those functions that were showing inside comments, and putting them in a class/endclass structure, they stopped showing in the functionlist. If I’m correct, then that means the problem may be in the post class function part, since after making them disappear, I copied them outside of the class structure, and they reappeared.

            Lee

            Lycan ThropeL 1 Reply Last reply Reply Quote 0
            • Lycan ThropeL
              Lycan Thrope @Lycan Thrope
              last edited by

              @lycan-thrope
              Well this is interesting. An overseas (to me) user found that by putting the open and close parens after the function function(), he was able to make the FunctionList not see it. I just tried it out and indeed, it works. Why, I don’ t get it, but apparently it does.
              Screenshot1 shows my code outside the class/endclass construct, representing a non-class function inside comments:
              FLCommentwithoutparens.PNG

              Screenshot 2 shows that after adding the parens, and reloading the FunctionList, the commented code is now invisible to the FunctionList:
              FLCommentwithparens.PNG

              So, I may have coded my regex improperly (other than the misnaming I did, that I fixed), or this is a weird bug maybe? The same code is used in the Class/Function class range, which is why I enclosed it in a class/endclass construct to see if was persistent or seperately problematic.

              Lee

              Lycan ThropeL 1 Reply Last reply Reply Quote 0
              • Lycan ThropeL
                Lycan Thrope @Lycan Thrope
                last edited by

                @lycan-thrope,
                Equally problematic is that looking at the screenshot now, I just noticed that the Class/Endclass construct, is not showing as a class inside the FunctionList.

                Hmmm…

                Lee

                Lycan ThropeL 1 Reply Last reply Reply Quote 0
                • Lycan ThropeL
                  Lycan Thrope @Lycan Thrope
                  last edited by

                  @lycan-thrope
                  Never mind, just remembered it has to have an UNcommented function to show in the list. :-(. DOH!!

                  1 Reply Last reply Reply Quote 0
                  • PeterJonesP
                    PeterJones @Lycan Thrope
                    last edited by

                    @lycan-thrope said in FunctionList Confused:

                    There seems, according to this forum code highlighting, to be a difference in highlighting, that to me, says there’s a typo somewhere

                    Just a quick FYI: you really shouldn’t rely on this forum’s syntax highlighter to accurately determine whether or not you have valid XML. It wasn’t built for that. (The Notepad++ plugin XML Tools would be a much better choice for such checking.)

                    1 Reply Last reply Reply Quote 2
                    • PeterJonesP
                      PeterJones @Lycan Thrope
                      last edited by

                      @lycan-thrope ,

                      The (!to) that you have in there a couple times does not mean what you think it means. I think you meant to say (?!to) to say a negative lookahead to prevent to from being the next word after procedure.

                      But even that isn’t quite right, because if you had a procedure named todosomething, the procedure \h+ \K (?!to)\w+ would eliminate that match. So we need to force a boundary after that as well, so procedure \h+ \K (?!to\b)\w+: so I think what you want for that alternation in both is

                      									procedure				# must have word 'procedure' as first word
                      									\h+      				# must have at least one horizontal space after procedure
                      									\K       				# don't keep 'procedure' in the name of the function in the panel
                      									(?!to\b)\w+ 				# the name of the function is the first whole word after 'procedure' - 'to'
                      															# so as to exclude any 'set procedure to' statements, needs work though.
                      

                      I don’t know why our comment expressions aren’t working right in your definition given in your “highlight difference in here” post, because in my simplified definition, that comment expression prevented it completely. Hmph.

                      Still, we should be able to make it so that set procedure or // procedure or && procedure will never allow it, by making the function names require a start-of-line before the spaces, so procedure/function/with must be the first non-space on the given line to match. Yes, adding a ^ to the beginning of each of the <function mainExpr="..."> attribute values seems to have worked.

                      032f3538-c421-41c2-af3e-9c59c9ca5f2b-image.png

                      <?xml version="1.0" encoding="UTF-8" ?>
                      <!-- ==========================================================================\
                      |
                      |   To learn how to make your own language parser, please check the following
                      |   link:
                      |       https://npp-user-manual.org/docs/function-list/
                      |
                      \=========================================================================== -->
                      <NotepadPlus>
                      	<functionList>
                      		<!-- ========================================================= [ dBASEPlus ] -->
                      		<parser
                      			displayName="dBASEPlus"
                      			id         ="dbaseplus"
                      			commentExpr="(?s:/\*.*?\*/)|(?m-s:(//|&&).*?$)"
                      		>
                      			<classRange
                      				mainExpr="(?x-i)                        #  Free-spacing mode and inline comments + search sensitive to case
                      
                      						  ^\h*                          #  Optional leading whitespace chars
                      						  class                         #  'class' keyword
                      						  \h?                           #  Optional whitepace char
                      						  \w+                           #  Class name
                      
                      														#  Following the class name there is the option of parameters, and if so the first entry inside the parens is required, whether there is other 
                      														#  parameters or not, once the parens go up, the first is required. ie: class FrameCtrl(frameObj)
                      
                      						  (                             #  Beginning of the optional parameter(s) part  ( Group 1 )
                      							\h? \(                      #    Opening parenthesis
                      							\w+                         #    First and required parameter
                      							( , \h? \w+)*               #    Following optional/additional parameters
                      							\)                          #    Closing  parenthesis
                      						  )?                            #  End of the optional parameter(s) part
                      
                      														#  For the rest of the class declaration, after the class name, all other options are part of one big optional set, that follows 'of'
                      														#  and can be populated by one of several options.
                      
                      						  (?:                           #  Beginning of the main optional part, in a non-capturing group
                      
                      														#    The first and most prevalent is the Superclass name that the class is being subclassed from, and it's options of parameters and again, 
                      														#    if it has parameters, at least the first one is required ie.: class ToolButtonFx(oParent) of Toolbutton(oParent).
                      
                      							\h of \h                    #    Optional 'of' keyword, surrounded by 1 horizontal whitespace char
                      							\w+                         #    Superclass name
                      
                      							(?1)?                       #    Optional parameter(s) part ( Subroutine call to Group 1 )
                      
                      														#    The next possible option is that it is a custom object and needs to be in this line so if the object or form is opened up in the dBASE IDE,
                      														#    the designers in it won't mess up the object by streaming out missing parts or overriding properties or objects and functions.
                      
                      							( \h custom )?              #    Optional 'custom' keyword 
                      
                      														#    The next possible option is that the class is being subclassed from another object that is contained elsewhere and the compiler needs to know
                      														#    this reference. There are two options for pointing to the file. The first is an Alias path in the IDE that can be accessed by the compiler
                      														#    in the environment, or second, it is in the current directory and only the name is needed...or it has a path that can be listed here,
                      														#    but this is bad practice, and an Alias is recommended if the file is in a place other than the current directory. If it is, the name can be
                      														#    used in quotes as a string that gets passed to the compiler. Both follow the word 'From'. The Alias directory is a name that is enclosed
                      														#    in two colons, one immediately before the Alias name and one immediately after, no spaces.
                      
                      							(?:                         #    Beginning of the optional part, in a non-capturing group
                      							  \h from \h                #      Optional 'from' keyword, surrounded by 1 horizontal whitespace char
                      
                      							  (?:                       #    Beginning of a non-capturing group
                      								  : \w+ : \w+ \. \w+    #        First pointing file case
                      								|                       #      OR
                      								  \x22 \w+ \. \w+ \x22  #        Second pointing file case
                      							  )                         #    End of a non-capturing group
                      
                      							)?                          #    End of the optional part
                      
                      						  )?                            #  End of the main optional part
                      
                      						  $                             #  End of current line and end of the class declaration
                      
                      						  (?s:.*?^\h*endclass)           #  must match all the way to 'endclass'
                      
                      
                      						 "
                      
                      				 closeSymbole="endclass"
                      						 
                      			>
                      				<className>
                      					<nameExpr
                      						expr="(?x-i)                    #  Free-spacing mode and inline comments and search sensible to case
                      						      \h*                       #  Optional leading whitespace chars
                      						      class                     #  'class' keyword
                      						      \h?                       #  Optional whitepace char
                      						      \K\w+                     #  Pure class name
                      						     "
                      					/>
                      					
                      				</className>
                      			<function
                      					mainExpr="(?x-s) 
                      									^						# peter added ^ to make sure function/procedure/with is first non-whitespace on line
                      									\h* 
                      									(?:
                      									
                      									function \h+ \w+
                      									|
                      									procedure \h+ \w+
                      									|
                      									with \h+ \(.*?\)
                      								)
                      								\h*
                      							"
                      				>
                      					<functionName>
                      						<funcNameExpr expr="(?x-s)			# multiline/comments
                      															# (! // | && | * ) trying to keep following keywords from being included in comments
                      								\h*							# allow leading spaces
                      								(?:
                      									
                      									function				# must have word 'function' as first word
                      									\h+						# must have at least one horizontal space after function
                      									\K 						# don't keep 'function' in the name of the function in the panel
                      									\w+						# the name of the function is the first whole word after 'function'
                      								|
                      									procedure				# must have word 'procedure' as first word
                      									\h+      				# must have at least one horizontal space after procedure
                      									\K       				# don't keep 'procedure' in the name of the function in the panel
                      									(?!to\b)\w+ 				# the name of the function is the first whole word after 'procedure' - 'to'
                      															# so as to exclude any 'set procedure to' statements, needs work though.
                      								|
                      									with					# must have word 'with' as first word
                      									\h+						# must have at least one horizontal space after function
                      									\K 						# don't keep 'with' in the name of the function in the panel
                      									\(						# start paren
                      									.*?						# 'this' or equivalent
                      									\)						# end paren
                      								)
                      							"
                      						/>
                      					</functionName>
                      				</function>
                      			</classRange>
                      			<function
                      					mainExpr="(?x-s) 
                      									^						# peter added ^ to make sure function/procedure/with is first non-whitespace on line
                      									\h* 
                      									(?:
                      									function \h+ \w+
                      									|
                      									procedure \h+ \w+
                      									|
                      									with \h+ \(.*?\)
                      								)
                      								\h*
                      							"
                      				>
                      					<functionName>
                      						<nameExpr expr="(?x-s)			# multiline/comments
                      								
                      								\h*							# allow leading spaces
                      								(?:
                      									function				# must have word 'function' as first word
                      									\h+						# must have at least one horizontal space after function
                      									\K 						# don't keep 'function' in the name of the function in the panel
                      									\w+						# the name of the function is the first whole word after 'function'
                      								|
                      									procedure
                      									\h+
                      									\K
                      									(?!to\b)\w+ 				# the name of the function is the first whole word after 'procedure' - 'to'
                      								|
                      									with					# must have word 'with' as first word
                      									\h+						# must have at least one horizontal space after function
                      									\K 						# don't keep 'with' in the name of the function in the panel
                      									\(						# start paren
                      									.*?						# 'this' or equivalent
                      									\)						# end paren
                      								)
                      							"
                      						/>
                      					</functionName>
                      				</function>
                      		</parser>
                      	</functionList>
                      </NotepadPlus>
                      

                      Also, I see you again had (but fixed) the confusion between <functionName><functionNameExpr> in a class vs <functionName><nameExpr> not in a class. The FAQ definitely shows it correctly, but I apparently need to clarify that better in the usermanual, because it’s not well-defined there. :-(

                      Lycan ThropeL 1 Reply Last reply Reply Quote 2
                      • Lycan ThropeL
                        Lycan Thrope @PeterJones
                        last edited by

                        @peterjones ,

                        Thanks, that seems to have been the problem. I (mistakenly) though that the caret ^ meant it had to be the very first character on the line, all the way to the left with no spaces, which is why I didn’t try that. :-(

                        Thanks for that !to fix. I have to say, both of these issues are the result that I probably don’t have the understanding of regex usage that I should, and that is definitely on me, so thanks for these fixes I should have caught. :(

                        Anything to help clarity, but really, the manual and the Outline that MAPJe71 lays out, is pretty clear, it’s just kind that if I had followed your process of doing the function first, I wouldn’t have gotten confused thinking the Class fuction finding structure, was the same for the non-Class function finding structure. This might be what I saw in the highlighting of the forum syntax highlighting being the difference, and started searching for bad tags and found it. :) Fortunate coincidence, maybe, but effective just the same.

                        Thanks a bunch. As one of our programmers in the group always points out, that code always works against the test usage, it’s when it get used against other usage that it breaks. That was the problem here. While I was testing against the kind of code I write (without commenting out sections) it worked just fine…it wasn’t until someone that does comment out code sections used it that the error came to light. :-)

                        Again, many thanks for the help and hopefully I won’t bother you over the New Year, since other than the hints I’m meticulously going over to put together, this problem should be the last regex related one. :-)

                        Happy New Year,
                        Lee

                        1 Reply Last reply Reply Quote 0
                        • guy038G
                          guy038
                          last edited by

                          hello, @lycan-thrope and All,

                          First, I wish an excellent year 2022, to any N++ user, with less COVID-19 stories than before !


                          Well, Lycan, I thought that the kind of regex, below, would solve the problem of false positive functions, procedures and with (this) things !

                          commentExpr="(?s:/\*((?!function|procedure|with \(this\)|endwith).)*?\*/)|(?-s://|&&)((?!function|procedure|with \(this\)|endwith).)*$"

                          Unfortunately, this does not work, too ! Indeed, assuming this INPUT text, in a new tab :

                          /*Test_1
                          */
                          
                          //Test_2
                          
                          &&Test_3
                          
                          //with (that)
                          
                          /* Test_4
                           */
                          
                          // Test_5
                          
                          && Test_6
                          
                          // with (that)
                          
                          /*  Test_7
                          */
                          
                          //  Test_8
                          
                          &&  Test_9
                          
                          //  with (that)
                          
                          
                          //function
                          //function ABC
                          
                          &&function DEF
                          
                          /*function GHI
                          */
                          
                          //with (this)
                          //endwith
                          
                          //procedure
                          //procedure JKL
                          
                          
                          // function
                          // function ABC_1
                          
                          && function DEF_1
                          
                          /* function GHI_1
                           */
                          
                          // with (this)
                          // endwith
                          
                          // procedure
                          // procedure JKL_1
                          
                          
                          //  function
                          //  function ABC_2
                          
                          &&  function DEF_2
                          
                          /*  function GHI_2
                            */
                          
                          //  with (this)
                          //  endwith
                          
                          //  procedure
                          //  procedure JKL_2
                          
                          
                          //Test this function being caught
                          
                          // Test this function being caught
                          
                          //  Test this function being caught
                          
                          
                          class Test
                          	bla
                          	blah
                          	function toto
                          		bla
                          		bla
                          		blah
                          	blah
                          	bla
                          endclass
                          

                          and using your dbasePlus.xml file, with my new comments tag, the function list panel does display the class Test and the embedded function Toto.

                          Now, if you try to see the occurrences of the associated regex : (?s:/\*((?!function|procedure|with \(this\)|endwith).)*?\*/)|(?-s://|&&)((?!function|procedure|with \(this\)|endwith).)*$, it’ll just highlights, as expected, the following lines :

                          /*Test_1
                          */
                          
                          //Test_2
                          
                          &&Test_3
                          
                          //with (that)
                          
                          /* Test_4
                           */
                          
                          // Test_5
                          
                          && Test_6
                          
                          // with (that)
                          
                          /*  Test_7
                          */
                          
                          //  Test_8
                          
                          &&  Test_9
                          
                          //  with (that)
                          

                          Which are really true comments ! Note that //..with (that) is considered as true comment because it’s different from with (this)

                          However, the commentExpr tag still displays the different Functions, procedures and so on, as valid values, although they are defined in comment parts !

                          So the simple rule to remember is to forbid any piece of code in comments !

                          Best Regards,

                          guy038

                          Lycan ThropeL 1 Reply Last reply Reply Quote 1
                          • guy038G
                            guy038
                            last edited by guy038

                            Hi, @lycan-thrope and All,

                            Back to what I wrote yesterday, I realize that my reasonning is absolutely false. For instance, if I suppose, as does my regex, that the word function must not be present in comments, this implies that it should be displayed as a normal function, i.e. exactly the opposite way that I suggested before :-((

                            So, inverting the regex logic, I should have used the regex :

                            commentExpr="(?s:/\*((?=function|procedure|with \(this\)|endwith).)*?\*/)|(?-s://|&&)((?=function|procedure|with \(this\)|endwith).)*$"

                            But, in this case, normal comments, not containing any code, would not be considered as comments, too :-((


                            So, globally, we should say that the commentExpr tag is not acting the way it should ! Indeed, whatever occurs, right after the comment character(s), it should always be considered as a true comment !

                            Thus, again, just forbid any piece of code in comments !

                            BR

                            guy038

                            1 Reply Last reply Reply Quote 0
                            • Lycan ThropeL
                              Lycan Thrope @guy038
                              last edited by

                              @guy038
                              Well, before Peter found the problem with my regex, that was my advice to the guy with the problem. :-)

                              Patient: Doctor, it hurts when I do this.
                              Doctor: Stop doing that, then. That’ll be $50.00, please.

                              Anyway, with Peter’s help it was fixed, and I’m on to the Auto Completion stuff to try and finish this project within the next few days.

                              Thanks for looking at this, though. After I get done with the Auto Complete, I have to go back and look at removing the ’
                              (this.object.object) parens and let it show the final object as the object listed in the FunctionList, so that it looks a little neater, and more in keeping with the present usage of the in IDE editor views…but that’s for playing later, I just want to get the full project done before I start fine tuning things. :-)

                              Happy New Year to you also, and all the forum dwellers here.

                              Lee

                              Lycan ThropeL 1 Reply Last reply Reply Quote 0
                              • Lycan ThropeL
                                Lycan Thrope @Lycan Thrope
                                last edited by

                                @lycan-thrope
                                Okay, it’s a New Year. Back to the regex stuff. :-)

                                I’m trying to remove the Parens from around the this naming that shows the objects in our FunctionList, and am trying to pick off the end name or any combination to display without the this. I came up with this regex, that seems to do the job of isolating the last word in the parens and capture it in it’s own capture group, but I seem to be having trouble making it work in side of the functionList regex.

                                ([.](\w+)\))

                                As this screenshot of Regex101.com shows:
                                FLRegexminusparens.PNG

                                This is what comes up with your regex:
                                FLTreeWithoutTryingCaptureGroupassign.PNG

                                And what it shows when I try just assigning capture group 2 for the id with this ([.](\w+)\)) \2 in place of your \( *.? \) regex:
                                FLTreeTryingCaptureGroupassign.PNG

                                The problem seems to come when I try anything other than the original regex you developed Peter. I tried a couple of things to try and give an option of either this last word or this…kind of like (this | ([.](\w+)\)) and most often it comes up with the first (this) object and nothing else, or nothing at all, only functions. Is there a way to isolate the names without the this and the parens like a look-behind thing or am I way off base here?

                                Lee

                                Lycan ThropeL 1 Reply Last reply Reply Quote 0
                                • Lycan ThropeL
                                  Lycan Thrope @Lycan Thrope
                                  last edited by

                                  @lycan-thrope
                                  By the way, the only thing that really changed, was that I got rid of the \K and allowed the Function or Procedure to be included with it’s name. One of the users who has a lot of old dBASE code that he’s porting over to the dBASEPlus has the differentiations, and this helps him quickly identify renaming or recoding the differently named identifiers. We found and he liked this quirk that the Functions inside comments was doing as he was able to identify them by doing that, but until you showed me how to fix it, he was going to wait until I was able to change it, and once I got the Autocompletion done, it was a matter of minutes before I figured out what to do to return that functionality for him and he’s really grateful for the ability to discern them now. :-) You’ve a big help already to our community, so thanks.

                                  Lee

                                  Lycan ThropeL 1 Reply Last reply Reply Quote 0
                                  • Lycan ThropeL
                                    Lycan Thrope @Lycan Thrope
                                    last edited by

                                    @lycan-thrope
                                    Never mind, just saw this section of the FunctionList explanation.
                                    The parser can only search for function names, it will not do regular expression replacement or modification (so you cannot add text to the matching names)

                                    I guess the question becomes, is there a way to isolate those sections that I do want with regex, and then pose a selection choice this| (foundtext) depending on if there are other names are not.

                                    Lee

                                    Lycan ThropeL 1 Reply Last reply Reply Quote 0
                                    • Lycan ThropeL
                                      Lycan Thrope @Lycan Thrope
                                      last edited by

                                      @lycan-thrope
                                      Well, I have hope I’m on to something here. Tried a different site to explain some of the look ahead/behind stuff and managed to come up with something that half works. :-)

                                      The first half works in that it changes (this) to this in the functionList panel for the first object which is the Form itself. I used this regex, probably improperly or need to phrase it differently\(\Kthis(?=\))|[.]\K\w+(?=\)) but the OR condition didn’t take, or it did but since the other objects have this with a dot in it, it disqualifed the condition and threw out the final objects instead. So now this:
                                       So now this:

                                      Looks like this:
                                      ARegexthis.PNG

                                      I need to figure out how to make the regex choose between supplying the captured group of either this by it’s self, OR if a match works that ends with a dotWordclosingparen, it displays just the word for that Object.

                                      If the above screenshot, the (this.TESTCONTAINER.VSCROLLBAR1) is a child object of the TESTCONTAINER, but…the VSCROLLBAR1 is an obect in it’s self. If I can capture the whole thing after this without the parens, but the dot between the two objects that would be considered a success since it at least cleans it up, but I am tryig to just pick off the last object name so the list would just include the objects themselves for navigation purposes when using the FunctionList panel…so I’m still working on it, trying to see how to make it work.

                                      Lee

                                      Lycan ThropeL 1 Reply Last reply Reply Quote 0
                                      • Lycan ThropeL
                                        Lycan Thrope @Lycan Thrope
                                        last edited by

                                        @lycan-thrope
                                        Interesting, reversing a different, but similar regex gets me the VSCROLLBAR1 but nothing else. Hmm… I guess the or operator is not going to get this job done. Hmm.

                                        Lycan ThropeL 1 Reply Last reply Reply Quote 0
                                        • Lycan ThropeL
                                          Lycan Thrope @Lycan Thrope
                                          last edited by

                                          @lycan-thrope

                                          Okay, now we’re cooking with gas. :-)

                                          I figured out how to exclude the parens with \K(.*?)(?=\)) and here’s what it looks like:
                                          FLRegexminusparensAccomplished.PNG

                                          I fear, however, keeping the this for the first object, and removing it from the rest is going to be a bit harder…but maybe not if I can figure out how to make the or work and figure out how to keep the this keyword if followed by the closing paren, but not if it’s follow by a dot operator, and use the rest of the object description instead. This is kind of fun…and kind of frustrating at the same time. :-)

                                          Lee

                                          Lycan ThropeL 1 Reply Last reply Reply Quote 0
                                          • Lycan ThropeL
                                            Lycan Thrope @Lycan Thrope
                                            last edited by

                                            @lycan-thrope
                                            Any chance that there is an IF/ELSE kind of Regex construction that the FunctionList parser will accept, instead of selecting a capture group, or using OR(|)?

                                            Lee

                                            Lycan ThropeL 1 Reply Last reply Reply Quote 0
                                            • First post
                                              Last post
                                            The Community of users of the Notepad++ text editor.
                                            Powered by NodeBB | Contributors