• Login
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.
  • H
    hwyml
    last edited by Aug 23, 2016, 6:25 AM

    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
    • M
      MAPJe71
      last edited by Aug 23, 2016, 6:38 AM

      [\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
      • H
        hwyml
        last edited by hwyml Aug 23, 2016, 6:46 AM Aug 23, 2016, 6:46 AM

        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
        • M
          MAPJe71
          last edited by MAPJe71 Aug 23, 2016, 7:04 AM Aug 23, 2016, 7:04 AM

          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
          • H
            hwyml
            last edited by Aug 23, 2016, 7:06 AM

            I agree with you. Thank you!

            1 Reply Last reply Reply Quote 0
            • M
              MAPJe71
              last edited by MAPJe71 Aug 23, 2016, 7:29 AM Aug 23, 2016, 7:28 AM

              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
              4 out of 6
              • First post
                4/6
                Last post
              The Community of users of the Notepad++ text editor.
              Powered by NodeBB | Contributors