User Defined Language doesn't exclude sign in front of numbers
I’m trying to finish a user defined language for OCL files, but the Operators 1 section that allows for numbers without spaces isn’t excluding the sign when directly in front of numbers. Is there a way around this?
From the example you can see it works fine for <num><sign><num>, <num><sign><text>, and <text><sign><text>, but the style seems to assume + or - constitute a number sign for this specific whether it is wanted or not - and in this case it is never wanted.
These are customer files, so I don’t get to modify them. Is there a workaround for this that will provide what is needed? I tried to accomplish this with Keywords Lists, but it doesn’t seem to treat non-alpha text as valid, at least not in a way that seems to work here, so even when I remove all operators, it isn’t allowing me to use special cases like “)+”, etc.
I haven’t done a lot of this before, so I could easily be missing something and it would be great to know.
UDL has its limitations.
-prefixing a number with no intervening space will always be treated as part of the number.
If you add the EnhanceAnyLexer plugin using Plugins Admin, you can use that plugin to have a regular expression apply foreground coloring:
0xFFFF00 = [+-](?=\d) ; for UDL, need to remove 3 from excluded styles if you want ; this new color to override the number styling excluded_styles = 1,2,4,5,6,7,8,9,10,11,12,13,14,15,16,20,21,22,23
I used cyan in my example (0xGGBBRR=0xFFFF00) to make it obvious:
without EnhanceAnyLexer (or with the definition commented out):
The 24 style numbers are defined in the Notepad++ UDL source code (a similar link is present in the default EnhanceAnyLexerConfig.ini, if anyone reads the comments there…)