FunctionList Confused
-
@lycan-thrope
Hey Folks,I found a bit of a problem. I searched the forums to see if there was a previous issue with FunctionList words being found inside comments, and I think even Peter made a comment in it that it still had a bug that required to spaces or some such to keep it from listing in the FunctionList.
So, I double checked and the following screenshots show my problem with apparently any time a keyword (function, procedure, with/endwith) shows up in any comment. I know I didn’t regex the (&& comment characters) but it doesn’t seem to make any difference as it shows in this screenshot:
I also checked to make sure the comments were being considered by rechecking the FunctionList regex for the comments symbols (// and /* */) and they were as the screenshot shows, these are standard comment symbols that are supposed to be ignored:
I also tried to change the regex in the search to not include comment symbols from the start of the line search, by using a similar regex like I used to exclude “to”.
(! // | && | *)
All this did was stop even the legitimate finding of functions from working altogether.
So I guess the question is, has this bug been fixed, or is there some way I can exclude these Functions from being found inside comments and listed?
Thanks in advance for any help and wishing all a Happy New Year during these holidays,
Lee
-
@lycan-thrope
OOps forgot the second screenshot showing the regex for the standard comments here:
Thanks , again,
Lee
-
Hi, @lycan-thrope,
Be patient
4/6
hours. I’ll have a look into your problem. I think I’ve got a work-aroud to solve the detection of the wordFunction
in comments !Best Regards,
guy038
-
@guy038 ,
Thanks. Patience, fortunately or unfortunately, is one of my virtues. :-)
I have to get back to work documenting our common methods for the hints as well as our ADO components.
Thanks,
Lee
-
My first, with no proper comment defined, shows functions found in both comments and non-c omments:
My second attempt, just adding in the
//
comment expression does not show the functions from the comments:Now add in the
/*...*/
-style comments to the UDL, but not to the functionList (though I did update to put the//
inside the modified group), and restart:
As expected, it shows
/* function othercomment */
asfunction othercomment
in the functionList. Now edit the comment regex to include an alternate comment definition and restartIt works exactly as I would expect. FunctionList shows
real
,second
,real
,nextwillbecommentedtoo
, andlast
, without showing any ofin comment
,hidden
,commented
,othercomment
, ordontlistme
.As I have done in all the times I have given suggestions in your various forays into UDL, FunctionList, and AutoComplete – though I may not have said it explicitly enough – I always work incrementally in these: start with something that is working, then modify it to try one small thing new, and then either debug until it works or move forward to the next step if it does work. For you to make progress, you are going to have to do the same thing.
<?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> <parser displayName="LycanThropeWFM" id ="lycanthropewfm_function" commentExpr="(?s:/\*.*?\*/)|(?xm-s://.*$)" > <function mainExpr="(?x) # Utilize inline comments (see `RegEx - Pattern Modifiers`) (function|procedure) # works with functions or procedures \s+ [A-Za-z_]\w* " > <functionName> <nameExpr expr=".*" /> </functionName> </function> </parser> </functionList> </NotepadPlus>
Oh, sorry, I just saw that you have added
&&
as a new comment. I will assume those are single-line comments as well, like//
. So i used(?s:/\*.*?\*/)|(?xm-s:(//|\&\&).*$)
in Notepad++ search first, and verified it also found&& procedure ampersand
in addition to the other comment lines. So then I change the commentExpr and save and restart Notepad++:Once again, it works exactly as I would expect. I also removed the
\
before the&
, because that’s only special in the subsitution/replacement, not in the search, and it still works.Oh, you also don’t have the x in the modifier list. But when I remove it, it still works right:
<?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> <parser displayName="LycanThropeWFM" id ="lycanthropewfm_function" commentExpr="(?s:/\*.*?\*/)|(?m-s:(//|&&).*$)" > <function mainExpr="(?x) # Utilize inline comments (see `RegEx - Pattern Modifiers`) (function|procedure) # works with functions or procedures \s+ [A-Za-z_]\w* " > <functionName> <nameExpr expr=".*" /> </functionName> </function> </parser> </functionList> </NotepadPlus>
So, I cannot replicate your problem. If I am inside the parser’s
commentExpr
region, the parser will not identify the function/prcedure for me. -
Hello, @lycan-thrope,
Finally, as we all tried numerous ways to to get a functional parser, the best would be to send me, first, the last version of your
dBAsePlus.xml
file, as text, of course !If you mind a possible lack of confidentiality, here is my temporary e-mail address :
Sorry for this delay !
BR
guy038
-
I don’t know how to explain it, Peter. I pretty much left the file alone after we did our thing and then I made that one change to keep the to out that I posted above to stop
procedure to
from printing theto
. I actually need to stop anyset procedure to
from being recognized, but for the time, that was enough as long as the other stuff worked. I sent it out to some users to test for me and they reported the problems, and then I duplicated it…in that screenshot above.Prior, none of my code has those keywords in my comments, that’s why I didn’t notice it…but that’s the way it was, so I’m at a loss to explain it, but I am back to checking the regex and such.
Here’s my code:
<?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> <funcNameExpr 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>
-
@guy038 ,
I sent the FunctionList file and an example program that I’ve been using, it’s small but if you throw comments in you may see it. I was just using a blank document to put those comments in with a .wfm extension to trigger the FunctionList.
Lee -
@lycan-thrope
Awww crap, I think I just saw the problem in this color-coded viewer on the forums. Need to check it out. :(Lee
-
@lycan-thrope
Not sure if I made it worse or not. ::sigh::
The one change I did do, which was changed thefuncNameExpr
that’s supposed to find just the functions, tonameExpr
seem to change my test set, to lose the Function/Procedure lead names, but they still show, but on the positive side, theset 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 commentsFunction <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-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-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:
And then Screen 2 shows what looks like something unclosed or different and abnormal:
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-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-thrope
Well this is interesting. An overseas (to me) user found that by putting the open and close parens after the functionfunction()
, 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:
Screenshot 2 shows that after adding the parens, and reloading the FunctionList, the commented code is now invisible to the FunctionList:
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-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-thrope
Never mind, just remembered it has to have an UNcommented function to show in the list. :-(. DOH!! -
@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.)
-
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 preventto
from being the next word afterprocedure
.But even that isn’t quite right, because if you had a procedure named
todosomething
, theprocedure \h+ \K (?!to)\w+
would eliminate that match. So we need to force a boundary after that as well, soprocedure \h+ \K (?!to\b)\w+
: so I think what you want for that alternation in both isprocedure # 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.<?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. :-( -
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 -
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
andwith (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 newcomments
tag, thefunction list
panel does display theclass
Test and the embeddedfunction
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 fromwith (this)
However, the
commentExpr
tag still displays the differentFunctions
,procedures
and so on, as valid values, although they are defined incomment
parts !So the simple rule to remember is to forbid any piece of code in
comments
!Best Regards,
guy038