Is it possible to have a * as an operator and as a comment?
How do I prevent the two from conflicting?
For example, if I do 10 * 10 | After the * symbol it will comment instead of being an operator.
I assume this is another UDL question. It’s better to be explicit, so we don’t have to guess.
How does your language distinguish between a
*that means “multiply” and a
*that means “start a comment”?
I don’t know your language, but how would it tell the difference between
a = 5 * 15
a = 5 * 15
where the first is supposed to have
* 15be a comment and in the second, the
* 15is supposed to be multiplication?
Okay, assuming this is still
ABAPfrom before, I just did a quick search on “ABAP comments” and found this… if I skimmed that correctly,
*only indicates a comment at the start of a line. That makes it easier, and there is a feature built into Notepad++'s UDL to work with that.
That’s why Comment & Number has a Comment line style with the line comment position – set it to “Allow preceding whitespace”, which means that the
*has to be the first non-space character on the line.
Please notice: we cannot be expected to be experts in every possible programming language; if you had given examples of comments vs multiplication, it would have been much easier to help you; as it was, I was willing to do a 30second google to get the answer, but if you really want help, you should have supplied the information to begin with.
If you are going to be using UDL, it would behoove you to follow the link on the first page of the UDL dialog and read the documentation that Ivan Radić provided; it gives a great practical overview of how to use UDL, and what each of the entry blanks mean.
… and with your slew of questions, I am assuming you will soon ask how to get the quote-to-end-of-line version of comments as well:
Please note that if you choose
force at beginning of linerather than
allow preceding whitespace, it should mostly work for the ABAP comments… but if you have a comment-line as the first line, it won’t always recognize that as a comment, whereas
allow preceding whitespacewill more reliably recognize it.
The built in feature doesn’t seem to be working. Even when I use force at beginning of line or allow preceding whitespace. It seems to comment out instead of being an operator.
That’s because you changed what I showed.
In the right comment style box, I had a
", not a
*. If you use the right comment style with an asterisk, then always and anywhere, asterisk-to-end-of-line is a comment, which is not what you want.
… actually, you’ll probably not want the
((EOL))on the right-side “comment style” at all, since you have it as a delimiter already.
Please note that UDL is not an infinitely-configurable solution; there are times that your desired styling for a language goes beyond what UDL can offer.
At that point, your choices are to write a full lexer plugin which can be distributed as a DLL or through the Plugins Admin; if that’s beyond your scope, you might get the extra highlighting you want by using the Python Script plugin and the script
EnhanceAnyLexer.pythat @Ekopalypse shares in his github repo, which allows you to add extra highlighting to a builtin lexer (like the HTML lexer) or to a User Defined Language (UDL) using regexes.
So if you cannot get the UDL “good enough”, do as much as you can, then try Eko’s script. If that still doesn’t cover your needs, writing a lexer plugin is the next option.