Community
    • Login

    UDL Using a space as an end delimiter

    Scheduled Pinned Locked Moved Help wanted · · · – – – · · ·
    3 Posts 2 Posters 1.7k 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.
    • dansdevelopmentsD
      dansdevelopments
      last edited by

      I am trying to use the User Defined Language feature, and I have a syntax highlighting question.

      I have an operator, @, that allows me to specify an attribute of the preceding object, such that if I wanted to get the length of an array called arr, I would type

      arr@length

      I would like @length to highlight in this case.

      There is another case where with specific attributes, they may have sub-attributes, denoted by dot notation, such as

      arr@style.color

      In either case the attribute will only ever be followed by a space or maybe an end of line, so I wanted to define it as a delimiter, but I’m not sure how to specify a space as the end delimiter. It would also be acceptable to highlight an unknown number of alpha characters and periods if that is easier.

      Any ideas?

      PeterJonesP 1 Reply Last reply Reply Quote 0
      • PeterJonesP
        PeterJones @dansdevelopments
        last edited by

        @dansdevelopments ,

        I don’t think you will be able to get what you want with pure UDL syntax.

        Fortunately, you can add extra highlighting to any lexer, including the User Defined Language (UDL), using regexes via the script EnhanceAnyLexer.py that @Ekopalypse shares in his github repo. I think if you used that and matched on a regex like @\S*, it would match on @ followed by 0 or more non-space characters. If you want to be more restrictive, like @ followed by letters and maybe one dot, then @[[:alpha:]]*(\.[[:alpha]]*)? might be better…

        dansdevelopmentsD 1 Reply Last reply Reply Quote 1
        • dansdevelopmentsD
          dansdevelopments @PeterJones
          last edited by

          @PeterJones,
          Thank you! I was sure there had to be a way to do this. I was hoping to avoid using something outside UDL, but I’m glad to know there is a way to deal with this. Gonna take look at it.

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