• Login
Community
  • Login

Simple Function list but not working

Scheduled Pinned Locked Moved Help wanted · · · – – – · · ·
3 Posts 2 Posters 254 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.
  • S
    shsteve07
    last edited by PeterJones May 17, 2024, 1:02 PM May 16, 2024, 10:28 PM

    Hi
    I have looked at the help and FAQ and none the wiser :(

    The functions I am looking for have the syntax (not case-sensitive)
    !whatever:rem
    So !*:rem works as a regular expression

    The language name and name of the function list are the same.
    The language is a simple C version, so I took the c.xml, renamed it and displayed the name and ID tags.
    Setting the function name does not make sense to me.

    <functionName>
    <nameExpr expr="(?x)        # Utilize inline comments (see `RegEx - Pattern Modifiers`)
    	[A-Za-z_\x7F-\xFF][\w\x7F-\xFF]*
    	\s*\( !                                          # start of parameters
    	(?s:.*?)                                        # whatever, until...
    	:rem\)                                           # end   of parameters
    " />
    

    Can someone point out where I am wrong, please?

    —

    moderator added code markdown around text; please don’t forget to use the </> button to mark example text as “code” so that characters don’t get changed by the forum

    P 1 Reply Last reply May 17, 2024, 1:25 PM Reply Quote 0
    • P
      PeterJones @shsteve07
      last edited by PeterJones May 17, 2024, 1:45 PM May 17, 2024, 1:25 PM

      @shsteve07,

      When I merge that regex into one line (?x) [A-Za-z_\x7F-\xFF][\w\x7F-\xFF]* \s*\( ! (?s:.*?) :rem\), and try it in the MARK dialog, like the following:

      spacer
      func (!blah:rem)
      spacer
      notfunc (!something else)
      spacer
      stillnot (!this)
      spacer
      butyes (!whatever:rem)
      spacer
      butabsoultelynot (!whatever:rem )
      spacer
      norspacey ( !whatever:rem)
      spacer
      

      e93b9c1b-fb7f-4b4f-b69e-453ec9fdf557-image.png

      As you can see, it found three matches: line 2 was a single match, lines 4-8 was a single match, and lines 10-12 was the third match.

      Function names for the FunctionList feature should normally resolve down to a single line of text (or less)

      When I use your functionName’s nameExpr, I get:
      ad00af99-6197-442e-a06e-3412d9b054bb-image.png
      … each of those entries matches the first line of the three blocks that MARK found. So it’s behaving as I’d expect it.

      Also note that your regex has some restrictions, like the ! must come immediately after the ( with no spaces between, and the :rem must come immediately before the ) with no spaces in between. I am not sure if that’s intentional.

      Since you gave no examples of text that you expected to show up in the function list panel and text you didn’t, I cannot know what you intended, and cannot try to help you fix it.

      Update: But my guess is that even though you tried to make it non-greedy, the sub-expression (?s:.*?) is probably matching more than you think it does. I think you probably wanted it to stop if it ever hit a ) that wasn’t preceeded by :rem, but you don’t have that there. If that’s the case, I would change it to (?s:[^)].*?) … this would only find the func and the butyes lines in my example code, which I think were the two that you would expect to match.

      8a0a2f99-d471-4bbb-b879-1bc8d8cbdd4e-image.png

      1 Reply Last reply Reply Quote 2
      • S
        shsteve07
        last edited by May 24, 2024, 3:31 AM

        Thanks for your time on this, Peter.
        I have spent more time on this than it was worth and will shelve it until I get some more free time.

        1 Reply Last reply Reply Quote 0
        2 out of 3
        • First post
          2/3
          Last post
        The Community of users of the Notepad++ text editor.
        Powered by NodeBB | Contributors