Navigation

    Community

    • Login
    • Search
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search

    UDL Using a space as an end delimiter

    Help wanted · · · – – – · · ·
    2
    3
    226
    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.
    • dansdevelopments
      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?

      PeterJones 1 Reply Last reply Reply Quote 0
      • PeterJones
        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…

        dansdevelopments 1 Reply Last reply Reply Quote 1
        • dansdevelopments
          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
          Copyright © 2014 NodeBB Forums | Contributors