Improved FunctionList's NSIS parser#2462
Improved FunctionList's NSIS parser#2462negrutiu wants to merge 1 commit intonotepad-plus-plus:masterfrom negrutiu:functionlist
Conversation
- Added "!echo" keyword - Detect functions with comments following the function name: Function Test1 ; Comment1 FunctionEnd Function Test2 /* Comment2 */ FunctionEnd
MAPJe71
left a comment
There was a problem hiding this comment.
Current parsers are not ideal. I'm working on improving the FunctionList parsers.
Thanks for the suggestions but I won't integrate them.
| id ="nsis_syntax" | ||
| displayName="NSIS Syntax" | ||
| commentExpr="(?s:/\*.*?\*/)|(?m-s:[#;].*?$)" | ||
| commentExpr="(?s:^[\t\x20]*/\*.*?\*/)|(?m-s:^[\t\x20]*[#;].*?$)" |
There was a problem hiding this comment.
The at-start-of-line (^) and optional leading blanks ([\t\x20]*) don't improve the comment detection but rather make it worse i.e. it prevents detecting trailing comment.
There was a problem hiding this comment.
It's your decision and I respect it...
You're right of course, when speaking about the multi-line /* */ comments.
But for the single-line comments ; and #, my suggestion could still have some value...
The final expression would be: commentExpr="(?s:/\*.*?\*/)|(?m-s:^[\t\x20]*[#;].*?$)"
Just a thought... :)
There was a problem hiding this comment.
could still have some value
What value exactly?
There was a problem hiding this comment.
Here's a perfectly valid NSIS script: Test.nsi.txt
No function is identified with the default parser rules.
With the changes I've suggested (almost) all functions are detected. SubTest4 is of course incorrectly displayed, but still, it becomes much easier to navigate inside large scripts.
Nevertheless, not a critical problem. I'm waiting for the improved parsers...
| > | ||
| <function | ||
| mainExpr="^[\t\x20]*(!macro|Function|Section|SectionGroup)[\t\x20]+[^\r\n]*$" | ||
| mainExpr="^[\t\x20]*(!macro|Function|Section|SectionGroup|!echo)[\t\x20]+[^\r\n]*$" |
There was a problem hiding this comment.
The !echo will list text messages in the FunctionList tree.
That might be your personal preference but is not something to include in the list of official parsers.
There was a problem hiding this comment.
Being a 10+ years NSIS enthusiast I realized that !echo keyword is hardly used in the NSIS community...
Since FunctionList doesn't have "grouping capabilities", I used !echo ----------- to insert separators between blocks of code. I gained more visibility in the function list.
But yes, it's more of a personal preference...
There was a problem hiding this comment.
doesn't have "grouping capabilities"
Yes it does (somewhat) with classRange. I intend to use it for SectionGroup.
Improved FunctionList's NSIS syntax:
Added !echo keyword
Detect functions with comments following the function name: