Function list and AutoIt / AU3 files
my name is Dave and I am a big fan of NotePad++ and I am trying to customize it as far as I can. And as I am writing some AutoIt stuff at the moment, I try to find or write a parser to include into functionList.xml to add recognition of AU3 functions.
They look like this :
and comments are delimitated by a “;” : everything on the right of the “;” is ignored.
as a first try, I added this :
<association langID="40" id="au3_function"/>
<parser id="au3_function" displayName="Au3 script" > <function mainExpr="^\s*func\s+\w+\(.*" displayMode="$functionName"> <functionName> <nameExpr expr=".*"/> </functionName> </function> </parser>
the function list seems to detect the AU3 file, but nothing appears…
subsidiary question : is the function list parser case sensitive ? because I type “func” but it could be “Func” or “FUNC” or any other combination…
Notepad++ doc on the subject :
Thanks for your help and have a nice day.
Try this parser:
<parser id="au_function" displayName="AutoIt3" commentExpr="(((?mi-s)^\h*;.*?$)/|((?s-m)#cs.*?#ce))" > <function mainExpr="(?i)^\h*func\h+\w+\h*\(" > <functionName> <nameExpr expr="(?mi)(?<=^\h*func\h+)\w+" /> </functionName> </function> </parser>
thanks a lot for the answer.
sorry to reply with another login, but I cannot login with my google+ on firefox… strange.
So I tried what you said, but it does not match at all.
So I tried to simplify and the only thing that worked was :
<function mainExpr="^\h*func\h+\w+\h*\(" > <functionName> <nameExpr expr="^\h*func\h+\w+" />
but it returns “func” before each function name.
I do not understand why (?<= does not work…
Mea Culpa, didn’t test it, just copied from my FuncionList.xml.
Try this (tested and confirmed!) parser:
<parser id="au3_function" displayName="AutoIt3" commentExpr="(?mi-s)^\s*;.*?$|(?s-m)#cs.*?#ce" > <function mainExpr="^\s*(?i:FUNC)\s+[A-Za-z_]\w*\s*\([^()]*?\)" > <functionName> <nameExpr expr="(?!(?i:FUNC)\s+)[A-Za-z_]\w*\s*\(" /> <nameExpr expr="[A-Za-z_]\w*" /> </functionName> </function> </parser>
Thanks a lot !
It works like a charm.
I understood what you did,
I just have a problem with the [^()]*? part between the two function parenthesis at the end of mainExpr.
And what about (?!func\s+). Does it mean that I don’t want a func patern at the right ? Why not a positive lookbehind with ?<= is not working ?
Could you explain to a novice ?
[^()]*?(none greedy zero or more characters not being parenthesis) I was aiming for the possibility to include the function parameters in the tree view.
(?!(?i:FUNC)\s+))should have been
(?!(?i:FUNC)\b))so you can even use function names starting with func, Func, fUNC, FUNC, FuNc, etc. e.g.
Func functionNameExample() ; function body EndFunc
Positive look behind is supported since Boost v1.33.0.
So in theory it should be supported as Notepad++ is using Boost v1.55.0 for the RegEx engine in its custom Scintilla build.
Thanks for the explanation