[Help] Function list doesn't support my language.
-
Could you supply a code example?
-
This is my code, already integrated into functionlist and working.
Just need to parse out the comments, so they dont appear in thefunction list.
<!-- Basic lua parser for functionList.xml in Notepad++ 6.5.3 --> <!-- See http://notepad-plus-plus.org/features/function-list.html --> <parser id="lua_function" displayName="Lua" commentExpr="--.*?$"> <!-- Basic lua table view, nested lua table not supported --> <classRange mainExpr="[.\w]+[\s]*=[\s]*\{" openSymbole="\{" closeSymbole="\}" displayMode="node"> <className> <nameExpr expr="[.\w]+"/> </className> <function mainExpr="[.\w]+[\s]*=[\s]*['"]?[\w]+['"]?"> <functionName> <funcNameExpr expr=".*"/> </functionName> </function> </classRange> <!-- Basic lua functions support --> <function mainExpr="(function[\s]+[.\w]+(:[\w]+)?)|([.\w]+[\s]*=[\s]*function)" displayMode="$className->$functionName"> <functionName> <nameExpr expr="((?<=function)[\s]+[.:\w]+)|(([.\w]+)(?=([\s]*=[\s]*function)))"/> </functionName> <className> <nameExpr expr="[.\w]+(?=:)"/> </className> </function> </parser> <!-- ================================================================= --> </parsers> </functionList></NotepadPlus>
-
@SalviaSage
Sigh, a Lua source code example containing function definitions in comment that the parser should not find. -
This one for example:
--[[ Resize and hide any unusable bag slots in the frame. This function needs to know about the size and layout of the frame --]]“needs” here is recognized as a function because it is right after the word “function”
and here:–this function is there so that it can be overriden
the word "is" is recognized here also. -
@SalviaSage
Change the parsers header from<parser id="lua_function" displayName="Lua" commentExpr="--.*?$">to
<parser displayName="Lua" id ="lua_function" commentExpr="(?x) # free-spacing (see `RegEx - Pattern Modifiers`) (?s: # Multi Line Comment (?<!-)-{2} # - start-of-comment indicator with \x5B(?'MLCLVL'=*)\x5B # ...specific level .*? # - whatever, until \x5D\k'MLCLVL'\x5D # - end-of-comment indicator of equal level ) | (?m-s:-{2}.*$) # Single Line Comment | (?s-m: # String Literal =\s* \x5B(?'SLLVL'=*)\x5B # - start-of-string indicator with specific level .*? # - whatever, until \x5D\k'SLLVL'\x5D # - end-of-string indicator of equal level ) " > -
I just entered this code into the functionlist.xml as such:
</parser> <!-- Basic lua parser for functionList.xml in Notepad++ 6.5.3 --> <!-- See http://notepad-plus-plus.org/features/function-list.html --> <parser displayName="Lua" id ="lua_function" commentExpr="(?x) # free-spacing (see `RegEx - Pattern Modifiers`) (?s: # Multi Line Comment (?<!-)-{2} # - start-of-comment indicator with \x5B(?'MLCLVL'=*)\x5B # ...specific level .*? # - whatever, until \x5D\k'MLCLVL'\x5D # - end-of-comment indicator of equal level ) | (?m-s:-{2}.*$) # Single Line Comment | (?s-m: # String Literal =\s* \x5B(?'SLLVL'=*)\x5B # - start-of-string indicator with specific level .*? # - whatever, until \x5D\k'SLLVL'\x5D # - end-of-string indicator of equal level ) " > <!-- Basic lua table view, nested lua table not supported --> <classRange mainExpr="[.\w]+[\s]*=[\s]*\{" openSymbole="\{" closeSymbole="\}" displayMode="node"> <className> <nameExpr expr="[.\w]+"/> </className> <function mainExpr="[.\w]+[\s]*=[\s]*['"]?[\w]+['"]?"> <functionName> <funcNameExpr expr=".*"/> </functionName> </function> </classRange> <!-- Basic lua functions support --> <function mainExpr="(function[\s]+[.\w]+(:[\w]+)?)|([.\w]+[\s]*=[\s]*function)" displayMode="$className->$functionName"> <functionName> <nameExpr expr="((?<=function)[\s]+[.:\w]+)|(([.\w]+)(?=([\s]*=[\s]*function)))"/> </functionName> <className> <nameExpr expr="[.\w]+(?=:)"/> </className> </function> </parser> <!-- ================================================================= --> </parsers> </functionList> </NotepadPlus>It didn’t change anything. I think I indented right.
It errors on this line <nameExpr expr=“((?<=function)[\s]+[.:\w]+)|(([.\w]+)(?=([\s]*=[\s]*function)))”/>
according to the online xml validator. -
Change the
?<=to?<=. -
I don’t think that worked.
-
This one works for me (no classes/tables yet though):
<parser displayName="Lua w/o Class" id ="lua_function" commentExpr="(?x) # free-spacing (see `RegEx - Pattern Modifiers`) (?s: # Multi Line Comment (?<!-)-{2} # - start-of-comment indicator with \x5B(?'MLCLVL'=*)\x5B # ...specific level .*? # - whatever, until \x5D\k'MLCLVL'\x5D # - end-of-comment indicator of equal level ) | (?m-s:-{2}.*$) # Single Line Comment | (?s-m: # String Literal =\s* \x5B(?'SLLVL'=*)\x5B # - start-of-string indicator with specific level .*? # - whatever, until \x5D\k'SLLVL'\x5D # - end-of-string indicator of equal level ) " > <function mainExpr="(?x) # free-spacing (see `RegEx - Pattern Modifiers`) (?m) # ^ and $ match at line-breaks (?: ^\h* # optional leading white-space at start-of-line (?-i:local\s+)? (?-i:function) \s+[A-Za-z_]\w* (?:\.[A-Za-z_]\w*)* (?::[A-Za-z_]\w*)? | \s*[A-Za-z_]\w* (?:\.[A-Za-z_]\w*)* \s*= \s*(?-i:function) ) \s*\([^()]*\) " > <functionName> <nameExpr expr="(?<=\bfunction\b)\s+[A-Za-z_][\w.:]*\s*\(|[A-Za-z_][\w.]*\s*=" /> <nameExpr expr="[A-Za-z_][\w.:]*" /> </functionName> </function> </parser> -
I just tested this new code here, and it doesn’t catch the comments or the strings incorrectly.
Thanks a lot for this!
I am trying to combine the table support from the code above into this new code.
Hello! It looks like you're interested in this conversation, but you don't have an account yet.
Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.
With your input, this post could be even better 💗
Register Login