I haven’t had a chance to “live with it” yet, but I took @MAPJe71’s and added yuzhy8701’s attributes/prototypes
I also allowed (\w*::)* in the function name, to handle that rare-but-valid syntax. (I decided it didn’t need a separate hierarchy, because if you’re doing it in that format, you probably aren’t thinking of it as “belonging” to a class.)
e710e890-fb34-46e3-a56f-e790a0f7a868-image.png
<!-- ======================================================== [ PERL ] --> <!-- PERL - Practical Extraction and Reporting Language --> <parser displayName="Perl" id="perl_function" commentExpr="(?x) # free-spacing (see `RegEx - Pattern Modifiers`) (?m-s:\x23.*$) # Single Line Comment | (?s:__(?:END|DATA)__.*\Z) # Discard up till end-of-text " > <classRange mainExpr ="(?x) # free-spacing (see `RegEx - Pattern Modifiers`) (?m) # ^ and $ match at line-breaks (?'PACKAGE_HEADER' ^ # NO leading white-space at start-of-line (?-i:package\b) ) (?s:.*?) # whatever, (?= # ...up till \s* # ...optional leading white-space of (?: (?&PACKAGE_HEADER) # ...next header | \Z # ...or end-of-text ) ) " > <className> <nameExpr expr="(?x) # free-spacing (see `RegEx - Pattern Modifiers`) \s \K # discard text matched so far [^;]+ " /> </className> <function mainExpr="(?x) # free-spacing (see `RegEx - Pattern Modifiers`) (?m) ^\h* sub \s+ (?:\w+\:\:)* # optional prefix::package::names:: \w+ (?:\s*\([^()]*\))? # prototype or signature (?:\s*\:\s*[^{]+)? # attributes \s*\{ # start of function body " > <functionName> <funcNameExpr expr="(?x) # free-spacing (see `RegEx - Pattern Modifiers`) (sub\s+)? \K # discard text matched so far (?:\w+\:\:)* # optional prefix::package::names:: \w+ " /> </functionName> </function> </classRange> <function mainExpr="(?x) # free-spacing (see `RegEx - Pattern Modifiers`) (?m) ^\h* sub \s+ (?:\w+\:\:)* # optional prefix::package::names:: \w+ (?:\s*\([^()]*\))? # prototype or signature (?:\s*\:\s*[^{]+)? # attributes \s*\{ # start of function body " > <functionName> <nameExpr expr="(?x) # free-spacing (see `RegEx - Pattern Modifiers`) (?:sub\s+)? \K # discard text matched so far (?:\w+\:\:)* # optional prefix::package::names:: \w+ " /> </functionName> </function> </parser>