Community
    • Login

    [functionList.xml] What do these colons mean?

    Scheduled Pinned Locked Moved Help wanted · · · – – – · · ·
    6 Posts 2 Posters 3.0k Views
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • hwymlH
      hwyml
      last edited by

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

      What do these colons mean?

      1 Reply Last reply Reply Quote 0
      • MAPJe71M
        MAPJe71
        last edited by

        [\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”.

        1 Reply Last reply Reply Quote 0
        • hwymlH
          hwyml
          last edited by hwyml

          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”.

          1 Reply Last reply Reply Quote 0
          • MAPJe71M
            MAPJe71
            last edited by MAPJe71

            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.

            1 Reply Last reply Reply Quote 0
            • hwymlH
              hwyml
              last edited by

              I agree with you. Thank you!

              1 Reply Last reply Reply Quote 0
              • MAPJe71M
                MAPJe71
                last edited by MAPJe71

                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>
                
                1 Reply Last reply Reply Quote 0
                • First post
                  Last post
                The Community of users of the Notepad++ text editor.
                Powered by NodeBB | Contributors