User-Defined Language | Block comments



  • Dear all,
    I created a user-defined language using the GUI (Language --> Define your language…) in Notepad++ v6.9.2 on Windows.
    The syntax highlighting is working perfectly, except for comment stlye (block comments). My comment settings are:

    • Line comment position: Allow anywhere
    • Allow folding of comments: <checkmark set>
    • Comment line style:
      - Styler: <all empty/no settings>
      - Open: $
      - Continue character: <empty>
      - Close: <empty>
    • Comment style:
      - Styler: <all empty/no settings>
      - Open: $$
      - Close: $$

    Just to clarify:
    Opening of a comment line must be done with a $.
    Opening and closing of a block comment must be done using a $$, as I do not have any influence on the language itself.

    Thank you for helping!
    ePostler



  • @ePostler said:

    Dear all,
    I created a user-defined language using the GUI (Language --> Define your language…) in Notepad++ v6.9.2 on Windows.
    The syntax highlighting is working perfectly, except for comment stlye (block comments). My comment settings are:

    • Line comment position: Allow anywhere
    • Allow folding of comments: <checkmark set>
    • Comment line style:
      - Styler: <all empty/no settings>
      - Open: $
      - Continue character: <empty>
      - Close: <empty>
    • Comment style:
      - Styler: <all empty/no settings>
      - Open: $$
      - Close: $$

    Just to clarify:
    Opening of a comment line must be done with a $.
    Opening and closing of a block comment must be done using a $$, as I do not have any influence on the language itself.

    Thank you for helping!
    ePostler

    Sorry, but my message was not previewed correctly on the right side!
    Block comments use two dollar signs for opening and closing!!
    So like this $ $ , but without any space inbetween!
    Cheers, ePostler



  • @ePostler
    Instead of the Comment & Number tab, have you tried to use the Operators & Delimiters tab to highlight block comments? I use it to have various flavors of comments by defining different Delimiter styles for each.

    The delimiters seem to work pretty well for all kinds of “block” highlighting.



  • @ePostler

    and in addition,what I discovered recently, when using delimiters and one is a subsets of the other
    define the subset later. E.g.

    Delimiter1
    Open:$$
    Close:$$

    Delimiter2
    Open:$
    Close:((EOL))

    Cheers
    Claudia



  • fail into the same trap - first delimiter is of course two dollar signs.

    Delimiter1
    Open:$$
    Close:$$

    Delimiter2
    Open:$
    Close:((EOL))

    Cheers
    Claudia



  • Thank you for your response! I solved my problem with Claudia Frank’s suggestion!



  • Is it possible to define a single space in a delimiter?
    I am thinking on defining Delimiter Open as $ followed by a single space. Using regular expressions, I would like to use something like $\s
    The background to this is that in the language, which I use, the $ is used (too) extensively :) It is used for comments ($), block comments ($$), and for modifying some expressions ($). For the latter, no space is allowed. This led to the idea of defining the normal comment as $\s.
    I thought looked up regular expressions, but could not find a solution yet.
    Reading trough the UDL 2.0 doc gave me the idea that a space may cannot be defined.
    However, I hope someone of you has got a solution or at least a hint for me :)



  • @ePostler

    afaik no, you cannot define a space to be significant.
    If I understand correctly, your dollar sign is used like this

    $expression
    
    $ line comment
    
    $$block
    comment
    comment
    comment
    $$
    
    $another_expression
    

    If this is the case than you can define
    delimiter 1 two dollar signs open and close
    delimiter 3 one dollar sign + a to one dollar sign + z using the same
    color as the expression or default and the same amount of ((EOL)) for closing
    So e.g. $a $b $c $d $e $f … $z
    Together with ((EOL)) ((EOL)) ((EOL)) ((EOL)) ((EOL)) … ((EOL))
    delimiter 5 one dolar sign for open and ((EOL)) for close.

    Btw. the new udl documentation link is http://ivan-radic.github.io/udl-documentation/

    Cheers
    Claudia

    P.S. I don’t know if this can be solution for but I’m working on a python script
    based lexer which uses regular expressions exclusively. If you are interested let me know.
    I assume that it might take another 2-4 weeks before it can go public.