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.



  • @cll142

    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
    

    and

    a = 5 * 15
    

    where the first is supposed to have * 15 be a comment and in the second, the * 15 is supposed to be multiplication?

    Okay, assuming this is still ABAP from 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.

    07983ce9-27dd-4518-8bc7-d663ea660607-image.png

    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:
    b76a5086-016f-4349-9aed-3e4d3b197fc9-image.png



  • Please note that if you choose force at beginning of line rather 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 whitespace will 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.
    292d2255-6d95-4229-84b4-8173e3fa5220-image.png
    daead771-5a30-484d-b304-7df312d1d323-image.png 0aa7db6d-a9be-4e04-855c-e544a7ac591a-image.png
    dd3dbaea-f517-4337-bacd-245cc2ad567a-image.png



  • @cll142 ,

    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 " to ((EOL)) on the right-side “comment style” at all, since you have it as a delimiter already.



  • @cll142 ,

    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.py that @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.


Log in to reply