Community
    • Login

    UDL Using a space as an end delimiter

    Scheduled Pinned Locked Moved Help wanted · · · – – – · · ·
    3 Posts 2 Posters 2.2k Views 2 Watching
    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 Offline
      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 Offline
        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 Offline
          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

          Hello! It looks like you're interested in this conversation, but you don't have an account yet.

          Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.

          With your input, this post could be even better 💗

          Register Login
          • First post
            Last post
          The Community of users of the Notepad++ text editor.
          Powered by NodeBB | Contributors