[functionList.xml] What do these colons mean?



  • In “c-function” node of functionList.xml, there are “[\w:]+” and “([\w]+[\s]*::)?” in mainExpr.

    What do these colons mean?



  • [\w:]+ means “match one or more word characters (i.e. A to Z, a to z, 0 to 9 or an underscore) or a colon”.

    ([\w]+[\s]*::)? means “optionally (i.e. the question mark at the end) match one or more word characters followed by zero or more white space (Most engines: space, tab, newline, carriage return, vertical tab; .NET, Python 3, JavaScript: any Unicode separator) followed by two colons”.



  • Thanks to MAPJe71!
    But I don’t understand why there needs colon in C function definition’s head line.

    What I say “function definition’s head line” means:
    int func(int a, int b)
    {

    }
    Then, “int func(int a, int b)” is “function definition’s head line”.



  • The Notepad++ v6.9.2 parser looks like this:

    <parser id="c_function" displayName="C source" commentExpr="((/\*.*?\*)/|(//.*?$))">
    	<function
    	    mainExpr="^[\t ]*((static|const|virtual)[\s]+)?[\w:]+([\s]+[\w]+)?([\s]+|(\*|\*\*)[\s]+|[\s]+(\*|\*\*)|[\s]+(\*|\*\*)[\s]+)([\w_]+[\s]*::)?(?!(if|while|for))[\w_]+[\s]*\([^\)\(]*\)([\s]*const[\s]*)?[\n\s]*\{"
    		displayMode="$functionName">
    		<functionName>
    			<nameExpr expr="(?!(if|while|for))[\w_~]+[\s]*\("/>
    			<nameExpr expr="(?!(if|while|for))[\w_~]+"/>
    		</functionName>
    	</function>
    </parser>
    

    I don’t think this parser works correctly.
    I suspect parts of it have been copied from the C/C++ parser hence the double colon i.e. trying to match a class name.
    The (?!(if|while|for))[\w_]+ part is for the function name.



  • I agree with you. Thank you!



  • I’m actually in the process of creating the first update/overhaul for functionList.xml.
    Unfortunately it will only be a cleanup for the C parser not a correction, yet.

    Current state:

    <parser displayName="C source" id="c_function" commentExpr="(?s-m:/\*.*?\*/)|(?m-s://.*?$)" >
    	<function
    		mainExpr="^[\t ]*((?-i:static|const|virtual)\s+)?[\w:]+(\s+\w+)?(\s+|(\*|\*\*)\s+|\s+(\*|\*\*)|\s+(\*|\*\*)\s+)(\w+\s*::)?(?-i:\b(?!if|while|for)\b)\w+\s*\([^\)\(]*\)(\s*const\s*)?[\n\s]*\{"
    	>
    		<functionName>
    			<nameExpr expr="(?-i:\b(?!if|while|for)\b)[\w~]+\s*\(" />
    			<nameExpr expr="[\w~]+" />
    		</functionName>
    	</function>
    </parser>
    

Log in to reply