UDL Using a space as an end delimiter



  • 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?



  • @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…



  • @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.


Log in to reply